From 08635f8839f44672e5512a5d898e715b8b84832c Mon Sep 17 00:00:00 2001 From: William Edwards Date: Thu, 27 Feb 2025 22:58:08 -0800 Subject: [PATCH] fix(Unified Gamepad): add extra value types --- src/cli/ui/menu/device_test_menu.rs | 20 +++ src/drivers/unified_gamepad/reports.rs | 116 +++++++++++++++--- .../reports/input_capability_report.rs | 20 +++ 3 files changed, 140 insertions(+), 16 deletions(-) diff --git a/src/cli/ui/menu/device_test_menu.rs b/src/cli/ui/menu/device_test_menu.rs index 5bdf2aa..a50442f 100644 --- a/src/cli/ui/menu/device_test_menu.rs +++ b/src/cli/ui/menu/device_test_menu.rs @@ -436,6 +436,13 @@ impl MenuWidget for DeviceTestMenu { let trigger = TriggerGauge::new(cap.capability, label.as_str()); self.ui_triggers.push(trigger); } + ValueType::UInt32 => (), + ValueType::UInt64 => (), + ValueType::Int8 => (), + ValueType::Int16 => (), + ValueType::Int32 => (), + ValueType::Int64 => (), + ValueType::UInt8Vector2 => (), ValueType::UInt16Vector2 => match cap.capability { InputCapability::GamepadAxisLeftStick | InputCapability::GamepadAxisRightStick => { @@ -450,11 +457,24 @@ impl MenuWidget for DeviceTestMenu { self.ui_touch.push(gauge); } }, + ValueType::UInt32Vector2 => (), + ValueType::UInt64Vector2 => (), + ValueType::Int8Vector2 => (), + ValueType::Int16Vector2 => (), + ValueType::Int32Vector2 => (), + ValueType::Int64Vector2 => (), + ValueType::UInt8Vector3 => (), + ValueType::UInt16Vector3 => (), + ValueType::UInt32Vector3 => (), + ValueType::UInt64Vector3 => (), + ValueType::Int8Vector3 => (), ValueType::Int16Vector3 => { let label = format!("{:?}", cap.capability); let gauge = GyroGauge::new(cap.capability, label.as_str()); self.ui_gyro.push(gauge); } + ValueType::Int32Vector3 => (), + ValueType::Int64Vector3 => (), ValueType::Touch => { let label = format!("{:?}", cap.capability); let gauge = TouchGauge::new(cap.capability, label.as_str()); diff --git a/src/drivers/unified_gamepad/reports.rs b/src/drivers/unified_gamepad/reports.rs index 62f0598..16a57dd 100644 --- a/src/drivers/unified_gamepad/reports.rs +++ b/src/drivers/unified_gamepad/reports.rs @@ -98,19 +98,63 @@ pub enum FeatureReportType { #[derive(PrimitiveEnum_u8, Clone, Copy, PartialEq, Debug, Default, Ord, PartialOrd, Eq)] pub enum ValueType { #[default] - None, + None = 0x00, /// Bool values take up 1 bit in the input report - Bool, + Bool = 0x01, + /// Uint8 values take up 1 byte in the input report - UInt8, + UInt8 = 0x02, /// Uint16 values take up 2 bytes in the input report - UInt16, - /// UInt16Vector2 vales take up 4 bytes in the input report - UInt16Vector2, - /// Int16Vector3 vales take up 6 bytes in the input report - Int16Vector3, + UInt16 = 0x03, + /// Uint32 values take up 4 bytes in the input report + UInt32 = 0x04, + /// Uint64 values take up 8 bytes in the input report + UInt64 = 0x05, + /// Int8 values take up 1 byte in the input report + Int8 = 0x06, + /// Int16 values take up 2 bytes in the input report + Int16 = 0x07, + /// Int32 values take up 4 bytes in the input report + Int32 = 0x08, + /// Int64 values take up 8 bytes in the input report + Int64 = 0x09, + + /// UInt8Vector2 values take up 2 bytes in the input report + UInt8Vector2 = 0x12, + /// UInt16Vector2 values take up 4 bytes in the input report + UInt16Vector2 = 0x13, + /// UInt32Vector2 values take up 8 bytes in the input report + UInt32Vector2 = 0x14, + /// UInt64Vector2 values take up 16 bytes in the input report + UInt64Vector2 = 0x15, + /// Int8Vector2 values take up 2 bytes in the input report + Int8Vector2 = 0x16, + /// Int16Vector2 values take up 4 bytes in the input report + Int16Vector2 = 0x17, + /// Int32Vector2 values take up 8 bytes in the input report + Int32Vector2 = 0x18, + /// Int64Vector2 values take up 16 bytes in the input report + Int64Vector2 = 0x19, + + /// UInt8Vector3 values take up 3 bytes in the input report + UInt8Vector3 = 0x22, + /// UInt16Vector3 values take up 6 bytes in the input report + UInt16Vector3 = 0x23, + /// UInt32Vector3 values take up 12 bytes in the input report + UInt32Vector3 = 0x24, + /// UInt64Vector3 values take up 24 bytes in the input report + UInt64Vector3 = 0x25, + /// Int8Vector3 values take up 3 bytes in the input report + Int8Vector3 = 0x26, + /// Int16Vector3 values take up 6 bytes in the input report + Int16Vector3 = 0x27, + /// Int32Vector3 values take up 12 bytes in the input report + Int32Vector3 = 0x28, + /// Int64Vector3 values take up 24 bytes in the input report + Int64Vector3 = 0x29, + /// Touch values takes up 6 bytes in the input report - Touch, + Touch = 0x30, } impl ValueType { @@ -121,8 +165,28 @@ impl ValueType { ValueType::Bool => BoolValue::packed_bits(), ValueType::UInt8 => UInt8Value::packed_bits(), ValueType::UInt16 => UInt16Value::packed_bits(), + ValueType::UInt32 => todo!(), + ValueType::UInt64 => todo!(), + ValueType::Int8 => todo!(), + ValueType::Int16 => todo!(), + ValueType::Int32 => todo!(), + ValueType::Int64 => todo!(), + ValueType::UInt8Vector2 => todo!(), ValueType::UInt16Vector2 => UInt16Vector2Value::packed_bits(), + ValueType::UInt32Vector2 => todo!(), + ValueType::UInt64Vector2 => todo!(), + ValueType::Int8Vector2 => todo!(), + ValueType::Int16Vector2 => todo!(), + ValueType::Int32Vector2 => todo!(), + ValueType::Int64Vector2 => todo!(), + ValueType::UInt8Vector3 => todo!(), + ValueType::UInt16Vector3 => todo!(), + ValueType::UInt32Vector3 => todo!(), + ValueType::UInt64Vector3 => todo!(), + ValueType::Int8Vector3 => todo!(), ValueType::Int16Vector3 => Int16Vector3Value::packed_bits(), + ValueType::Int32Vector3 => todo!(), + ValueType::Int64Vector3 => todo!(), ValueType::Touch => TouchValue::packed_bits(), } } @@ -142,13 +206,33 @@ impl ValueType { /// be ordered first. pub fn order_priority(&self) -> u8 { match self { - ValueType::None => 6, - ValueType::Bool => 5, - ValueType::UInt8 => 4, - ValueType::UInt16 => 3, - ValueType::UInt16Vector2 => 2, - ValueType::Int16Vector3 => 1, - ValueType::Touch => 0, + ValueType::None => 100, + ValueType::Bool => 99, + ValueType::UInt8 => 98, + ValueType::UInt16 => 97, + ValueType::UInt32 => 96, + ValueType::UInt64 => 95, + ValueType::Int8 => 94, + ValueType::Int16 => 93, + ValueType::Int32 => 92, + ValueType::Int64 => 91, + ValueType::UInt8Vector2 => 90, + ValueType::UInt16Vector2 => 89, + ValueType::UInt32Vector2 => 88, + ValueType::UInt64Vector2 => 87, + ValueType::Int8Vector2 => 86, + ValueType::Int16Vector2 => 85, + ValueType::Int32Vector2 => 84, + ValueType::Int64Vector2 => 83, + ValueType::UInt8Vector3 => 82, + ValueType::UInt16Vector3 => 81, + ValueType::UInt32Vector3 => 80, + ValueType::UInt64Vector3 => 79, + ValueType::Int8Vector3 => 78, + ValueType::Int16Vector3 => 77, + ValueType::Int32Vector3 => 76, + ValueType::Int64Vector3 => 75, + ValueType::Touch => 74, } } } diff --git a/src/drivers/unified_gamepad/reports/input_capability_report.rs b/src/drivers/unified_gamepad/reports/input_capability_report.rs index 50bad0d..dc06540 100644 --- a/src/drivers/unified_gamepad/reports/input_capability_report.rs +++ b/src/drivers/unified_gamepad/reports/input_capability_report.rs @@ -228,18 +228,38 @@ impl InputCapabilityReport { let value = UInt16Value::unpack(buffer)?; Value::UInt16(value) } + ValueType::UInt32 => todo!(), + ValueType::UInt64 => todo!(), + ValueType::Int8 => todo!(), + ValueType::Int16 => todo!(), + ValueType::Int32 => todo!(), + ValueType::Int64 => todo!(), + ValueType::UInt8Vector2 => todo!(), ValueType::UInt16Vector2 => { let slice = &report.data[byte_start..byte_end]; let buffer = slice.try_into()?; let value = UInt16Vector2Value::unpack(buffer)?; Value::UInt16Vector2(value) } + ValueType::UInt32Vector2 => todo!(), + ValueType::UInt64Vector2 => todo!(), + ValueType::Int8Vector2 => todo!(), + ValueType::Int16Vector2 => todo!(), + ValueType::Int32Vector2 => todo!(), + ValueType::Int64Vector2 => todo!(), + ValueType::UInt8Vector3 => todo!(), + ValueType::UInt16Vector3 => todo!(), + ValueType::UInt32Vector3 => todo!(), + ValueType::UInt64Vector3 => todo!(), + ValueType::Int8Vector3 => todo!(), ValueType::Int16Vector3 => { let slice = &report.data[byte_start..byte_end]; let buffer = slice.try_into()?; let value = Int16Vector3Value::unpack(buffer)?; Value::Int16Vector3(value) } + ValueType::Int32Vector3 => todo!(), + ValueType::Int64Vector3 => todo!(), ValueType::Touch => { let slice = &report.data[byte_start..byte_end]; let buffer = slice.try_into()?;