more checks for graphics tablet capabilities

xkb
sezanzeb 3 years ago committed by sezanzeb
parent cb577cf2b3
commit a983cf9126

@ -36,6 +36,14 @@ from keymapper.logger import logger
_devices = None
TABLET_KEYS = [
evdev.ecodes.BTN_STYLUS,
evdev.ecodes.BTN_TOOL_BRUSH,
evdev.ecodes.BTN_TOOL_PEN,
evdev.ecodes.BTN_TOOL_RUBBER
]
if not hasattr(evdev.InputDevice, 'path'):
# for evdev < 1.0.0 patch the path property
@property
@ -59,11 +67,10 @@ def is_gamepad(device):
# check for some random mousepad capability
return False
if evdev.ecodes.BTN_TOOL_BRUSH in capabilities.get(EV_KEY, []):
# a graphics tablet, not a gamepad
return False
if evdev.ecodes.BTN_STYLUS in capabilities.get(EV_KEY, []):
# another graphics tablet test
# graphics tablet tests.
# They use ABS_X and ABS_Y for moving the cursor
keys = capabilities.get(EV_KEY, [])
if [key for key in keys if key in TABLET_KEYS]:
return False
if evdev.ecodes.ABS_X in abs_capabilities:

@ -124,6 +124,6 @@ Communication to the service always happens via `key-mapper-control`
## Resources
[PyGObject API Reference](https://lazka.github.io/pgi-docs/)
[python-evdev](https://python-evdev.readthedocs.io/en/stable/)
- [Guidelines for device capabilities](https://www.kernel.org/doc/Documentation/input/event-codes.txt)
- [PyGObject API Reference](https://lazka.github.io/pgi-docs/)
- [python-evdev](https://python-evdev.readthedocs.io/en/stable/)

@ -176,8 +176,8 @@ class TestGetDevices(unittest.TestCase):
EV_KEY: [evdev.ecodes.ABS_X] # intentionally ABS_X (0) on EV_KEY
})))
self.assertFalse(is_gamepad(FakeDevice({
EV_ABS: [evdev.ecodes.ABS_X],
EV_KEY: [evdev.ecodes.BTN_TOOL_BRUSH]
EV_ABS: [evdev.ecodes.ABS_Y],
EV_KEY: [evdev.ecodes.BTN_TOOL_PEN]
})))
self.assertFalse(is_gamepad(FakeDevice({
EV_ABS: [evdev.ecodes.ABS_X],

Loading…
Cancel
Save