diff --git a/firmware/src/device.rs b/firmware/src/device.rs index 37289e0..d94e131 100644 --- a/firmware/src/device.rs +++ b/firmware/src/device.rs @@ -16,43 +16,43 @@ use usbd_human_interface_device::{ // Generated using Waratah #[rustfmt::skip] pub const CUSTOM_DESCRIPTOR: &[u8] = &[ - 0x05, 0x01, // UsagePage(Generic Desktop[0x0001]) - 0x09, 0x04, // UsageId(Joystick[0x0004]) - 0xA1, 0x01, // Collection(Application) - 0x09, 0x01, // UsageId(Pointer[0x0001]) - 0xA1, 0x00, // Collection(Physical) - 0x09, 0x30, // UsageId(X[0x0030]) - 0x09, 0x32, // UsageId(Z[0x0032]) - 0x15, 0x00, // LogicalMinimum(0) - 0x26, 0xFF, 0x0F, // LogicalMaximum(4,095) - 0x95, 0x02, // ReportCount(2) - 0x75, 0x0C, // ReportSize(12) - 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) - 0xC0, // EndCollection() - 0x05, 0x09, // UsagePage(Button[0x0009]) - 0x19, 0x01, // UsageIdMin(Button 1[0x0001]) - 0x29, 0x10, // UsageIdMax(Button 16[0x0010]) - 0x25, 0x01, // LogicalMaximum(1) - 0x95, 0x10, // ReportCount(16) - 0x75, 0x01, // ReportSize(1) - 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) - 0x05, 0x0E, // UsagePage(Haptics[0x000E]) - 0x09, 0x21, // UsageId(Manual Trigger[0x0021]) - 0x26, 0xFF, 0x00, // LogicalMaximum(255) - 0x95, 0x01, // ReportCount(1) - 0x75, 0x08, // ReportSize(8) - 0x91, 0x02, // Output(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, NonVolatile, BitField) - 0xC0, // EndCollection() + 0x05, 0x01, // UsagePage(Generic Desktop[0x0001]) + 0x09, 0x04, // UsageId(Joystick[0x0004]) + 0xA1, 0x01, // Collection(Application) + 0x09, 0x01, // UsageId(Pointer[0x0001]) + 0xA1, 0x00, // Collection(Physical) + 0x09, 0x30, // UsageId(X[0x0030]) + 0x09, 0x32, // UsageId(Z[0x0032]) + 0x15, 0x00, // LogicalMinimum(0) + 0x27, 0xFF, 0xFF, 0x00, 0x00, // LogicalMaximum(65,535) + 0x95, 0x02, // ReportCount(2) + 0x75, 0x10, // ReportSize(16) + 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) + 0xC0, // EndCollection() + 0x05, 0x09, // UsagePage(Button[0x0009]) + 0x19, 0x01, // UsageIdMin(Button 1[0x0001]) + 0x29, 0x10, // UsageIdMax(Button 16[0x0010]) + 0x25, 0x01, // LogicalMaximum(1) + 0x95, 0x10, // ReportCount(16) + 0x75, 0x01, // ReportSize(1) + 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) + 0x05, 0x0E, // UsagePage(Haptics[0x000E]) + 0x09, 0x21, // UsageId(Manual Trigger[0x0021]) + 0x26, 0xFF, 0x00, // LogicalMaximum(255) + 0x95, 0x01, // ReportCount(1) + 0x75, 0x08, // ReportSize(8) + 0x91, 0x02, // Output(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, NonVolatile, BitField) + 0xC0, // EndCollection() ]; #[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)] #[packed_struct(endian = "lsb", size_bytes = "6")] pub struct CustomInputReport { - #[packed_field] - pub y: u16, #[packed_field] pub x: u16, #[packed_field] + pub y: u16, + #[packed_field] pub buttons: u16, } diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 781b974..c5d88d8 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -131,14 +131,14 @@ fn main() -> ! { fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc) -> CustomInputReport { let integLT: u16 = adc1.read(&mut pins.pa1).unwrap(); let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap(); - let retX = integLT as i16; - let retY = floodLT as i16; + let retX = integLT * 16; + let retY = floodLT * 16; let buttons: u16 = 0; CustomInputReport { - x: floodLT.into(), - y: floodLT.into(), + x: retX.into(), + y: retY.into(), buttons, } }