1
0
Fork 0

Have 2 output reports for testing stuff

Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
fly 2024-04-14 23:38:32 +02:00
parent eb85c4f787
commit e589056abd
3 changed files with 20 additions and 8 deletions

View file

@ -10,8 +10,16 @@ usage = ['Generic Desktop', 'Pointer']
usage = ['Generic Desktop', 'X']
logicalValueRange = [0, 65535]
[[applicationCollection.inputReport.physicalCollection.variableItem]]
usage = ['Generic Desktop', 'Z']
logicalValueRange = [0, 65535]
[[applicationCollection.outputReport]]
[[applicationCollection.outputReport.variableItem]]
usage = ['Haptics', 'Manual Trigger']
logicalValueRange = [0, 255]
logicalValueRange = [0, 48000]
[[applicationCollection.outputReport.variableItem]]
usage = ['Haptics', 'Manual Trigger']
logicalValueRange = [0, 65535]

View file

@ -36,12 +36,15 @@ pub const CUSTOM_DESCRIPTOR: &[u8] = &[
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])
0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00)
0x09, 0x01, // Usage (0x01)
0x27, 0x80, 0xBB, 0x00, 0x00, // LogicalMaximum(48,000)
0x95, 0x01, // ReportCount(1)
0x75, 0x10, // ReportSize(16)
0x91, 0x02, // Output(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, NonVolatile, BitField)
0x09, 0x21, // UsageId(Manual Trigger[0x0021])
0x27, 0xFF, 0xFF, 0x00, 0x00, // LogicalMaximum(65,535)
0x91, 0x02, // Output(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, NonVolatile, BitField)
0xC0, // EndCollection()
];
@ -57,10 +60,11 @@ pub struct CustomInputReport {
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
#[packed_struct(endian = "lsb", size_bytes = "2")]
#[packed_struct(endian = "lsb", size_bytes = "4")]
pub struct CustomOutputReport {
#[packed_field]
pub int: u16,
pub integ_lt: u16,
pub test: u16,
}
pub struct CustomDevice<'a, B: UsbBus> {
@ -77,7 +81,7 @@ impl<'a, B: UsbBus> CustomDevice<'a, B> {
}
pub fn read_report(&mut self) -> Result<CustomOutputReport, UsbHidError> {
let mut data = [0, 0];
let mut data = [0, 0, 0, 0];
self.interface
.read_report(&mut data[..])
.map(|_| CustomOutputReport::unpack(&data).unwrap())

View file

@ -111,11 +111,11 @@ fn main() -> ! {
Err(UsbHidError::WouldBlock) => {}
Ok(output) => {
let pwm_val: u16;
if output.int > pwm_max {
if output.integ_lt > pwm_max {
pwm_val = pwm_max;
}
else {
pwm_val = output.int;
pwm_val = output.integ_lt;
}
pwm.set_duty(Channel::C1, pwm_val);
}