@@ -477,6 +477,8 @@ trait HidDeviceBackendBase {
477477 fn send_feature_report ( & self , data : & [ u8 ] ) -> HidResult < ( ) > ;
478478 fn get_feature_report ( & self , buf : & mut [ u8 ] ) -> HidResult < usize > ;
479479 fn send_output_report ( & self , data : & [ u8 ] ) -> HidResult < ( ) > ;
480+ #[ cfg( any( hidapi, target_os = "linux" ) ) ]
481+ fn get_input_report ( & self , data : & mut [ u8 ] ) -> HidResult < usize > ;
480482 fn set_blocking_mode ( & self , blocking : bool ) -> HidResult < ( ) > ;
481483 fn get_device_info ( & self ) -> HidResult < DeviceInfo > ;
482484 fn get_manufacturer_string ( & self ) -> HidResult < Option < String > > ;
@@ -595,23 +597,36 @@ impl HidDevice {
595597 self . inner . get_feature_report ( buf)
596598 }
597599
598- // Send a Output report to the device.
599- //
600- // Output reports are sent over the Control endpoint as a Set_Report
601- // transfer. The first byte of data[] must contain the Report ID.
602- // For devices which only support a single report, this must be set
603- // to 0x0. The remaining bytes contain the report data. Since the
604- // Report ID is mandatory, calls to hid_send_output_report() will
605- // always contain one more byte than the report contains. For example,
606- // if a hid report is 16 bytes long, 17 bytes must be passed to
607- // hid_send_output_report(): the Report ID (or 0x0, for devices
608- // which do not use numbered reports), followed by the report
609- // data (16 bytes). In this example, the length passed in
610- // would be 17.
600+ /// Send a Output report to the device.
601+ ///
602+ /// Output reports are sent over the Control endpoint as a Set_Report
603+ /// transfer. The first byte of data[] must contain the Report ID.
604+ /// For devices which only support a single report, this must be set
605+ /// to 0x0. The remaining bytes contain the report data. Since the
606+ /// Report ID is mandatory, calls to hid_send_output_report() will
607+ /// always contain one more byte than the report contains. For example,
608+ /// if a hid report is 16 bytes long, 17 bytes must be passed to
609+ /// hid_send_output_report(): the Report ID (or 0x0, for devices
610+ /// which do not use numbered reports), followed by the report
611+ /// data (16 bytes). In this example, the length passed in
612+ /// would be 17.
611613 pub fn send_output_report ( & self , data : & [ u8 ] ) -> HidResult < ( ) > {
612614 self . inner . send_output_report ( data)
613615 }
614616
617+ /// Get a input report from a HID device
618+ ///
619+ /// Set the first byte of data to the report id of the report to be read.
620+ /// Set the first byte to zero if your device does not use numbered reports.
621+ /// After calling the function, the first byte will still contain the same report id.
622+ ///
623+ /// If successful, returns the number of bytes read plus one for the report ID (which is still
624+ /// in the first byte).
625+ #[ cfg( any( hidapi, target_os = "linux" ) ) ]
626+ pub fn get_input_report ( & self , data : & mut [ u8 ] ) -> HidResult < usize > {
627+ self . inner . get_input_report ( data)
628+ }
629+
615630 /// Set the device handle to be in blocking or in non-blocking mode. In
616631 /// non-blocking mode calls to `read()` will return immediately with an empty
617632 /// slice if there is no data to be read. In blocking mode, `read()` will
0 commit comments