From 08a74c28b31e42fca77bf1d31339c4306f023f40 Mon Sep 17 00:00:00 2001 From: Naxdy <naxdy@naxdy.org> Date: Mon, 14 Oct 2024 21:41:03 +0200 Subject: [PATCH] chore: move gcc hid descriptor --- src/hid/gcc.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ src/usb_comms.rs | 59 +----------------------------------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/hid/gcc.rs b/src/hid/gcc.rs index 8930bc8..dddc8ef 100644 --- a/src/hid/gcc.rs +++ b/src/hid/gcc.rs @@ -7,6 +7,63 @@ use embassy_usb::{ use crate::usb_comms::{HidReportBuilder, SIGNAL_RUMBLE}; use packed_struct::{derive::PackedStruct, PackedStruct}; +#[rustfmt::skip] +pub const GCC_REPORT_DESCRIPTOR: &[u8] = &[ + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x05, // Usage (Game Pad) + 0xA1, 0x01, // Collection (Application) + 0xA1, 0x03, // Collection (Report) + 0x85, 0x11, // Report ID (17) + 0x19, 0x00, // Usage Minimum (Undefined) + 0x2A, 0xFF, 0x00, // Usage Maximum (0xFF) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x75, 0x08, // Report Size (8) + 0x95, 0x05, // Report Count (5) + 0x91, 0x00, // Output (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0xC0, // End Collection + 0xA1, 0x03, // Collection (Report) + 0x85, 0x21, // Report ID (33) + 0x05, 0x00, // Usage Page (Undefined) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0xFF, // Logical Maximum (-1) + 0x75, 0x08, // Report Size (8) + 0x95, 0x01, // Report Count (1) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (0x01) + 0x29, 0x08, // Usage Maximum (0x08) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x75, 0x08, // Report Size (8) + 0x95, 0x02, // Report Count (2) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x09, 0x32, // Usage (Z) + 0x09, 0x33, // Usage (Rx) + 0x09, 0x34, // Usage (Ry) + 0x09, 0x35, // Usage (Rz) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x75, 0x08, // Report Size (8) + 0x95, 0x06, // Report Count (6) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0xC0, // End Collection + 0xA1, 0x03, // Collection (Report) + 0x85, 0x13, // Report ID (19) + 0x19, 0x00, // Usage Minimum (Undefined) + 0x2A, 0xFF, 0x00, // Usage Maximum (0xFF) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x75, 0x08, // Report Size (8) + 0x95, 0x01, // Report Count (1) + 0x91, 0x00, // Output (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0xC0, // End Collection + 0xC0, // End Collection +]; + #[derive(Clone, Copy, Debug, PartialEq, Eq, Default, PackedStruct, Format)] #[packed_struct(bit_numbering = "lsb0", size_bytes = "1")] pub struct GcButtons1 { diff --git a/src/usb_comms.rs b/src/usb_comms.rs index 85e41f2..bf94edb 100644 --- a/src/usb_comms.rs +++ b/src/usb_comms.rs @@ -25,7 +25,7 @@ use libm::powf; use crate::{ config::{ControllerMode, InputConsistencyMode}, hid::{ - gcc::{GcReportBuilder, GcState, GccRequestHandler}, + gcc::{GcReportBuilder, GcState, GccRequestHandler, GCC_REPORT_DESCRIPTOR}, procon::{ProconReportBuilder, ProconRequestHandler, PROCON_REPORT_DESCRIPTOR}, }, input::CHANNEL_GCC_STATE, @@ -50,63 +50,6 @@ pub static MUTEX_CONTROLLER_MODE: Mutex<CriticalSectionRawMutex, Option<Controll /// Vendor-defined property data const DEVICE_INTERFACE_GUID: &str = "{ecceff35-146c-4ff3-acd9-8f992d09acdd}"; -#[rustfmt::skip] -pub const GCC_REPORT_DESCRIPTOR: &[u8] = &[ - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x05, // Usage (Game Pad) - 0xA1, 0x01, // Collection (Application) - 0xA1, 0x03, // Collection (Report) - 0x85, 0x11, // Report ID (17) - 0x19, 0x00, // Usage Minimum (Undefined) - 0x2A, 0xFF, 0x00, // Usage Maximum (0xFF) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x00, // Logical Maximum (255) - 0x75, 0x08, // Report Size (8) - 0x95, 0x05, // Report Count (5) - 0x91, 0x00, // Output (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - 0xC0, // End Collection - 0xA1, 0x03, // Collection (Report) - 0x85, 0x21, // Report ID (33) - 0x05, 0x00, // Usage Page (Undefined) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0xFF, // Logical Maximum (-1) - 0x75, 0x08, // Report Size (8) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x09, // Usage Page (Button) - 0x19, 0x01, // Usage Minimum (0x01) - 0x29, 0x08, // Usage Maximum (0x08) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x08, // Report Size (8) - 0x95, 0x02, // Report Count (2) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x09, 0x31, // Usage (Y) - 0x09, 0x32, // Usage (Z) - 0x09, 0x33, // Usage (Rx) - 0x09, 0x34, // Usage (Ry) - 0x09, 0x35, // Usage (Rz) - 0x15, 0x81, // Logical Minimum (-127) - 0x25, 0x7F, // Logical Maximum (127) - 0x75, 0x08, // Report Size (8) - 0x95, 0x06, // Report Count (6) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, // End Collection - 0xA1, 0x03, // Collection (Report) - 0x85, 0x13, // Report ID (19) - 0x19, 0x00, // Usage Minimum (Undefined) - 0x2A, 0xFF, 0x00, // Usage Maximum (0xFF) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x00, // Logical Maximum (255) - 0x75, 0x08, // Report Size (8) - 0x95, 0x01, // Report Count (1) - 0x91, 0x00, // Output (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - 0xC0, // End Collection - 0xC0, // End Collection -]; - pub trait HidReportBuilder<const LEN: usize> { async fn get_hid_report(&mut self, state: &GcState) -> [u8; LEN]; }