Works from flightgear, hidviz is broken

Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
fly 2024-05-20 01:41:26 +02:00
parent 04d8e5812e
commit af34339c44
2 changed files with 10 additions and 7 deletions

View file

@ -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<CustomOutputReport, UsbHidError> {
let mut data = [0, 0, 0, 0];
let mut data = [0; 5];
self.interface
.read_report(&mut data[..])
.map(|_| CustomOutputReport::unpack(&data).unwrap())

View file

@ -282,7 +282,7 @@ fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc<pac::ADC1>, cal: &Calibrati
}
CustomInputReport {
// report_id: 1,
report_id: 1,
axis: values_norm,
buttons,
}