| Summary: | DirectX back-end handles multiple joysticks incorrectly. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Erik Soma <stillusingirc> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | stillusingirc |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Windows (All) | ||
| Attachments: | Fix for bug | ||
Upon further inspection it is fine I just didn't realize the separation between the joystick's instance id and device index was intentional. In hindsight it seems obvious :) |
Created attachment 1025 [details] Fix for bug When multiple joysticks are attached to the system the joysticks are opened incorrectly. Specifically, the SDL_Joystick will be assigned the wrong instance_id for the joystick_id requested. This is contrary to what the user expects, since the instance_id is used for for event.[type].which in joystick events. With two joysticks attached to the system: If we SDL_OpenJoystick(0) we will get an SDL_Joystick with the instance_id 1. If we SDL_OpenJoystick(1) we will get an SDL_Joystick with the instance_id 0. I determined that the implementation is handing out the internal directx joysticks in reverse order because of how the linked list of joysticks is being populated. Explains why it works fine with a single joystick. I believe I've fixed the issue by using a linked list more similar to the one in the Linux joystick back-end (with a head/tail) and rewriting the callback function that enumerates the connected joysticks. I need to do some more testing, especially regarding disconnecting and reconnecting devices, but I've attached a patch in the meantime for any potential feedback.