Hey guys, asking for a little code review here...
I was looking at the solution for this bug http://bugs.winehq.org/show_bug.cgi?id=30705 and it comes down to implementing the DIPROP_JOYSTICKSID property for joystick devices. After some research on what this is I know it's always a number between (0,n), where n is the number of joysticks connected, and is analogous to the winmm driver joystick id.
The solution I came up is in the attached patch, it's a little weird but I found it hard to give a unique ID to each joystick on Linux when they can come from different drivers. This solution uses the order which dinput puts the joysticks on it's device list and will work regardless. If someone has a better way to do it I'd like to know.
Cheers,
On 05/28/2012 12:53 PM, Lucas Zawacki wrote:
The solution I came up is in the attached patch, it's a little weird
It's not just weird it's incorrect. You shouldn't use that list or rely on order of devices in that list.
Instead you should use get_joystick_index() to get the index. It's not exactly clear where this ID is used so I doubt returning the same ID for different drivers will change anything
Vitaliy.
Ok, I sent patches doing this for linux and linuxinput drivers and a test. The joystick_osx.c version of this could be done but I dont have the means to test so if anyone wants to do it, you're welcome.