tools/usb_gadget/hid_gadget.py
def ClassControlWrite(self, recipient, request, value, index, data):
    """Handle class-specific control requests.

    See Device Class Definition for Human Interface Devices (HID) Version 1.11
    section 7.2.

    Args:
      recipient: Request recipient (device, interface, endpoint, etc.)
      request: bRequest field of the setup packet.
      value: wValue field of the setup packet.
      index: wIndex field of the setup packet.
      data: Data stage of the request.

    Returns:
      True on success, None to stall the pipe.
    """
    if recipient != usb_constants.Recipient.INTERFACE:
      return None
    if index != self._interface_number:
      return None

    if request == hid_constants.Request.SET_REPORT:
      report_type, report_id = value >> 8, value & 0xFF
      print('SetReport(type={}, id={}, length={})'
            .format(report_type, report_id, len(data)))
      return self.SetReport(report_type, report_id, data)
    elif request == hid_constants.Request.SET_IDLE:
      duration, report_id = value >> 8, value & 0xFF
      print('SetIdle(duration={}, report={})'
            .format(duration, report_id))
      return True
Handle class-specific control requests.

    See Device Class Definition for Human Interface Devices (HID) Version 1.11
    section 7.2.

    Args:
      recipient: Request recipient (device, interface, endpoint, etc.)
      request: bRequest field of the setup packet.
      value: wValue field of the setup packet.
      index: wIndex field of the setup packet.
      data: Data stage of the request.

    Returns:
      True on success, None to stall the pipe.
    
Handle class-specific control requests.
See Device Class Definition for Human Interface Devices (HID) Version 1.11
section 7.2.
Handle class - specific control requests . See Device Class Definition for Human Interface Devices ( HID ) Version 1 . 11 section 7 . 2 .
def ClassControlWrite(self, recipient, request, value, index, data):
    if recipient != usb_constants.Recipient.INTERFACE:
      return None
    if index != self._interface_number:
      return None
    if request == hid_constants.Request.SET_REPORT:
      report_type, report_id = value >> 8, value & 0xFF
      print('SetReport(type={}, id={}, length={})'
            .format(report_type, report_id, len(data)))
      return self.SetReport(report_type, report_id, data)
    elif request == hid_constants.Request.SET_IDLE:
      duration, report_id = value >> 8, value & 0xFF
      print('SetIdle(duration={}, report={})'
            .format(duration, report_id))
      return True
def ClassControlWrite ( self , recipient , request , value , index , data ) : if recipient != usb_constants . Recipient . INTERFACE : return None if index != self . _interface_number : return None if request == hid_constants . Request . SET_REPORT : report_type , report_id = value >> 8 , value & 0xFF print ( 'SetReport(type={}, id={}, length={})' . format ( report_type , report_id , len ( data ) ) ) return self . SetReport ( report_type , report_id , data ) elif request == hid_constants . Request . SET_IDLE : duration , report_id = value >> 8 , value & 0xFF print ( 'SetIdle(duration={}, report={})' . format ( duration , report_id ) ) return True
Handle class-specific control requests.
Handle class - specific control requests .
"""Handle class-specific control requests.

    See Device Class Definition for Human Interface Devices (HID) Version 1.11
    section 7.2.

    Args:
      recipient: Request recipient (device, interface, endpoint, etc.)
      request: bRequest field of the setup packet.
      value: wValue field of the setup packet.
      index: wIndex field of the setup packet.
      data: Data stage of the request.

    Returns:
      True on success, None to stall the pipe.
    """
True on success, None to stall the pipe.
True on success None to stall the pipe .
self
recipient
Request recipient (device, interface, endpoint, etc.)
Request recipient ( device interface endpoint etc . )
request
bRequest field of the setup packet.
bRequest field of the setup packet .
value
wValue field of the setup packet.
wValue field of the setup packet .
index
wIndex field of the setup packet.
wIndex field of the setup packet .
data
Data stage of the request.
Data stage of the request .