We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4189 - Joystick reports wrong `which` value on event and wrong `GUID` on SDL_JoystickGetDeviceGUID.
Summary: Joystick reports wrong `which` value on event and wrong `GUID` on SDL_Joystic...
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.8
Hardware: x86_64 Windows 7
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-07 13:42 UTC by jlalvarez
Modified: 2018-06-07 14:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jlalvarez 2018-06-07 13:42:03 UTC
On windows, with current (2.0.8) SDL version, if two joysticks are plugged SDL initially enumerates them as:

[SDL2] Joystick number 0 -- "Saitek X45"
  --> Buttons: 26
  -->    Axis: 6
  -->    Hats: 1
  -->   Balls: 0
  -->    GUID: "03000000a30600003c05000000000000"
[SDL2] Joystick number 1 -- "Generic   USB  Joystick  "
  --> Buttons: 12
  -->    Axis: 5
  -->    Hats: 1
  -->   Balls: 0
  -->    GUID: "03000000790000000600000000000000"

But immediately the events generated by Joystick 0 (Saitek X45) have the event `which` attribute set to 1, and the events generated by the joystick 0 (Generic) have the `which`attribute set to 1.

More worrying, if I disconnect joystick 1 (Generic) and whenever an event from Joystick 0 (Saitek) is received I call `SDL_JoystickGetDeviceGUID` with the events' `which` value, it will still be 1 and the returned GUID will be all-zero.

How to reproduce:
- Enumerate and open all joystick devices (SDL_JoystickOpen).
- register an event callback (SDL_AddEventWatch).
- Whenever a joystick event is received, call SDL_JoystickGetDeviceGUID with `which`as an argument.

At this point, printing the event `which`argument should be swapped around between joystick 1 and 0. The device enumerated as '0' will have '1' on the `which` attribute and the other way around.

- Disconnect device 1
- Move device 0
- the returned GUID will be all-zero and the event `which` value should still be swapped. Somehow I am receiving events from a device that does not exist/have GUID.
Comment 1 jlalvarez 2018-06-07 14:56:54 UTC
Missread the meaning of `which` on the docs. This bug ain't a bug but my own error.