1
0
Fork 0

Works at least when making it to be 16 bit

Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
fly 2024-04-11 02:55:35 +02:00
parent 4a0cdccdb5
commit 7bdc627898
2 changed files with 33 additions and 33 deletions

View file

@ -24,9 +24,9 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[
0x09, 0x30, // UsageId(X[0x0030]) 0x09, 0x30, // UsageId(X[0x0030])
0x09, 0x32, // UsageId(Z[0x0032]) 0x09, 0x32, // UsageId(Z[0x0032])
0x15, 0x00, // LogicalMinimum(0) 0x15, 0x00, // LogicalMinimum(0)
0x26, 0xFF, 0x0F, // LogicalMaximum(4,095) 0x27, 0xFF, 0xFF, 0x00, 0x00, // LogicalMaximum(65,535)
0x95, 0x02, // ReportCount(2) 0x95, 0x02, // ReportCount(2)
0x75, 0x0C, // ReportSize(12) 0x75, 0x10, // ReportSize(16)
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField) 0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
0xC0, // EndCollection() 0xC0, // EndCollection()
0x05, 0x09, // UsagePage(Button[0x0009]) 0x05, 0x09, // UsagePage(Button[0x0009])
@ -48,11 +48,11 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
#[packed_struct(endian = "lsb", size_bytes = "6")] #[packed_struct(endian = "lsb", size_bytes = "6")]
pub struct CustomInputReport { pub struct CustomInputReport {
#[packed_field]
pub y: u16,
#[packed_field] #[packed_field]
pub x: u16, pub x: u16,
#[packed_field] #[packed_field]
pub y: u16,
#[packed_field]
pub buttons: u16, pub buttons: u16,
} }

View file

@ -131,14 +131,14 @@ fn main() -> ! {
fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc<pac::ADC1>) -> CustomInputReport { fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc<pac::ADC1>) -> CustomInputReport {
let integLT: u16 = adc1.read(&mut pins.pa1).unwrap(); let integLT: u16 = adc1.read(&mut pins.pa1).unwrap();
let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap(); let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap();
let retX = integLT as i16; let retX = integLT * 16;
let retY = floodLT as i16; let retY = floodLT * 16;
let buttons: u16 = 0; let buttons: u16 = 0;
CustomInputReport { CustomInputReport {
x: floodLT.into(), x: retX.into(),
y: floodLT.into(), y: retY.into(),
buttons, buttons,
} }
} }