diff options
-rw-r--r-- | src/hid.rs | 21 |
1 files changed, 3 insertions, 18 deletions
@@ -101,21 +101,6 @@ impl<B: UsbBus, D: HidDevice> HidClass<'_, B, D> { } } - fn get_report_descriptor(&self, index: u8, buf: &mut [u8]) -> usb_device::Result<usize> { - if index == 0 { - let report_descriptor = self.device.report_descriptor(); - let len = report_descriptor.len(); - if len > buf.len() { - Err(UsbError::BufferOverflow) - } else { - buf[0..len].copy_from_slice(report_descriptor); - Ok(len) - } - } else { - Err(UsbError::InvalidState) - } - } - fn get_report(&mut self, xfer: ControlIn<B>) { let req = xfer.request(); let [report_type, report_id] = req.value.to_be_bytes(); @@ -202,9 +187,9 @@ impl<B: UsbBus, D: HidDevice> UsbClass<B> for HidClass<'_, B, D> { (RequestType::Standard, Recipient::Interface) => { if req.request == control::Request::GET_DESCRIPTOR { let (dtype, index) = req.descriptor_type_index(); - if dtype == DescriptorType::Report.into() { - xfer.accept(|mut buf| self.get_report_descriptor(index, &mut buf)) - .ok(); + if dtype == DescriptorType::Report.into() && index == 0 { + let descriptor = self.device.report_descriptor(); + xfer.accept_with(descriptor).ok(); } } } |