From c086b753857d2ddd2779922fcb4445613f753b9e Mon Sep 17 00:00:00 2001 From: William Edwards Date: Thu, 27 Feb 2025 10:54:56 -0800 Subject: [PATCH] fix(Unified Gamepad): implement top buttons and touchscreen --- src/drivers/unified_gamepad/capability.rs | 21 +++++++++++++++------ src/input/target/unified_gamepad.rs | 11 +++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/drivers/unified_gamepad/capability.rs b/src/drivers/unified_gamepad/capability.rs index bce8666..5abb020 100644 --- a/src/drivers/unified_gamepad/capability.rs +++ b/src/drivers/unified_gamepad/capability.rs @@ -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 @@ -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, @@ -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, } diff --git a/src/input/target/unified_gamepad.rs b/src/input/target/unified_gamepad.rs index 4bf309f..3aae8f1 100644 --- a/src/input/target/unified_gamepad.rs +++ b/src/input/target/unified_gamepad.rs @@ -676,7 +676,7 @@ impl From 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, @@ -684,7 +684,7 @@ impl From for InputCapability { 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, @@ -727,7 +727,10 @@ impl From for InputCapability { Touch::Button(_) => Self::TouchpadCenterButton, }, }, - Capability::Touchscreen(_) => Self::default(), + Capability::Touchscreen(touch) => match touch { + Touch::Motion => Self::TouchscreenMotion, + Touch::Button(_) => Self::default(), + }, } } } @@ -750,7 +753,7 @@ impl From 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),