def process_event(self): ev_type, request = uhid.parse_event(self.__uhid_read( uhid.EVENT_LENGTH)) if ev_type == uhid.EVENT_TYPE_START: dev_flags, = request logger.log_uhid_event("UHID_START", "dev_flags=0b{:08b}".format(dev_flags)) elif ev_type == uhid.EVENT_TYPE_STOP: logger.log_uhid_event("UHID_STOP") elif ev_type == uhid.EVENT_TYPE_OPEN: logger.log_uhid_event("UHID_OPEN") elif ev_type == uhid.EVENT_TYPE_CLOSE: logger.log_uhid_event("UHID_CLOSE") elif ev_type == uhid.EVENT_TYPE_OUTPUT: data, size, rtype = request logger.log_uhid_event( "UHID_OUTPUT", "data=0x{} size={} rtype={}".format(data.hex(), size, rtype), ) logger.log_hid_packet("DEVICE_INPUT", "0x{}".format(data[1:].hex())) return data[1:] else: logger.log_uhid_event( "UNKNOWN_EVENT", "ev_type={} request=0x{}".format(ev_type, request.hex()), )
def process_event(self): ev_type, request = uhid.parse_event(self.__uhid_read( uhid.EVENT_LENGTH)) if ev_type == uhid.EVENT_TYPE_START: dev_flags, = request logger.log_uhid_event("UHID_START", f"dev_flags=0b{dev_flags:08b}") elif ev_type == uhid.EVENT_TYPE_STOP: logger.log_uhid_event("UHID_STOP") elif ev_type == uhid.EVENT_TYPE_OPEN: logger.log_uhid_event("UHID_OPEN") elif ev_type == uhid.EVENT_TYPE_CLOSE: logger.log_uhid_event("UHID_CLOSE") elif ev_type == uhid.EVENT_TYPE_OUTPUT: data, size, rtype = request logger.log_uhid_event( "UHID_OUTPUT", f"data=0x{data.hex()} size={size} rtype={rtype}", ) logger.log_hid_packet("DEVICE_INPUT", f"0x{data[1:].hex()}") return data[1:] else: logger.log_uhid_event( "UNKNOWN_EVENT", f"ev_type={ev_type} request=0x{request.hex()}", )
def write_data(self, data): buf = uhid.create_input2_event(data) self.__uhid_write(buf) logger.log_uhid_event( "UHID_INPUT2", "data=0x{} size={}".format(data.hex(), len(data)) ) logger.log_hid_packet("DEVICE_OUTPUT", "0x{}".format(data.hex()))
def write_data(self, data): buf = uhid.create_input2_event(data) self.__uhid_write(buf) logger.log_uhid_event("UHID_INPUT2", f"data=0x{data.hex()} size={len(data)}") logger.log_hid_packet("DEVICE_OUTPUT", f"0x{data.hex()}")