Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix using invalid joystick id in event handlers #13

Merged
merged 3 commits into from
Sep 17, 2020

Conversation

more-errors
Copy link
Contributor

@more-errors more-errors commented Sep 16, 2020

This PR fix using incorrect id while handle joystick events.

Description

In the function getJoystick, the id pass as an argument refers to N'th joystick on the system (system device index). But this index is not the value which will identify this joystick in the future joystick events. The joystick's instance id (SDL_JoystickID) will be used there instead.
However, now we are using system device index as id while handle joystick events. It leads to crashes when handle events after connecting additional joysticks and pass wrong id to signals in update function when working with multiple joysticks.

Solution

Add additional instanceID field for SDL_JoystickID in QJoystickDevice. Use this field to identify joystick while handle events.
Note that "instanceID" field is permanent id of joystick (and it will not be changed untill joystick is reconnected), while "id" field can be changed.

Linked issues

Bug #6 is fixed now

@alex-spataru
Copy link
Owner

Thanks, merging.

@alex-spataru alex-spataru merged commit 23931b8 into alex-spataru:master Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants