From af34339c44826968eae1bb7a07561de00e111675 Mon Sep 17 00:00:00 2001 From: fly Date: Mon, 20 May 2024 01:41:26 +0200 Subject: [PATCH] Works from flightgear, hidviz is broken Signed-off-by: fly --- Pedestal/firmware/src/device.rs | 15 +++++++++------ Pedestal/firmware/src/main.rs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Pedestal/firmware/src/device.rs b/Pedestal/firmware/src/device.rs index 60bf1b1..593b857 100644 --- a/Pedestal/firmware/src/device.rs +++ b/Pedestal/firmware/src/device.rs @@ -19,7 +19,7 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[ 0x05, 0x01, // UsagePage(Generic Desktop[0x0001]) 0x09, 0x04, // UsageId(Joystick[0x0004]) 0xA1, 0x01, // Collection(Application) -// 0x85, 0x01, // ReportId(1) + 0x85, 0x01, // ReportId(1) 0x09, 0x01, // UsageId(Pointer[0x0001]) 0xA1, 0x00, // Collection(Physical) 0x09, 0x30, // UsageId(X[0x0030]) @@ -37,6 +37,7 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[ 0x95, 0x10, // ReportCount(16) 0x75, 0x01, // ReportSize(1) 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) + 0x85, 0x02, // ReportId(2) 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00) 0x09, 0x01, // Usage (0x01) 0x27, 0x80, 0xBB, 0x00, 0x00, // LogicalMaximum(48,000) @@ -50,10 +51,10 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[ ]; #[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)] -#[packed_struct(endian = "lsb", size_bytes = "6")] +#[packed_struct(endian = "lsb", size_bytes = "7")] pub struct CustomInputReport { -// #[packed_field] -// pub report_id: u8, + #[packed_field] + pub report_id: u8, #[packed_field] pub axis: [u16; 2], #[packed_field] @@ -61,8 +62,10 @@ pub struct CustomInputReport { } #[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)] -#[packed_struct(endian = "lsb", size_bytes = "4")] +#[packed_struct(endian = "lsb", size_bytes = "5")] pub struct CustomOutputReport { + #[packed_field] + pub report_id: u8, #[packed_field] pub integ_lt: u16, pub generic: u16, @@ -82,7 +85,7 @@ impl<'a, B: UsbBus> CustomDevice<'a, B> { } pub fn read_report(&mut self) -> Result { - let mut data = [0, 0, 0, 0]; + let mut data = [0; 5]; self.interface .read_report(&mut data[..]) .map(|_| CustomOutputReport::unpack(&data).unwrap()) diff --git a/Pedestal/firmware/src/main.rs b/Pedestal/firmware/src/main.rs index 5dace44..71d02bf 100644 --- a/Pedestal/firmware/src/main.rs +++ b/Pedestal/firmware/src/main.rs @@ -282,7 +282,7 @@ fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc, cal: &Calibrati } CustomInputReport { -// report_id: 1, + report_id: 1, axis: values_norm, buttons, }