set typing pool to use device id instead of dev file. now works when usb stuff has been disonnected or moved around.

workspace
Brendan Howell 9 years ago
parent 66ef6b4318
commit 37f6c1cfc3

@ -28,12 +28,16 @@ class TypingPool(Bureau):
self.devices = []
self.active_devices = []
devindex = {}
# add anything that smells like a keyboard
for dev in devices:
devkey = format(dev.info.vendor, '04x') + ":" +\
format(dev.info.product, '04x')
devindex[devkey] = dev
try:
if evdev.ecodes.KEY_A in dev.capabilities()[evdev.ecodes.EV_KEY]:
print(dir(dev))
print("usb device:", dev.info)
print(dev.fn)
self.devices.append(dev)
except KeyError as err:
@ -41,16 +45,24 @@ class TypingPool(Bureau):
# if we don't have any active KB so tell the user to config one
if "active" in self.config:
# TODO: better error handling here
self.active_devices = list(map(evdev.InputDevice,
self.config["active"]["devices"].split()))
# self.active_devices = list(map(evdev.InputDevice,
# self.config["active"]["devices"].split()))
cfg_devs = self.config["active"]["devices"].split()
print("trying to grab keyboard devs:", cfg_devs)
print("device index", devindex)
for dev in cfg_devs:
if dev in devindex:
self.active_devices.append(devindex[dev])
else:
print("you need to configure input hardware!")
print("add one of the following devices to TY.ini under [active]")
print(" devices = /dev/usb/kb1 /dev/input/whatever")
print(" devices = 0c45:7403 ")
print("available keyboard devices:")
for dev in self.devices:
print(dev.fn, ":", dev.name, dev.info)
print(dev.fn, ":", dev.name,
format(dev.info.vendor, '04x') + ":" +
format(dev.info.product, '04x'))
def run_io(self):
val = ""

Loading…
Cancel
Save