Skip to content

refactor: rename Controller* events to Gamepad* for SDL3 consistency#323

Open
revmischa wants to merge 2 commits into
fix/joystick-id-newtypefrom
fix/gamepad-event-naming
Open

refactor: rename Controller* events to Gamepad* for SDL3 consistency#323
revmischa wants to merge 2 commits into
fix/joystick-id-newtypefrom
fix/gamepad-event-naming

Conversation

@revmischa

Copy link
Copy Markdown
Member

Renames event types and variants to match SDL3's gamepad terminology:

Old Name New Name
ControllerAxisMotion GamepadAxisMotion
ControllerButtonDown GamepadButtonDown
ControllerButtonUp GamepadButtonUp
ControllerDeviceAdded GamepadAdded
ControllerDeviceRemoved GamepadRemoved
ControllerDeviceRemapped GamepadRemapped
ControllerTouchpadDown GamepadTouchpadDown
ControllerTouchpadMotion GamepadTouchpadMotion
ControllerTouchpadUp GamepadTouchpadUp
ControllerSensorUpdated GamepadSensorUpdated

Also renames is_controller() to is_gamepad() with a deprecated alias for backward compatibility.

Breaking change: Event variant names changed from Controller* to Gamepad*. The deprecated is_controller() alias helps migration.

This PR depends on #322 and together they complete #319.

@revmischa
revmischa force-pushed the fix/joystick-id-newtype branch from 6e0465d to 54fa191 Compare May 4, 2026 00:03
@revmischa
revmischa force-pushed the fix/joystick-id-newtype branch from 54fa191 to 8065da9 Compare June 9, 2026 20:57
@revmischa
revmischa force-pushed the fix/gamepad-event-naming branch from 105bf2a to 50be367 Compare June 9, 2026 21:03
@revmischa
revmischa requested a review from Copilot June 9, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the Rust event API with SDL3’s “gamepad” terminology by renaming Controller* event types/variants to Gamepad*, and introduces is_gamepad() (with a deprecated is_controller() alias) to ease migration. It also includes the JoystickId newtype work (per dependency on #322) and updates call sites/examples accordingly.

Changes:

  • Rename EventType::Controller* and Event::Controller* variants to Gamepad* equivalents.
  • Rename Event::is_controller() to Event::is_gamepad() and keep is_controller() as a deprecated alias.
  • Convert joystick/gamepad which identifiers to use the JoystickId newtype and update subsystem bindings/examples.

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 Introduces JoystickId as a transparent newtype and updates joystick APIs to convert into SDL’s ID type.
src/sdl3/gamepad.rs Updates gamepad subsystem APIs to accept JoystickId and pass the underlying SDL ID via .into().
src/sdl3/event.rs Renames controller events/types to gamepad equivalents; adds is_gamepad() and deprecated is_controller() alias.
examples/sensors.rs Updates sensor event matching to Event::GamepadSensorUpdated.
examples/gamepad.rs Updates event matching arms to new Gamepad* event variants.
Comments suppressed due to low confidence (1)

src/sdl3/event.rs:821

  • These doc comments still refer to "controller" even though the variants were renamed to Gamepad*. Updating the wording keeps the public API docs consistent with the SDL3 gamepad terminology.
    GamepadAxisMotion {
        timestamp: u64,
        /// The controller's joystick `id`
        which: JoystickId,
        axis: Axis,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sdl3/event.rs
Comment thread src/sdl3/event.rs Outdated
Comment thread src/sdl3/event.rs
@revmischa
revmischa force-pushed the fix/joystick-id-newtype branch from 8065da9 to 3fcd4e2 Compare June 9, 2026 21:21
revmischa added 2 commits June 9, 2026 14:21
Converts JoystickId from a type alias to a proper newtype struct with
Debug, Display, and From trait implementations. This allows easier
construction via JoystickId::new(id) or .into(), and better debug
output.

Updates all joystick/gamepad events to use JoystickId for their `which`
field instead of raw u32. The From<u32> and From<JoystickId> for u32
impls make migration straightforward.

Breaking change: Event `which` fields now require JoystickId instead of
u32. Use `JoystickId::new(val)` or `val.into()` to construct, and
`.raw()` or `.into()` to get the raw u32 value.

Fixes #319
Renames event types and variants to match SDL3's gamepad terminology:
- ControllerAxisMotion → GamepadAxisMotion
- ControllerButtonDown → GamepadButtonDown
- ControllerButtonUp → GamepadButtonUp
- ControllerDeviceAdded → GamepadAdded
- ControllerDeviceRemoved → GamepadRemoved
- ControllerDeviceRemapped → GamepadRemapped
- ControllerTouchpadDown → GamepadTouchpadDown
- ControllerTouchpadMotion → GamepadTouchpadMotion
- ControllerTouchpadUp → GamepadTouchpadUp
- ControllerSensorUpdated → GamepadSensorUpdated

Also renames is_controller() to is_gamepad() with a deprecated alias
for backward compatibility.

Breaking change: Event variant names changed from Controller* to
Gamepad*. The deprecated is_controller() alias helps migration.

Part 2 of 2 for #319
@revmischa
revmischa force-pushed the fix/gamepad-event-naming branch from 50be367 to 8c6df42 Compare June 9, 2026 21:22
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