From 02e45bfc9d678459066ae3ec70a82a1505163821 Mon Sep 17 00:00:00 2001 From: Naxdy Date: Sat, 20 Apr 2024 11:02:56 +0200 Subject: [PATCH] feat(hid): add msos descriptor --- src/gcc_hid.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gcc_hid.rs b/src/gcc_hid.rs index 092d7d8..cefdaef 100644 --- a/src/gcc_hid.rs +++ b/src/gcc_hid.rs @@ -17,6 +17,8 @@ use embassy_time::{Duration, Instant, Timer}; use embassy_usb::{ class::hid::{HidReaderWriter, ReportId, RequestHandler, State}, control::OutResponse, + msos::{self, windows_version}, + types::InterfaceNumber, Builder, Handler, }; use libm::powf; @@ -36,6 +38,9 @@ pub static MUTEX_INPUT_CONSISTENCY_MODE: Mutex< Option, > = Mutex::new(None); +// This is a randomly generated GUID to allow clients on Windows to find our device +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) @@ -334,6 +339,15 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB> &mut control_buf, ); + builder.msos_descriptor(windows_version::WIN8_1, 2); + + let msos_writer = builder.msos_writer(); + msos_writer.device_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", "")); + msos_writer.device_feature(msos::RegistryPropertyFeatureDescriptor::new( + "DeviceInterfaceGUID", + msos::PropertyData::Sz(DEVICE_INTERFACE_GUID), + )); + builder.handler(&mut device_handler); let hid_config = embassy_usb::class::hid::Config {