removing ABS_VOLUME

pull/45/head
sezanzeb 4 years ago
parent b92115af25
commit 42ffdf8d1c

@ -305,6 +305,11 @@ class Injector:
input_device : evdev.InputDevice
gamepad : bool
if ABS capabilities should be removed in favor of REL
Returns
-------
a mapping of int event type to an array of int event codes.
Without absinfo.
"""
ecodes = evdev.ecodes
@ -351,12 +356,18 @@ class Injector:
if ecodes.EV_FF in capabilities:
del capabilities[ecodes.EV_FF]
if gamepad and not self._forwards_joystick():
# key input to text inputs and such only works without ABS
# Key input to text inputs and such only works without ABS
# events in the capabilities, possibly due to some intentional
# constraints in wayland/X. So if the joysticks are not used
# as joysticks remove ABS.
del capabilities[ecodes.EV_ABS]
if ecodes.ABS_VOLUME in capabilities.get(ecodes.EV_ABS, []):
# For some reason an ABS_VOLUME capability likes to appear
# for some users. It prevents mice from moving around and
# keyboards from writing characters
capabilities[ecodes.EV_ABS].remove(ecodes.ABS_VOLUME)
return capabilities
async def _msg_listener(self):

@ -25,8 +25,8 @@ import copy
import evdev
from evdev.ecodes import EV_REL, EV_KEY, EV_ABS, ABS_HAT0X, BTN_LEFT, KEY_A, \
REL_X, REL_Y, REL_WHEEL, REL_HWHEEL, BTN_A, ABS_X, ABS_Y, BTN_NORTH,\
ABS_Z, ABS_RZ
REL_X, REL_Y, REL_WHEEL, REL_HWHEEL, BTN_A, ABS_X, ABS_Y, \
ABS_Z, ABS_RZ, ABS_VOLUME
from keymapper.dev.injector import is_numlock_on, set_numlock, \
ensure_numlock, Injector, is_in_capabilities, \
@ -784,14 +784,17 @@ class TestInjector(unittest.TestCase):
class TestModifyCapabilities(unittest.TestCase):
def setUp(self):
class FakeDevice:
def capabilities(self, absinfo=True):
assert absinfo is False
return {
def __init__(self):
self._capabilities = {
evdev.ecodes.EV_SYN: [1, 2, 3],
evdev.ecodes.EV_FF: [1, 2, 3],
evdev.ecodes.EV_ABS: [1, 2, 3]
}
def capabilities(self, absinfo=True):
assert absinfo is False
return self._capabilities
mapping = Mapping()
mapping.change(Key(EV_KEY, 80, 1), 'a')
mapping.change(Key(EV_KEY, 81, 1), DISABLE_NAME)
@ -851,6 +854,21 @@ class TestModifyCapabilities(unittest.TestCase):
# device type.
self.assertIn(evdev.ecodes.EV_ABS, capabilities)
def test_no_abs_volume(self):
# I don't know what ABS_VOLUME is, for now I would like to just always
# remove it until somebody complains
self.injector = Injector('foo', self.mapping)
self.fake_device._capabilities = {
EV_ABS: [ABS_Y, ABS_VOLUME, ABS_X]
}
capabilities = self.injector._modify_capabilities(
{60: self.macro},
self.fake_device,
gamepad=False
)
self.assertNotIn(ABS_VOLUME, capabilities[EV_ABS])
def test_modify_capabilities_gamepad(self):
config.set('gamepad.joystick.left_purpose', MOUSE)
self.mapping.set('gamepad.joystick.right_purpose', WHEEL)

Loading…
Cancel
Save