Skip to content

Commit

Permalink
fix(Unified Gamepad): implement top buttons and touchscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Feb 27, 2025
1 parent 18b9951 commit c086b75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
21 changes: 15 additions & 6 deletions src/drivers/unified_gamepad/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ pub enum InputCapability {
GamepadButtonRightStick = 0x13e,

/* Non-standard gamepad codes */
/// Dedicated button to open an on-screen keyboard
GamepadButtonKeyboard = 0x304,
/// Dedicated button to take screenshots
GamepadButtonScreenshot = 0x305,
/// Dedicated mute button, Sony DualSense Mute
GamepadButtonMute = 0x306,
/// Left back paddle button, Xbox P3, Steam Deck L4
GamepadButtonLeftPaddle1 = 0x307,
/// Left back paddle button, Xbox P4, Steam Deck L5
Expand All @@ -657,12 +663,10 @@ pub enum InputCapability {
/// Touch binary sensor for right stick
GamepadButtonRightStickTouch = 0x30e,

/// Dedicated button to open an on-screen keyboard
GamepadButtonKeyboard = 0x304,
/// Dedicated button to take screenshots
GamepadButtonScreenshot = 0x305,
/// Dedicated mute button, Sony DualSense Mute
GamepadButtonMute = 0x306,
/// Top left button next to the left trigger, Ayaneo LC
GamepadButtonLeftTop = 0x30f,
/// Top left button next to the left trigger, Ayaneo RC
GamepadButtonRightTop = 0x310,

/// Left analog stick
GamepadAxisLeftStick = 0x400,
Expand Down Expand Up @@ -704,4 +708,9 @@ pub enum InputCapability {
TouchpadCenterButton = 0x704,
/// Right touchpad button press
TouchpadRightButton = 0x705,

/// 'Main' Touchscreen touch motion
TouchscreenMotion = 0x710,
/// Top touchscreen motion for dualscreen touch devices
TouchscreenTopMotion = 0x711,
}
11 changes: 7 additions & 4 deletions src/input/target/unified_gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,15 @@ impl From<Capability> for InputCapability {
GamepadButton::DPadLeft => Self::GamepadButtonDpadLeft,
GamepadButton::DPadRight => Self::GamepadButtonDpadRight,
GamepadButton::LeftBumper => Self::GamepadButtonLeftBumper,
GamepadButton::LeftTop => Self::default(),
GamepadButton::LeftTop => Self::GamepadButtonLeftTop,
GamepadButton::LeftTrigger => Self::GamepadButtonLeftTrigger,
GamepadButton::LeftPaddle1 => Self::GamepadButtonLeftPaddle1,
GamepadButton::LeftPaddle2 => Self::GamepadButtonLeftPaddle2,
GamepadButton::LeftPaddle3 => Self::GamepadButtonLeftPaddle3,
GamepadButton::LeftStick => Self::GamepadButtonLeftStick,
GamepadButton::LeftStickTouch => Self::GamepadButtonLeftStickTouch,
GamepadButton::RightBumper => Self::GamepadButtonRightBumper,
GamepadButton::RightTop => Self::default(),
GamepadButton::RightTop => Self::GamepadButtonRightTop,
GamepadButton::RightTrigger => Self::GamepadButtonRightTrigger,
GamepadButton::RightPaddle1 => Self::GamepadButtonRightPaddle1,
GamepadButton::RightPaddle2 => Self::GamepadButtonRightPaddle2,
Expand Down Expand Up @@ -727,7 +727,10 @@ impl From<Capability> for InputCapability {
Touch::Button(_) => Self::TouchpadCenterButton,
},
},
Capability::Touchscreen(_) => Self::default(),
Capability::Touchscreen(touch) => match touch {
Touch::Motion => Self::TouchscreenMotion,
Touch::Button(_) => Self::default(),
},
}
}
}
Expand All @@ -750,7 +753,7 @@ impl From<Capability> for InputCapabilityInfo {
Gamepad::Gyro => Self::new(capability, ValueType::Int16Vector3),
},
Capability::Mouse(_) => Self::default(),
Capability::Keyboard(_) => Self::default(),
Capability::Keyboard(_) => Self::new(capability, ValueType::Touch),
Capability::Touchpad(touchpad) => match touchpad {
Touchpad::LeftPad(pad) => match pad {
Touch::Motion => Self::new(capability, ValueType::Touch),
Expand Down

0 comments on commit c086b75

Please sign in to comment.