File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -408,6 +408,24 @@ impl<B: UsbBus> HIDClass<'_, B> {
408
408
}
409
409
}
410
410
411
+ pub fn maybe_push_input < ' a , IR : AsInputReport > (
412
+ & self ,
413
+ mut producer : impl FnMut ( ) -> IR ,
414
+ ) -> Option < Result < usize > > {
415
+ if let Some ( ep) = & self . in_ep {
416
+ let mut buff: [ u8 ; 64 ] = [ 0 ; 64 ] ;
417
+ ep. maybe_write ( || {
418
+ let size = match serialize ( & mut buff, & producer ( ) ) {
419
+ Ok ( l) => l,
420
+ Err ( _) => return Err ( UsbError :: BufferOverflow ) ,
421
+ } ;
422
+ Ok ( & buff[ 0 ..size] )
423
+ } )
424
+ } else {
425
+ Some ( Err ( UsbError :: InvalidEndpoint ) )
426
+ }
427
+ }
428
+
411
429
/// Tries to write an input (device-to-host) report from the given raw bytes.
412
430
/// Data is expected to be a valid HID report for INPUT items. If report ID's
413
431
/// were used in the descriptor, the report ID corresponding to this report
You can’t perform that action at this time.
0 commit comments