in evdev i'm trying to check to see if there is a mouse and keyboard plugged in and if so assign the device path to a variable to be used. This worked for a while as i just checked for the name Mouse or Keyboard in the device name by using this code
if ("KEYBOARD" in device.name) or ("Keyboard" in device.name):
print ("This is a Keyboard")
keyboarddir = device.path
keyboard = evdev.InputDevice(keyboarddir)
After plugging in a different mouse i discovered that they don't all say mouse in there and i wanted to know if there was a way i could compare a string called "BTN_RIGHT" to the device capabilities. The code i typed which doesn't work would go something like this.
if ("BTN_RIGHT" in device.capabilities(verbose=True)):
print ("this is the mouse")
Please help me figure out how to detect a mouse easier or by actually being able to search through its capabilities and compare them to other strings!
Since the data structure you want to parse looks like:
...you might do something like (not using
verbose=True
here, since it's a lot simpler if we're just working with the raw constants):If you really want to work with the string forms (which I don't recommend), your data would instead look like:
...you might do something like:
...but that's a lot of extra code and overhead to work around cruft that's only in the data structures for purposes of human readability.