Jump to content
  • Advertisement
Sign in to follow this  
Metzler

[.net] Which keyboard sent the input?

This topic is 4912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I've got one question: I have a keyboard and a remote control connected to the computer, which both are handled as normal keyboards by Windows XP. Is there a way of determining, which of those two devices sent the input in .NET? So when i press the "1" on my remotecontrol i want to be able to know, that it was my remote control and not my keyboard. THX in advance Metzler

Share this post


Link to post
Share on other sites
Advertisement
Try DirectInput. It can enumerate alll the devices attached to your PC and track them.

Luck!
Guimo

Share this post


Link to post
Share on other sites
Quote:
Original post by Metzler
Hey,

I've got one question: I have a keyboard and a remote control connected to the computer, which both are handled as normal keyboards by Windows XP.
Is there a way of determining, which of those two devices sent the input in .NET?
So when i press the "1" on my remotecontrol i want to be able to know, that it was my remote control and not my keyboard.

THX in advance

Metzler


As far as I know, that functionality is not part of the .NET Framework. DirectInput/Managed DirectX is probably the way to go here, as the above poster suggested.

Share this post


Link to post
Share on other sites
So i just tried listing all Input Devices with the Manager class, but this particular one cant be found...
Any idea, guys?
In the device manager, both are listed...

THX in advance

Share this post


Link to post
Share on other sites
Some input devices don't work with directx or in the case of my tablet only expose a tiny subset of their functionality. It may totaly be overkill but check and see if the maker of your input device supplies some library or works with some standard library (for my tablet there was wintab). If you can find a lib than you may be able to use pinvoke to access the input device through that lib.

Also: all of you compatable devices should show up in the DirectX caps viewer -- but that should be the same as your EnumerateDevices call.

Share this post


Link to post
Share on other sites
Ok, listing the different keyboard devices with WMI works fine. But how do i get from listing the device to getting the input from a particular one?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just guessing here... But this is what I would try myself.

When your application start, enumerate all (your 2) keyboards and save away IDirectInputDeviceX pointers to them.

In your WM_KEYDOWN handler, call IDirectInputDevice8::GetDeviceState, which returns a byte array with each key's state. You'd have to look in the array for your remote control to see if that array indicates that the whatever key was pressed, or if it was pressed by another keyboard.

http://msdn.microsoft.com/library/en-us/directx9_c/directx/input/ref/ifaces/idirectinputdevice9/GetDeviceState.asp


Please post result if you try this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!