diff --git a/rootfs/usr/lib/udev/hwdb.d/60-inputplumber-autostart.hwdb b/rootfs/usr/lib/udev/hwdb.d/60-inputplumber-autostart.hwdb index 0f47149b..6e44320a 100644 --- a/rootfs/usr/lib/udev/hwdb.d/60-inputplumber-autostart.hwdb +++ b/rootfs/usr/lib/udev/hwdb.d/60-inputplumber-autostart.hwdb @@ -62,10 +62,14 @@ dmi:*svnGPD:pnG1618-03:* dmi:*svnGPD:pnG1618-04:* # GPD Win 5 dmi:*svnGPD:pnG1618-05:* +# GPD Win Max +dmi:*svnGPD:pnG1619-01:* # GPD Win Max 2 dmi:*svnGPD:pnG1619-04:* +dmi:*svnGPD:pnG1619-05:* # GPD Win Mini dmi:*svnGPD:pnG1617-01:* +dmi:*svnGPD:pnG1617-02:* # KONKR Fit dmi:*svnKONKR:pnKONKRFIT:* # Lenovo Legion Go diff --git a/rootfs/usr/share/inputplumber/capability_maps/gpd_type2.yaml b/rootfs/usr/share/inputplumber/capability_maps/gpd_type2.yaml index 0bfceea8..52d225cd 100644 --- a/rootfs/usr/share/inputplumber/capability_maps/gpd_type2.yaml +++ b/rootfs/usr/share/inputplumber/capability_maps/gpd_type2.yaml @@ -15,16 +15,46 @@ id: gpd2 mapping: - name: Left Paddle source_events: - - keyboard: Key0 + - keyboard: KeyLeftCtrl + - keyboard: KeyLeftShift + - keyboard: KeyF14 target_event: gamepad: button: LeftPaddle1 - name: Right Paddle source_events: - - keyboard: Key9 + - keyboard: KeyF3 + - keyboard: KeyF15 target_event: gamepad: button: RightPaddle1 + - name: Home + source_events: + - keyboard: KeyLeftMeta + - keyboard: KeyD + target_event: + gamepad: + button: Guide + - name: Home (Long Press) + source_events: + - keyboard: KeyTab + target_event: + gamepad: + button: Guide + - name: Menu + source_events: + - keyboard: KeyLeftCtrl + - keyboard: KeyLeftMeta + - keyboard: KeyO + target_event: + gamepad: + button: QuickAccess + - name: Keyboard (Long Press) + source_events: + - keyboard: KeyDelete + target_event: + gamepad: + button: QuickAccess2 # List of events to filter from the source devices filtered_events: [] diff --git a/rootfs/usr/share/inputplumber/capability_maps/gpd_type3.yaml b/rootfs/usr/share/inputplumber/capability_maps/gpd_type3.yaml deleted file mode 100644 index 3fde9148..00000000 --- a/rootfs/usr/share/inputplumber/capability_maps/gpd_type3.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/capability_map_v1.json -# Schema version number -version: 1 - -# The type of configuration schema -kind: CapabilityMap - -# Name for the device event map -name: GPD Type 3 - -# Unique identifier of the capability mapping -id: gpd3 - -# List of mapped events that are activated by a specific set of activation keys. -mapping: - - name: Quick Access - source_events: - - gamepad: - button: RightPaddle1 - target_event: - gamepad: - button: QuickAccess - -# List of events to filter from the source devices -filtered_events: [] diff --git a/rootfs/usr/share/inputplumber/capability_maps/gpd_type4.yaml b/rootfs/usr/share/inputplumber/capability_maps/gpd_type4.yaml deleted file mode 100644 index 89694dd8..00000000 --- a/rootfs/usr/share/inputplumber/capability_maps/gpd_type4.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/capability_map_v1.json -# Schema version number -version: 1 - -# The type of configuration schema -kind: CapabilityMap - -# Name for the device event map -name: GPD Type 4 - -# Unique identifier of the capability mapping -id: gpd4 - -# List of mapped events that are activated by a specific set of activation keys. -mapping: - - name: Left Paddle - source_events: - - keyboard: KeyF14 - target_event: - gamepad: - button: LeftPaddle1 - - name: Right Paddle - source_events: - - keyboard: KeyF15 - target_event: - gamepad: - button: RightPaddle1 - - name: Mode Switch - source_events: - - keyboard: KeyF13 - target_event: - gamepad: - button: QuickAccess - - name: Home - source_events: - - keyboard: KeyLeftMeta - - keyboard: KeyD - target_event: - gamepad: - button: Guide - - name: Home (Long Press) - source_events: - - keyboard: KeyTab - target_event: - gamepad: - button: Guide - - name: Keyboard - source_events: - - keyboard: KeyLeftMeta - - keyboard: KeyLeftCtrl - - keyboard: KeyO - target_event: - gamepad: - button: Keyboard - - name: Keyboard (Long Press) - source_events: - - keyboard: KeyDelete - target_event: - gamepad: - button: QuickAccess - -# List of events to filter from the source devices -filtered_events: [] diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2022.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2022.yaml new file mode 100644 index 00000000..0c691126 --- /dev/null +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2022.yaml @@ -0,0 +1,62 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json +# Schema version number +version: 1 + +# The type of configuration schema +kind: CompositeDevice + +# Name of the composite device mapping +name: GPD Win4 2022 + +# Only allow a single source device per composite device of this type. +single_source: false + +# Only use this profile if *any* of the given matches matches. If this list is +# empty, then the source devices will *always* be checked. +# /sys/class/dmi/id/product_name +matches: + - dmi_data: + product_name: G1618-04 + sys_vendor: GPD + cpu_model: AMD Ryzen 7 6800U + +# One or more source devices to combine into a single virtual device. The events +# from these devices will be watched and translated according to the key map. +source_devices: + # Back paddles + - group: keyboard + hidraw: + vendor_id: 0x2f24 + product_id: 0x0135 + interface_num: 1 + - group: gamepad + evdev: + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:73:00.3-4.1/input0 + handler: event* + - group: keyboard + blocked: true + evdev: + name: " Mouse for Windows" + handler: event* + phys_path: usb-0000:73:00.3-4.2/input1 + - group: imu + iio: + name: "{i2c-BMI0160:00,bmi260}" + mount_matrix: + x: [-1, 0, 0] + y: [0, 0, 1] + z: [0, -1, 0] + +# Optional configuration for the composite device +options: + # If true, InputPlumber will automatically try to manage the input device. If + # this is false, InputPlumber will not try to manage the device unless an + # external service enables management of the device. Defaults to 'false' + auto_manage: true + +# The target input device(s) to emulate by default +target_devices: + - xbox-elite + - mouse + - keyboard diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2023.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2023.yaml new file mode 100644 index 00000000..207845c3 --- /dev/null +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2023.yaml @@ -0,0 +1,66 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json +# Schema version number +version: 1 + +# The type of configuration schema +kind: CompositeDevice + +# Name of the composite device mapping +name: GPD Win4 2023 + +# Only allow a single source device per composite device of this type. +single_source: false + +# Only use this profile if *any* of the given matches matches. If this list is +# empty, then the source devices will *always* be checked. +# /sys/class/dmi/id/product_name +matches: + - dmi_data: + product_name: G1618-04 + sys_vendor: GPD + cpu_model: AMD Ryzen 7 7840U + - dmi_data: + product_name: G1618-04 + sys_vendor: GPD + cpu_model: AMD Ryzen 5 7640U + +# One or more source devices to combine into a single virtual device. The events +# from these devices will be watched and translated according to the key map. +source_devices: + # Back paddles + - group: keyboard + hidraw: + vendor_id: 0x2f24 + product_id: 0x0135 + interface_num: 1 + - group: gamepad + evdev: + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:63:00.3-3.1/input0 + handler: event* + - group: keyboard + blocked: true + evdev: + name: " Mouse for Windows" + handler: event* + phys_path: usb-0000:63:00.3-3.2/input1 + - group: imu + iio: + name: "{i2c-BMI0160:00,bmi260}" + mount_matrix: + x: [0, 1, 0] + y: [1, 0, 0] + z: [0, 0, -1] + +# Optional configuration for the composite device +options: + # If true, InputPlumber will automatically try to manage the input device. If + # this is false, InputPlumber will not try to manage the device unless an + # external service enables management of the device. Defaults to 'false' + auto_manage: true + +# The target input device(s) to emulate by default +target_devices: + - xbox-elite + - mouse + - keyboard diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_win4.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2025.yaml similarity index 75% rename from rootfs/usr/share/inputplumber/devices/50-gpd_win4.yaml rename to rootfs/usr/share/inputplumber/devices/50-gpd_win4_2025.yaml index 93994267..5bc46d3e 100644 --- a/rootfs/usr/share/inputplumber/devices/50-gpd_win4.yaml +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_win4_2025.yaml @@ -6,7 +6,7 @@ version: 1 kind: CompositeDevice # Name of the composite device mapping -name: GPD Win4 +name: GPD Win4 2025 # Only allow a single source device per composite device of this type. single_source: false @@ -18,42 +18,31 @@ matches: - dmi_data: product_name: G1618-04 sys_vendor: GPD + cpu_model: AMD Ryzen AI 9 HX 370 # One or more source devices to combine into a single virtual device. The events # from these devices will be watched and translated according to the key map. source_devices: - # GPD Win4 2022 (6800U) - - group: gamepad - evdev: - name: "Microsoft X-Box 360 pad" - phys_path: usb-0000:73:00.3-4.1/input0 - handler: event* + # Back paddles - group: keyboard - evdev: - name: " Mouse for Windows" - handler: event* - phys_path: usb-0000:73:00.3-4.2/input1 - - group: imu - iio: - name: "{i2c-BMI0160:00,bmi260}" - mount_matrix: - x: [-1, 0, 0] - y: [0, -1, 0] - z: [0, 0, 1] - # GPD Win4 2025 (HX 370) + hidraw: + vendor_id: 0x2f24 + product_id: 0x0135 + interface_num: 1 - group: gamepad evdev: name: "Microsoft X-Box 360 pad" phys_path: usb-0000:66:00.0-2.1/input0 handler: event* - group: keyboard + blocked: true evdev: name: " Mouse for Windows" handler: event* phys_path: usb-0000:66:00.0-2.2/input1 - group: imu iio: - name: i2c-BMI0260:00 + name: "{i2c-BMI0160:00,bmi260}" mount_matrix: x: [-1, 0, 0] y: [0, -1, 0] @@ -71,6 +60,3 @@ target_devices: - xbox-elite - mouse - keyboard - -# The ID of a device event mapping in the 'event_maps' folder -capability_map_id: gpd3 diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_win5.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_win5.yaml index e5949af3..42642595 100644 --- a/rootfs/usr/share/inputplumber/devices/50-gpd_win5.yaml +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_win5.yaml @@ -28,21 +28,37 @@ source_devices: phys_path: usb-0000:66:00.0-5.1/input0 handler: event* capability_map_id: gpd_menu - - group: keyboard - evdev: - name: " Mouse for Windows" - handler: event* - phys_path: usb-0000:66:00.0-5.2/input0 - group: keyboard evdev: name: " Keyboard for Windows" handler: event* phys_path: usb-0000:66:00.0-5.3/input0 + events: + exclude: + - "*" + include: + - Keyboard:KeyF14 + - Keyboard:KeyF15 + - Keyboard:KeyF3 + - Keyboard:KeyLeftCtrl + - Keyboard:KeyLeftShift - group: keyboard evdev: name: AT Translated Set 2 keyboard phys_path: isa0060/serio0/input0 handler: event* + events: + exclude: + - "*" + include: + - Keyboard:KeyD + - Keyboard:KeyDelete + - Keyboard:KeyLeftCtrl + - Keyboard:KeyLeftMeta + - Keyboard:KeyO + - Keyboard:KeyTab + - Keyboard:KeyVolumeDown + - Keyboard:KeyVolumeUp - group: imu iio: name: "{i2c-BMI0160:00,bmi260}" @@ -65,4 +81,4 @@ target_devices: - keyboard # The ID of a device event mapping in the 'event_maps' folder -capability_map_id: gpd4 +capability_map_id: gpd2 diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_winmax.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_winmax.yaml new file mode 100644 index 00000000..38b70b64 --- /dev/null +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_winmax.yaml @@ -0,0 +1,42 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json +# Schema version number +version: 1 + +# The type of configuration schema +kind: CompositeDevice + +# Name of the composite device mapping +name: GPD Win Max + +# Only allow a single source device per composite device of this type. +single_source: false + +# Only use this profile if *any* of the given matches matches. If this list is +# empty, then the source devices will *always* be checked. +# /sys/class/dmi/id/product_name +matches: + - dmi_data: + product_name: G1619-01 + sys_vendor: GPD + +# One or more source devices to combine into a single virtual device. The events +# from these devices will be watched and translated according to the key map. +source_devices: + - group: gamepad + evdev: + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:00:14.0-5/input0 + handler: event* + +# Optional configuration for the composite device +options: + # If true, InputPlumber will automatically try to manage the input device. If + # this is false, InputPlumber will not try to manage the device unless an + # external service enables management of the device. Defaults to 'false' + auto_manage: true + +# The target input device(s) to emulate by default +target_devices: + - xbox-elite + - mouse + - keyboard diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_winmax2.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_winmax2.yaml index 87a48ad1..4fd19096 100644 --- a/rootfs/usr/share/inputplumber/devices/50-gpd_winmax2.yaml +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_winmax2.yaml @@ -6,7 +6,7 @@ version: 1 kind: CompositeDevice # Name of the composite device mapping -name: GPD WinMax2 +name: GPD Win Max 2 # Only allow a single source device per composite device of this type. single_source: false @@ -18,49 +18,64 @@ matches: - dmi_data: product_name: G1619-04 sys_vendor: GPD + - dmi_data: + product_name: G1619-05 + sys_vendor: GPD # One or more source devices to combine into a single virtual device. The events # from these devices will be watched and translated according to the key map. source_devices: + # Back paddles + - group: keyboard + hidraw: + vendor_id: 0x2f24 + product_id: 0x0135 + interface_num: 1 + # Older models, TODO: Look up specific years for each - group: gamepad evdev: name: "Microsoft X-Box 360 pad" phys_path: usb-0000:74:00.3-3/input0 handler: event* - - group: gamepad + - group: keyboard + blocked: true evdev: - name: "Microsoft X-Box 360 pad" - phys_path: usb-0000:65:00.3-3/input0 + name: " Mouse for Windows" + phys_path: usb-0000:74:00.3-4/input1 handler: event* - group: gamepad evdev: name: "Microsoft X-Box 360 pad" - phys_path: usb-0000:73:00.3-3/input0 + phys_path: usb-0000:65:00.3-3/input0 handler: event* - group: keyboard + blocked: true evdev: name: " Mouse for Windows" - phys_path: usb-0000:74:00.3-4/input1 + phys_path: usb-0000:65:00.3-4/input1 handler: event* - - group: keyboard + - group: gamepad evdev: - name: " Mouse for Windows" - phys_path: usb-0000:65:00.3-4/input0 + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:73:00.3-3/input0 handler: event* - group: keyboard + blocked: true evdev: name: " Mouse for Windows" - phys_path: usb-0000:65:00.3-4/input1 + phys_path: usb-0000:73:00.3-4/input1 handler: event* - - group: keyboard + # Win Max 2 (2025) + - group: gamepad evdev: - name: " Mouse for Windows" - phys_path: usb-0000:73:00.3-4/input0 + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:c7:00.0-3/input0 handler: event* - group: keyboard + blocked: true evdev: name: " Mouse for Windows" - phys_path: usb-0000:73:00.3-4/input1 + phys_path: usb-0000:c7:00.0-4/input1 handler: event* - group: imu iio: @@ -78,6 +93,3 @@ target_devices: - xbox-elite - mouse - keyboard - -# The ID of a device event mapping in the 'event_maps' folder -capability_map_id: gpd2 diff --git a/rootfs/usr/share/inputplumber/devices/50-gpd_winmini.yaml b/rootfs/usr/share/inputplumber/devices/50-gpd_winmini.yaml index 2fc42d62..3dffbda0 100644 --- a/rootfs/usr/share/inputplumber/devices/50-gpd_winmini.yaml +++ b/rootfs/usr/share/inputplumber/devices/50-gpd_winmini.yaml @@ -18,37 +18,56 @@ matches: - dmi_data: product_name: G1617-01 sys_vendor: GPD + - dmi_data: + product_name: G1617-02 + sys_vendor: GPD # One or more source devices to combine into a single virtual device. The events # from these devices will be watched and translated according to the key map. source_devices: + # Win Mini (2023) - group: gamepad evdev: name: "Microsoft X-Box 360 pad" phys_path: "{usb-0000:63:00.3-5/input0,usb-0000:c3:00.3-5/input0}" handler: event* - - group: keyboard - hidraw: - vendor_id: 0x2f24 - product_id: 0x0135 - interface_num: 1 - group: keyboard blocked: true evdev: name: " Mouse for Windows" phys_path: usb-0000:63:00.3-3/input1 handler: event* - - group: mouse - hidraw: - vendor_id: 0x093A - product_id: 0x0255 - interface_num: 0 + # Win Mini (2025) + - group: gamepad + evdev: + name: "Microsoft X-Box 360 pad" + phys_path: usb-0000:c6:00.0-3.1/input0 + handler: event* + - group: keyboard + blocked: true + evdev: + name: " Keyboard for Windows" + phys_path: usb-0000:c6:00.0-3.3/input0 + handler: event* + # All devices - group: mouse unique: false blocked: true evdev: - name: "{HTIX5288:00 093A:0255 Mouse,HTIX5288:00 093A:0255 Touchpad}" + name: "{HTIX5288:00*}" handler: event* + # Back Paddles + - group: keyboard + hidraw: + vendor_id: 0x2f24 + product_id: 0x0135 + interface_num: 1 + # Touchpad + - group: mouse + hidraw: + vendor_id: 0x093A + product_id: 0x0255 + interface_num: 0 - group: imu iio: name: "{i2c-BMI0160:00,bmi260}" @@ -70,6 +89,3 @@ target_devices: - mouse - keyboard - touchpad - -# The ID of a device event mapping in the 'event_maps' folder -capability_map_id: gpd3 diff --git a/rootfs/usr/share/inputplumber/schema/composite_device_v1.json b/rootfs/usr/share/inputplumber/schema/composite_device_v1.json index e601c27f..c62fc6d6 100644 --- a/rootfs/usr/share/inputplumber/schema/composite_device_v1.json +++ b/rootfs/usr/share/inputplumber/schema/composite_device_v1.json @@ -150,6 +150,10 @@ "description": "System vendor to match found at /sys/class/dmi/id/sys_vendor", "type": "string" }, + "cpu_model": { + "description": "CPU model to match from 'lscpu'", + "type": "string" + }, "cpu_vendor": { "description": "CPU vendor to match from 'lscpu'", "type": "string" diff --git a/src/config/mod.rs b/src/config/mod.rs index f62a9eb5..714d1213 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -222,6 +222,8 @@ pub struct DMIMatch { #[serde(skip_serializing_if = "Option::is_none")] pub sys_vendor: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub cpu_model: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub cpu_vendor: Option, } @@ -1055,6 +1057,15 @@ impl CompositeDeviceConfig { } has_matches = true; } + if let Some(cpu_model) = dmi_config.cpu_model { + if !glob_match( + cpu_model.as_str(), + cpu_info.model_name(0).unwrap_or_default(), + ) { + continue; + } + has_matches = true; + } if let Some(bios_release) = dmi_config.bios_release { if !glob_match(bios_release.as_str(), data.bios_release.as_str()) { diff --git a/src/drivers/gpd_win_mini/event.rs b/src/drivers/gpd_device/event.rs similarity index 100% rename from src/drivers/gpd_win_mini/event.rs rename to src/drivers/gpd_device/event.rs diff --git a/src/drivers/gpd_win_mini/hid_report.rs b/src/drivers/gpd_device/hid_report.rs similarity index 100% rename from src/drivers/gpd_win_mini/hid_report.rs rename to src/drivers/gpd_device/hid_report.rs diff --git a/src/drivers/gpd_win_mini/macro_keyboard_driver.rs b/src/drivers/gpd_device/macro_keyboard_driver.rs similarity index 100% rename from src/drivers/gpd_win_mini/macro_keyboard_driver.rs rename to src/drivers/gpd_device/macro_keyboard_driver.rs diff --git a/src/drivers/gpd_win_mini/mod.rs b/src/drivers/gpd_device/mod.rs similarity index 100% rename from src/drivers/gpd_win_mini/mod.rs rename to src/drivers/gpd_device/mod.rs diff --git a/src/drivers/gpd_win_mini/touchpad_driver.rs b/src/drivers/gpd_device/touchpad_driver.rs similarity index 100% rename from src/drivers/gpd_win_mini/touchpad_driver.rs rename to src/drivers/gpd_device/touchpad_driver.rs diff --git a/src/drivers/mod.rs b/src/drivers/mod.rs index 7a8477ec..adef2133 100644 --- a/src/drivers/mod.rs +++ b/src/drivers/mod.rs @@ -1,7 +1,7 @@ pub mod dualsense; pub mod flydigi_vader_4_pro; pub mod fts3528; -pub mod gpd_win_mini; +pub mod gpd_device; pub mod horipad_steam; pub mod iio_imu; pub mod lego; diff --git a/src/input/source/hidraw.rs b/src/input/source/hidraw.rs index 92a7b003..d40e770c 100644 --- a/src/input/source/hidraw.rs +++ b/src/input/source/hidraw.rs @@ -2,8 +2,8 @@ pub mod blocked; pub mod dualsense; pub mod flydigi_vader_4_pro; pub mod fts3528; -pub mod gpd_win_mini_macro_keyboard; -pub mod gpd_win_mini_touchpad; +pub mod gpd_macro_keyboard; +pub mod gpd_touchpad; pub mod horipad_steam; pub mod legion_go; pub mod legion_go2; @@ -34,9 +34,8 @@ use crate::{ use self::{ blocked::BlockedHidrawDevice, dualsense::DualSenseController, flydigi_vader_4_pro::Vader4Pro, - fts3528::Fts3528Touchscreen, gpd_win_mini_macro_keyboard::GpdWinMiniMacroKeyboard, - gpd_win_mini_touchpad::GpdWinMiniTouchpad, horipad_steam::HoripadSteam, - legion_go::LegionGoController, legion_go2::LegionGo2Controller, + fts3528::Fts3528Touchscreen, gpd_macro_keyboard::GpdMacroKeyboard, gpd_touchpad::GpdTouchpad, + horipad_steam::HoripadSteam, legion_go::LegionGoController, legion_go2::LegionGo2Controller, legos_imu::LegionSImuController, legos_touchpad::LegionSTouchpadController, legos_xinput::LegionSXInputController, opineo::OrangePiNeoTouchpad, oxp_hid::OxpHid, rog_ally::RogAlly, steam_deck::DeckController, xpad_uhid::XpadUhid, zotac_zone::ZotacZone, @@ -48,8 +47,8 @@ enum DriverType { Blocked, DualSense, Fts3528Touchscreen, - GpdWinMiniMacroKeyboard, - GpdWinMiniTouchpad, + GpdMacroKeyboard, + GpdTouchpad, HoripadSteam, LegionGo, LegionGo2, @@ -73,8 +72,8 @@ pub enum HidRawDevice { Blocked(SourceDriver), DualSense(SourceDriver), Fts3528Touchscreen(SourceDriver), - GpdWinMiniMacroKeyboard(SourceDriver), - GpdWinMiniTouchpad(SourceDriver), + GpdWinMiniMacroKeyboard(SourceDriver), + GpdWinMiniTouchpad(SourceDriver), HoripadSteam(SourceDriver), LegionGo(SourceDriver), LegionGo2(SourceDriver), @@ -456,14 +455,14 @@ impl HidRawDevice { ); Ok(Self::ZotacZone(source_device)) } - DriverType::GpdWinMiniTouchpad => { - let device = GpdWinMiniTouchpad::new(device_info.clone())?; + DriverType::GpdTouchpad => { + let device = GpdTouchpad::new(device_info.clone())?; let source_device = SourceDriver::new(composite_device, device, device_info.into(), conf); Ok(Self::GpdWinMiniTouchpad(source_device)) } - DriverType::GpdWinMiniMacroKeyboard => { - let device = GpdWinMiniMacroKeyboard::new(device_info.clone())?; + DriverType::GpdMacroKeyboard => { + let device = GpdMacroKeyboard::new(device_info.clone())?; let source_device = SourceDriver::new(composite_device, device, device_info.into(), conf); Ok(Self::GpdWinMiniMacroKeyboard(source_device)) @@ -616,20 +615,20 @@ impl HidRawDevice { } // GPD Win Mini - if vid == drivers::gpd_win_mini::touchpad_driver::VID - && pid == drivers::gpd_win_mini::touchpad_driver::PID - && iid == drivers::gpd_win_mini::touchpad_driver::IID + if vid == drivers::gpd_device::touchpad_driver::VID + && pid == drivers::gpd_device::touchpad_driver::PID + && iid == drivers::gpd_device::touchpad_driver::IID { log::info!("Detected GPD Win Mini Touchpad"); - return DriverType::GpdWinMiniTouchpad; + return DriverType::GpdTouchpad; } - if vid == drivers::gpd_win_mini::macro_keyboard_driver::VID - && pid == drivers::gpd_win_mini::macro_keyboard_driver::PID - && iid == drivers::gpd_win_mini::macro_keyboard_driver::IID + if vid == drivers::gpd_device::macro_keyboard_driver::VID + && pid == drivers::gpd_device::macro_keyboard_driver::PID + && iid == drivers::gpd_device::macro_keyboard_driver::IID { log::info!("Detected GPD Win Mini Macro keyboard"); - return DriverType::GpdWinMiniMacroKeyboard; + return DriverType::GpdMacroKeyboard; } if vid == drivers::ultimate_2::VID && pid == drivers::ultimate_2::PID { diff --git a/src/input/source/hidraw/gpd_win_mini_macro_keyboard.rs b/src/input/source/hidraw/gpd_macro_keyboard.rs similarity index 69% rename from src/input/source/hidraw/gpd_win_mini_macro_keyboard.rs rename to src/input/source/hidraw/gpd_macro_keyboard.rs index 16c26dfd..2867506c 100644 --- a/src/input/source/hidraw/gpd_win_mini_macro_keyboard.rs +++ b/src/input/source/hidraw/gpd_macro_keyboard.rs @@ -1,30 +1,28 @@ use std::{error::Error, fmt::Debug}; use crate::{ - drivers::gpd_win_mini::{ - event, macro_keyboard_driver::MacroKeyboardDriver - }, + drivers::gpd_device::{event, macro_keyboard_driver::MacroKeyboardDriver}, input::{ capability::{Capability, Gamepad, GamepadButton}, event::{native::NativeEvent, value::InputValue}, - source::{InputError, SourceInputDevice, SourceOutputDevice} + source::{InputError, SourceInputDevice, SourceOutputDevice}, }, udev::device::UdevDevice, }; /// GPD Win Mini macro keyboard source device implementation -pub struct GpdWinMiniMacroKeyboard { +pub struct GpdMacroKeyboard { driver: MacroKeyboardDriver, } -impl GpdWinMiniMacroKeyboard { +impl GpdMacroKeyboard { pub fn new(device_info: UdevDevice) -> Result> { let driver = MacroKeyboardDriver::new(device_info)?; Ok(Self { driver }) } } -impl SourceInputDevice for GpdWinMiniMacroKeyboard { +impl SourceInputDevice for GpdMacroKeyboard { fn poll(&mut self) -> Result, InputError> { let events = self.driver.poll()?; let native_events = translate_events(events); @@ -36,9 +34,9 @@ impl SourceInputDevice for GpdWinMiniMacroKeyboard { } } -impl SourceOutputDevice for GpdWinMiniMacroKeyboard {} +impl SourceOutputDevice for GpdMacroKeyboard {} -impl Debug for GpdWinMiniMacroKeyboard { +impl Debug for GpdMacroKeyboard { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GpdWinMiniMacroKeyboard").finish() } @@ -57,18 +55,14 @@ fn translate_events(events: Vec) -> Vec { fn translate_event(event: event::Event) -> NativeEvent { match event { event::Event::GamepadButton(button) => match button { - event::GamepadButtonEvent::L4(value) => { - NativeEvent::new( - Capability::Gamepad(Gamepad::Button(GamepadButton::LeftPaddle1)), - InputValue::Bool(value.pressed) - ) - }, - event::GamepadButtonEvent::R4(value) => { - NativeEvent::new( - Capability::Gamepad(Gamepad::Button(GamepadButton::RightPaddle1)), - InputValue::Bool(value.pressed) - ) - }, + event::GamepadButtonEvent::L4(value) => NativeEvent::new( + Capability::Gamepad(Gamepad::Button(GamepadButton::LeftPaddle1)), + InputValue::Bool(value.pressed), + ), + event::GamepadButtonEvent::R4(value) => NativeEvent::new( + Capability::Gamepad(Gamepad::Button(GamepadButton::RightPaddle1)), + InputValue::Bool(value.pressed), + ), }, _ => NativeEvent::new(Capability::NotImplemented, InputValue::None), } diff --git a/src/input/source/hidraw/gpd_win_mini_touchpad.rs b/src/input/source/hidraw/gpd_touchpad.rs similarity index 69% rename from src/input/source/hidraw/gpd_win_mini_touchpad.rs rename to src/input/source/hidraw/gpd_touchpad.rs index f65876f6..5910e7da 100644 --- a/src/input/source/hidraw/gpd_win_mini_touchpad.rs +++ b/src/input/source/hidraw/gpd_touchpad.rs @@ -1,30 +1,34 @@ use std::{error::Error, fmt::Debug}; use crate::{ - drivers::gpd_win_mini::{ - event, touchpad_driver::{self, TouchpadDriver} + drivers::gpd_device::{ + event, + touchpad_driver::{self, TouchpadDriver}, }, input::{ capability::{Capability, Gamepad, GamepadTrigger, Touch, TouchButton, Touchpad}, - event::{native::NativeEvent, value::{InputValue, normalize_unsigned_value}}, - source::{InputError, SourceInputDevice, SourceOutputDevice} + event::{ + native::NativeEvent, + value::{normalize_unsigned_value, InputValue}, + }, + source::{InputError, SourceInputDevice, SourceOutputDevice}, }, udev::device::UdevDevice, }; /// GPD Win Mini source device implementation -pub struct GpdWinMiniTouchpad { +pub struct GpdTouchpad { driver: TouchpadDriver, } -impl GpdWinMiniTouchpad { +impl GpdTouchpad { pub fn new(device_info: UdevDevice) -> Result> { let driver = TouchpadDriver::new(device_info)?; Ok(Self { driver }) } } -impl SourceInputDevice for GpdWinMiniTouchpad { +impl SourceInputDevice for GpdTouchpad { fn poll(&mut self) -> Result, InputError> { let events = self.driver.poll()?; let native_events = translate_events(events); @@ -36,9 +40,9 @@ impl SourceInputDevice for GpdWinMiniTouchpad { } } -impl SourceOutputDevice for GpdWinMiniTouchpad {} +impl SourceOutputDevice for GpdTouchpad {} -impl Debug for GpdWinMiniTouchpad { +impl Debug for GpdTouchpad { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GpdWinMiniTouchpad").finish() } @@ -77,12 +81,10 @@ fn normalize_axis_value(event: event::TouchAxisEvent) -> InputValue { /// maximum axis ranges. fn normalize_trigger_value(event: event::TriggerEvent) -> InputValue { match event { - event::TriggerEvent::PadForce(value) => { - InputValue::Float(normalize_unsigned_value( - value.value as f64, - touchpad_driver::PAD_FORCE_MAX - )) - } + event::TriggerEvent::PadForce(value) => InputValue::Float(normalize_unsigned_value( + value.value as f64, + touchpad_driver::PAD_FORCE_MAX, + )), } } @@ -98,27 +100,21 @@ fn translate_events(events: Vec) -> Vec { /// Translate the given touchpad event into a native event fn translate_event(event: event::Event) -> NativeEvent { match event { - event::Event::TouchAxis(axis) => { - NativeEvent::new( - Capability::Touchpad(Touchpad::RightPad(Touch::Motion)), - normalize_axis_value(axis) - ) - }, + event::Event::TouchAxis(axis) => NativeEvent::new( + Capability::Touchpad(Touchpad::RightPad(Touch::Motion)), + normalize_axis_value(axis), + ), event::Event::TouchButton(button) => match button { - event::TouchButtonEvent::Left(value) => { - NativeEvent::new( - Capability::Touchpad(Touchpad::RightPad(Touch::Button(TouchButton::Press))), - InputValue::Bool(value.pressed), - ) - }, + event::TouchButtonEvent::Left(value) => NativeEvent::new( + Capability::Touchpad(Touchpad::RightPad(Touch::Button(TouchButton::Press))), + InputValue::Bool(value.pressed), + ), }, event::Event::Trigger(trigg) => match trigg.clone() { - event::TriggerEvent::PadForce(_) => { - NativeEvent::new( - Capability::Gamepad(Gamepad::Trigger(GamepadTrigger::RightTouchpadForce)), - normalize_trigger_value(trigg), - ) - }, + event::TriggerEvent::PadForce(_) => NativeEvent::new( + Capability::Gamepad(Gamepad::Trigger(GamepadTrigger::RightTouchpadForce)), + normalize_trigger_value(trigg), + ), }, _ => NativeEvent::new(Capability::NotImplemented, InputValue::None), }