

def raw_test():
    all_hids = hid.find_all_hid_devices()
    if all_hids:
        while True:
            print('Choose a device to monitor raw input reports:\n')
            print('0 => Exit')
            for (index, device) in enumerate(all_hids):
                device_name = unicode('{0.vendor_name} {0.product_name}(vID=0x{1:04x}, pID=0x{2:04x})'.format(device, device.vendor_id, device.product_id))
                print('{0} => {1}'.format((index + 1), device_name))
            print(("\n\tDevice ('0' to '%d', '0' to exit?) [press enter after number]:" % len(device_name)))
            index_option = raw_input()
            if (index_option.isdigit() and (int(index_option) <= len(all_hids))):
                break
        int_option = int(index_option)
        if int_option:
            device = all_hids[(int_option - 1)]
            try:
                device.open()
                device.set_raw_data_handler(sample_handler)
                print('\nWaiting for data...\nPress any (system keyboard) key to stop...')
                while ((not kbhit()) and device.is_plugged()):
                    sleep(0.5)
                return
            finally:
                device.close()
    else:
        print("There's not any non system HID class device available")

dataset/ETHPy150Open rene-aguirre/pywinusb/examples/raw_data.py raw_test/VarMisuse@95/224 `all_hids`->`device_name`