Meow
Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
parent
e0449c9ac8
commit
e8774ca450
2 changed files with 37 additions and 37 deletions
|
@ -16,44 +16,44 @@ 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, 0x31, // UsageId(Y[0x0031])
|
||||
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()
|
||||
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()
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
|
||||
#[packed_struct(endian = "lsb", size_bytes = "5")]
|
||||
#[packed_struct(endian = "lsb", size_bytes = "6")]
|
||||
pub struct CustomInputReport {
|
||||
#[packed_field]
|
||||
pub y: u16,
|
||||
#[packed_field]
|
||||
pub x: u16,
|
||||
#[packed_field]
|
||||
pub buttons: u16,
|
||||
#[packed_field]
|
||||
pub y: Integer<i16, packed_bits::Bits<12>>,
|
||||
#[packed_field]
|
||||
pub x: Integer<i16, packed_bits::Bits<12>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
|
||||
|
|
|
@ -96,7 +96,7 @@ fn main() -> ! {
|
|||
|
||||
loop {
|
||||
let report = get_report(&mut input_pins, &mut adc1);
|
||||
// if report != last {
|
||||
if report != last {
|
||||
match consumer.device().write_report(&report) {
|
||||
Err(UsbHidError::WouldBlock) => {}
|
||||
Ok(_) => {
|
||||
|
@ -106,7 +106,7 @@ fn main() -> ! {
|
|||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
if usb_dev.poll(&mut [&mut consumer]) {
|
||||
match consumer.device().read_report() {
|
||||
|
@ -131,14 +131,14 @@ fn main() -> ! {
|
|||
fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc<pac::ADC1>) -> CustomInputReport {
|
||||
let integLT: u16 = adc1.read(&mut pins.pa1).unwrap();
|
||||
let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap();
|
||||
let retX = (integLT / 4) as i16;
|
||||
let retX = integLT as i16;
|
||||
let retY = floodLT as i16;
|
||||
let buttons: u16 = 0;
|
||||
|
||||
|
||||
CustomInputReport {
|
||||
x: retX.into(),
|
||||
y: retY.into(),
|
||||
x: floodLT.into(),
|
||||
y: floodLT.into(),
|
||||
buttons,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue