As the titile
If I have two joysticks or two keyboards in the computer
How to get the press event of the two devices...
Thank you!!
As the titile
If I have two joysticks or two keyboards in the computer
How to get the press event of the two devices...
Thank you!!
How to get multi devices through directinput, Thank you!!
sillywilly78
Which language are you accessing DInput via (C#, VB6, VB.Net, C, C++...). I'll assume you're dealing with DirectInput8 as that's been the current version for years now
In my experience it should be as simple as creating multiple IDirectInputDevice8 objects - one for each device you wish to work with. The relevant SDK samples show how to enumerate what devices are attached to the system.
Just bare in mind that, for joysticks, XInput complicates things a little when you're dealing with DInput. Check out the 'joystick' sample in the SDK for more details on how to handle that situation...
hth
Jack
NOX2021
First thank you very much!!
And I will say the problem more clearly. I use C++ and Direct9( October 2005 which contains the DirectInput8 )
I have try you solution but it does not wok. I run the method InitDirectInput two times with two LPDIRECTINPUTDEVICE8 instances but it actually get the same Device so I just can use One of the two Joysticks.
The SDK says "call the EnumDevice method to enumerate the joysticks" I think that's the problem but I don't konw what I should do in the methond.
Does that clear
Can you help me again And with a simple sample
Thank you very much!!!
michaelp
Take a look at the joystick sample from the SDK.
In the “InitDirectInput” function it calls “EnumDevices” with the callback function “EnumJoysticksCallback”. This Function is called one time for each joystick in your system as long as you return “DIENUM_CONTINUE”.
Instead of create a device for the first joystick that is in your system you should save all in a list. You need at last the device guid but if you copy the whole DIDEVICEINSTANCE structure you will have more information for the user interface. After it has enumerated all joysticks in your system the EnumDevice method returns.
Now you can use the guids in your list to create for every joystick you want a device with the “CreateDevice” method from the DirectInput interface.
BTW: It is not longer recommended to use DirectInput for keyboard and mouse input.