How to use the hidapi.enumerate function in hidapi

To help you get started, we’ve selected a few hidapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pwr-Solaar / Solaar / lib / hidapi / View on Github external
def _open(args):
	device = args.device
	if args.hidpp and not device:
		for d in _hid.enumerate(vendor_id=0x046d):
			if d.driver == 'logitech-djreceiver':
				device = d.path
		if not device:
			sys.exit("!! No HID++ receiver found.")
	if not device:
		sys.exit("!! Device path required.")

	print (".. Opening device", device)
	handle = _hid.open_path(device)
	if not handle:
		sys.exit("!! Failed to open %s, aborting." % device)

	print (".. Opened handle %r, vendor %r product %r serial %r." % (
github lonetech / LookingGlass / View on Github external
page = len(json)//64
        l = min(64, jsonlen-64*page)
        json[64*page:] = rp(dev, page, l)
        #print json
    return json[4:]

def read_eeprom(devinfo):
    dev = hidapi.Device(devinfo)
    cfg = json.loads(loadconfig(dev).decode('ascii'))
    # TODO: Use calibration data. Sample code in
    return (dev, cfg)

for dev in hidapi.enumerate(vendor_id=0x04d8, product_id=0xef7e):
    if dev.product_string == u'HoloPlay':
        hiddev, cfg = read_eeprom(dev)
        while True:
            # Keep reading the button bitmask
            r =
            if r:
                byte = r[0]
                # Python 2 compatibility
                if isinstance(byte, str):
                    byte = ord(byte)
github cyanogen / uchroma / uchroma / server / View on Github external
Iterates over all connected HID devices with RAZER_VENDOR_ID
        and checks the product ID against the Hardware descriptor.

        Interface endpoint restrictions are currently hard-coded. In
        the future this should be done by checking the HID report
        descriptor of the endpoint, however this functionality in
        HIDAPI is broken (report_descriptor returns garbage) on
        Linux in the current release.

        Discovery is automatically performed when the object is
        constructed, so this should only need to be called if the
        list of devices changes (monitoring for changes is beyond
        the scope of this API).
        devinfos = sorted(list(hidapi.enumerate(vendor_id=RAZER_VENDOR_ID)), key=lambda x: x.path)

        for devinfo in devinfos:
            parent = self._get_parent(devinfo.product_id)
            if parent is None:

            if self._key_for_path(parent.sys_path) is not None:

            hardware = Hardware.get_device(devinfo.product_id)
            if hardware is None:

            if hardware.type == Hardware.Type.HEADSET:
                if devinfo.interface_number != 3:
github pwr-Solaar / Solaar / lib / logitech_receiver / View on Github external
def receivers():
	"""List all the Linux devices exposed by the UR attached to the machine."""
	for receiver_usb_id in _RECEIVER_USB_IDS:
		for d in _hid.enumerate(*receiver_usb_id):
			yield d