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 _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'): if not hasattr(evdev.InputDevice, 'path'):
# for evdev < 1.0.0 patch the path property # for evdev < 1.0.0 patch the path property
@property @property
@ -59,11 +67,10 @@ def is_gamepad(device):
# check for some random mousepad capability # check for some random mousepad capability
return False return False
if evdev.ecodes.BTN_TOOL_BRUSH in capabilities.get(EV_KEY, []): # graphics tablet tests.
# a graphics tablet, not a gamepad # They use ABS_X and ABS_Y for moving the cursor
return False keys = capabilities.get(EV_KEY, [])
if evdev.ecodes.BTN_STYLUS in capabilities.get(EV_KEY, []): if [key for key in keys if key in TABLET_KEYS]:
# another graphics tablet test
return False return False
if evdev.ecodes.ABS_X in abs_capabilities: if evdev.ecodes.ABS_X in abs_capabilities:

@ -124,6 +124,6 @@ Communication to the service always happens via `key-mapper-control`
## Resources ## Resources
[PyGObject API Reference](https://lazka.github.io/pgi-docs/) - [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/) - [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 EV_KEY: [evdev.ecodes.ABS_X] # intentionally ABS_X (0) on EV_KEY
}))) })))
self.assertFalse(is_gamepad(FakeDevice({ self.assertFalse(is_gamepad(FakeDevice({
EV_ABS: [evdev.ecodes.ABS_X], EV_ABS: [evdev.ecodes.ABS_Y],
EV_KEY: [evdev.ecodes.BTN_TOOL_BRUSH] EV_KEY: [evdev.ecodes.BTN_TOOL_PEN]
}))) })))
self.assertFalse(is_gamepad(FakeDevice({ self.assertFalse(is_gamepad(FakeDevice({
EV_ABS: [evdev.ecodes.ABS_X], EV_ABS: [evdev.ecodes.ABS_X],

Loading…
Cancel
Save