Joystick GetDeviceData()

Rob Crittenden <[email protected]> Wed, 05 Jan 2005 22:03:21 -0500
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
Someone in the forum asked about configuring a joystick to work in 
BF1942. I had added the GetDeviceData() function to allow a joystick to 
work at all in BF1942. At the time actually configuring the joystick was 
a bit wierd but I sort of blew it off as a game bug.

What happens is that when you go to remap an axis you have to click on 
the field you want to map and hit a button, move a joypad, whatever. For 
  doing the axis fields more often than not the one you just did will 
repeat itself again the next time you try to remap something. So if you 
move the joystick left when remapping a field, the next field you click 
on will also think it is joystick left.

I looked again and I see what the problem is. Two events are triggered 
as a result of this: the value from moving left and moving back to 0.

It would appear that only the first event is getting picked up by their 
config code so when another joystick event is needed, it is the moving 
back to center.

I suppose they have their own internal queue of joystick events that 
they populate based on GetDeviceData() and they pull items off as they 
use them. That might explain it. Otherwise I can't think of a workaround.

Here is a small bit of trace that demonstrates what I think is going on:

trace:joystick:LINUX22_GetDIData axis 0 -> -26350
trace:dinput:JoystickAImpl_GetDeviceState 
(this=0x403e37f0,0x00000110,0x406d1aa4)
trace:dinput:JoystickAImpl_GetDeviceData 
(0x403e37f0)->(dods=20,entries=10,fl=0x00000000)
trace:dinput:JoystickAImpl_GetDeviceData Application retrieving 1 event(s).
trace:dinput:JoystickAImpl_Poll (this=0x403e37f0)
trace:dinput:JoystickAImpl_GetDeviceState 
(this=0x403e37f0,0x00000110,0x406d1aa4)
trace:dinput:JoystickAImpl_GetDeviceData 
(0x403e37f0)->(dods=20,entries=10,fl=0x00000000)
trace:dinput:JoystickAImpl_GetDeviceData Application retrieving 0 event(s).
trace:dinput:JoystickAImpl_Poll (this=0x403e37f0)
trace:dinput:JoystickAImpl_GetDeviceState 
(this=0x403e37f0,0x00000110,0x406d1aa4)
trace:dinput:JoystickAImpl_GetDeviceData 
(0x403e37f0)->(dods=20,entries=10,fl=0x00000000)
trace:dinput:JoystickAImpl_GetDeviceData Application retrieving 0 event(s).
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Poll (this=0x403e37f0)
trace:joystick:LINUX22_GetDIData axis 0 -> 0
trace:dinput:JoystickAImpl_GetDeviceState 
(this=0x403e37f0,0x00000110,0x406d1aa4)
trace:dinput:JoystickAImpl_GetDeviceData 
(0x403e37f0)->(dods=20,entries=10,fl=0x00000000)
trace:dinput:JoystickAImpl_GetDeviceData Application retrieving 1 event(s).
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Acquire (this=0x403e37f0)
trace:dinput:JoystickAImpl_Poll (this=0x403e37f0)
trace:dinput:JoystickAImpl_GetDeviceState 
(this=0x403e37f0,0x00000110,0x406d1aa4)
...
(lots more retrieving 0 event(s)).