none
Creating custom InputDevice RRS feed

  • Question

  • Hello,

    I'd just like to ask... I'm trying to create a new InputDevice, but how do I set the InputEventArgs.Device property in PreProcessInput when it is read-only?

     

    If there is any documentation about how this all works or about creating custom InputDevice, please point me to it..

     

    Thanks,

    Jan

    Sunday, March 23, 2008 3:48 PM

Answers

  • The device is specified in the event arg constructor.  Each device is expected to have its own set of events.  However, we did not expose the input providers sufficiently for external implementation.  Specifically, InputProviderSite is internal.

     

    So, basically, this is not really supported.

     

    Tuesday, March 25, 2008 12:16 AM

All replies

  • The device is specified in the event arg constructor.  Each device is expected to have its own set of events.  However, we did not expose the input providers sufficiently for external implementation.  Specifically, InputProviderSite is internal.

     

    So, basically, this is not really supported.

     

    Tuesday, March 25, 2008 12:16 AM
  • Thank you Dwayne for answer.

    Do you have any idea whether this is going to be available in future release?

     

    Thanks,

    Jan

     

    Wednesday, March 26, 2008 9:43 PM
  • We haven't decided on how or how much of the input system to expose. Could you explain your scenario?

    Thursday, April 3, 2008 6:19 PM
  • Well Dwayne, to be honest, I'm working with the .NET Micro Framework at the moment. And as their model is based on WPF, there are the same problems implementing custom InputDevice as in big WPF. However, in .NET MF, there is only ButtonInputProvider now, so my current real scenario is a need for keyboard input provider... (CommandInputProvider or Mouse could follow)

     

    And I give to the consistency between WPF and MF WPF much higher priority than the ability to do it in MF only.

     

    But it could be also if I wanted to bring the concept of Buttons into the WPF, or I have seen this request together with multi-touch devices.

    I could also imagine one would need to create custom input providers for special devices helping people with disabilities.

     

    How much of the input system to expose - that's indeed difficult question. The problem is, that it is not possible now at all. I mean, regardless of how much work would developers need to do themselves, when there is a (reflection free) way, it is enough.

     

    Thank you for your time on this!

    Jan

    Saturday, April 5, 2008 7:44 PM
  • Well, does the current input model allow me create a KeyboardInputDevice reading data from serial port for example?

     

    I would also like create input system for white boards out there, which are a little bit different than tablets.

     

     

    Is there any place where this stuff can be discussed?

     

     

    Jan

    Thursday, April 24, 2008 5:23 PM
  • The official way to do this is to monitor your device (serial port, USB, etc) and then call the Win32 API SendInput to simulate either a mouse or a keyboard.  This simulates the input at a very low level, and the OS will think it is legitmate input from one of those devices, and WPF will convert it into the appropriate events.  This works for many scenarios, but "dumbs down" the new device to one of the legacy devices.  On the other hand, this has its advantages since almost all applications will work with it.

     

    Ideally, you should do this from a seperate process or service.  This way, the device can work across all applications. Your serial-bus keyboard-ish device can then be used to work with IE, Office, WPF, etc.

     

    Of course, sometimes your device has unique capability.  For example, the pen/stylus device used for the TabletPC can report all sorts of extra stuff like pressure, tilt, etc. This information is lost when simulating the mouse.  Another example might be multi-touch - you wouldn't want the mouse cursor flickering between the contact points all the time.  For these advanced scenarios, you really do want to introduce new input events and state.  You may even need to introduce your own notions of hit-testing or focus.

     

    As noted above, WPF does not expose all of the internal mechanisms by which we implemented our input devices.  But you can do basically the same thing we do: just raise your own events with your own data in them.  These events do not need to derive from InputEventArgs or anything. 

     

    The biggest feature you woulod be missing is integration with other input providers.  As an example, we use this integration to promote stylus events into mouse events.  This way controls that don't have special stylus behaviors see the events as mouse events, but controls with specialized behavior can respond to the richer stylus-specific events. 

    Thursday, April 24, 2008 5:49 PM
  • Thank you for answer, tips and patientce with me.

     

    I guess in the case of white boards it would be good idea to promote the events of pens or hands into mouse events, just as with stylus, in fact I would like to promote them into stylus events themselves - that way the stylus system would take care of converting it into mouse events.

     

    Okay, so.. I just wonder, should I try put some demand on making this available, like creating a suggestion on Connect or anything, or just leave it as it is and hope that someday it will be possible?

     

    Thanks,

    Jan

    Thursday, April 24, 2008 6:01 PM
  • I will pass your scenario requirements to the product team.

    Thursday, April 24, 2008 7:02 PM
  • Thank you.

     

    Thursday, April 24, 2008 7:19 PM
  • Hello,
    I wonder if there are any news for .NET 4.0 in this area...

    Thanks,
    Jan
    Sunday, December 28, 2008 4:58 PM
  • I'm also interested in creating a custom InputDevice.  I'm wondering if there's been any changes in .NET 4.0 or .NET 4.5 to make this easier.  My scenario is I want to create a custom input device for Kinect.


    matt

    Friday, April 6, 2012 12:37 AM
  • Year 2016. I need to handle some custom input hardware. Any improvement here?


    Mauro

    Monday, May 9, 2016 12:50 PM