mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-08-03 16:00:34 -04:00
Move client to own folder
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""XAP Client
|
||||
"""
|
||||
import hid
|
||||
|
||||
from .device import XAPDevice
|
||||
|
||||
|
||||
class XAPClient:
|
||||
@staticmethod
|
||||
def list(search=None):
|
||||
"""Find compatible XAP devices
|
||||
"""
|
||||
def _is_xap_usage(x):
|
||||
return x['usage_page'] == 0xFF51 and x['usage'] == 0x0058
|
||||
|
||||
def _is_filtered_device(x):
|
||||
name = '%04x:%04x' % (x['vendor_id'], x['product_id'])
|
||||
return name.lower().startswith(search.lower())
|
||||
|
||||
devices = filter(_is_xap_usage, hid.enumerate())
|
||||
if search:
|
||||
devices = filter(_is_filtered_device, devices)
|
||||
|
||||
return list(devices)
|
||||
|
||||
def connect(self, dev):
|
||||
"""Connect to a given XAP device
|
||||
"""
|
||||
return XAPDevice(dev)
|
||||
Reference in New Issue
Block a user