fix: use JoystickId for joystick/gamepad event which fields#322
fix: use JoystickId for joystick/gamepad event which fields#322revmischa wants to merge 1 commit into
Conversation
|
I can add a Debug would say it's SDL_JoystickId instead of just JoystickId, but with this you could keep using the alias instead of making your own newtype for it. The event fields should still be updated to use the id type though so that'd still be a breaking change |
How should we proceed? |
|
I added the |
Replaces the previous custom newtype approach with the simpler one maia-s suggested in #322: keep JoystickId as a type alias for sdl3-sys's SDL_JoystickID and rely on sdl3-sys 0.6.5's display-impls/debug-impls features and the new `SDL_JoystickID::new(...)` constructor. The breaking change is unchanged: event `which` fields go from u32 to JoystickId. Migration is `JoystickId::new(0)`.
6e0465d to
54fa191
Compare
|
Reworked per @maia-s's suggestion: Stacked on #379 which bumps sdl3-sys to 0.6.5. |
Replaces the previous custom newtype approach with the simpler one maia-s suggested in #322: keep JoystickId as a type alias for sdl3-sys's SDL_JoystickID and rely on sdl3-sys 0.6.5's display-impls/debug-impls features and the new `SDL_JoystickID::new(...)` constructor. The breaking change is unchanged: event `which` fields go from u32 to JoystickId. Migration is `JoystickId::new(0)`.
54fa191 to
8065da9
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the public API surface for joystick/gamepad IDs by switching event which fields and related getters to use JoystickId (SDL’s joystick instance ID type) instead of u32, aligning event payloads with the rest of the joystick/gamepad APIs.
Changes:
- Update
Joystick::id()andGamepad::id()to returnJoystickIdand adjust error checks accordingly. - Change joystick/gamepad-related
Event::*::whichfields fromu32toJoystickId, including test updates and doctest examples. - Enable
debug-implsanddisplay-implsfeatures forsdl3-sysand adjust example output formatting to useDisplay.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/sdl3/joystick.rs |
Returns JoystickId from joystick APIs and simplifies passing IDs to sys calls. |
src/sdl3/gamepad.rs |
Returns JoystickId from Gamepad::id() with updated error checks. |
src/sdl3/event.rs |
Updates all joystick/controller event which fields to JoystickId and updates tests/docs. |
examples/gamepad.rs |
Prints gamepad IDs via Display instead of accessing .0. |
Cargo.toml |
Enables debug-impls/display-impls on sdl3-sys to support formatting traits. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaces the previous custom newtype approach with the simpler one maia-s suggested in #322: keep JoystickId as a type alias for sdl3-sys's SDL_JoystickID and rely on sdl3-sys 0.6.5's display-impls/debug-impls features and the new `SDL_JoystickID::new(...)` constructor. The breaking change is unchanged: event `which` fields go from u32 to JoystickId. Migration is `JoystickId::new(0)`.
8065da9 to
3fcd4e2
Compare
Converts JoystickId from a type alias to a proper newtype struct with Debug, Display, and From trait implementations.
whichfieldBreaking change: Event
whichfields now require JoystickId instead of u32. Migration is straightforward using the From/Into impls:Part 1 of 2 for #319. The second PR will rename Controller* events to Gamepad* to match SDL3 terminology.