You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a long time trying to figure this out, I’ve discovered that SDL2 is using a signed integer for its joystick IDs so it can be both compared to, and used as an error code by SDL_NumJoysticks.
Given that the intent is for the “which” returned by ControllerDeviceAdded to be used in SDL_GameControllerOpen (as it is impossible to use it without first opening it!), it currently has an incompatible type with sdl::GameControllerSubsystem#open, where we’re accepting only a u32.
Given that rust-sdl2 converts other SDL2 errors to native Rust errors, and sdl2::GameControllerSubsystem#num_joysticks already does, I'd propose that ControllerDeviceAdded events be updated to supply which as a u32, so it can be used directly with open without requiring a confusing type conversion!
The text was updated successfully, but these errors were encountered:
After a long time trying to figure this out, I’ve discovered that SDL2 is using a signed integer for its joystick IDs so it can be both compared to, and used as an error code by
SDL_NumJoysticks
.This means that all
ControllerDevice
events returnwhich
as ansint32
, while onlyControllerDeviceAdded
actually intends to be used as a signed integer. Meanwhile, theControllerAxis
andControllerButton
events use theSDL_JoystickID
, which is a uint underneath.Given that the intent is for the “which” returned by
ControllerDeviceAdded
to be used inSDL_GameControllerOpen
(as it is impossible to use it without first opening it!), it currently has an incompatible type withsdl::GameControllerSubsystem#open
, where we’re accepting only a u32.Given that rust-sdl2 converts other SDL2 errors to native Rust errors, and
sdl2::GameControllerSubsystem#num_joysticks
already does, I'd propose thatControllerDeviceAdded
events be updated to supplywhich
as au32
, so it can be used directly withopen
without requiring a confusing type conversion!The text was updated successfully, but these errors were encountered: