test for correct linux header keycode usage

xkb
sezanzeb 4 years ago committed by sezanzeb
parent e54d0b9ded
commit 8827e85023

@ -31,7 +31,7 @@ Examples
--------
r(3, k(a).w(10)): a <10ms> a <10ms> a
r(2, k(a).k(-)).k(b): a - a - b
w(1000).m(SHIFT_L, r(2, k(a))).w(10).k(b): <1s> A A <10ms> b
w(1000).m(Shift_L, r(2, k(a))).w(10).k(b): <1s> A A <10ms> b
"""
@ -280,7 +280,7 @@ def parse(macro, handler):
macro : string
"r(3, k(a).w(10))"
"r(2, k(a).k(-)).k(b)"
"w(1000).m(SHIFT_L, r(2, k(a))).w(10, 20).k(b)"
"w(1000).m(Shift_L, r(2, k(a))).w(10, 20).k(b)"
handler : func
A function that accepts keycodes as the first parameter and the
key-press state as the second. 1 for down and 0 for up. The

@ -70,6 +70,7 @@ def get_selected_row_bg():
# TODO show if the preset is being injected
# apply button -> stop button. makes "Apply Defaults" obsolete
class Window:

@ -220,7 +220,7 @@ class TestInjector(unittest.TestCase):
self.assertAlmostEqual(history[-2][2], -1)
def test_injector(self):
custom_mapping.change(8, 'k(q).k(w)')
custom_mapping.change(8, 'k(KEY_Q).k(w)')
custom_mapping.change(9, 'a')
# one mapping that is unknown in the system_mapping on purpose
custom_mapping.change(10, 'b')
@ -230,7 +230,7 @@ class TestInjector(unittest.TestCase):
code_q = 101
code_w = 102
system_mapping['a'] = code_a
system_mapping['q'] = code_q
system_mapping['KEY_Q'] = code_q
system_mapping['w'] = code_w
# the second arg of those event objects is 8 lower than the

@ -33,8 +33,11 @@ class TestMapping(unittest.TestCase):
def test_populate_system_mapping(self):
mapping = populate_system_mapping()
self.assertGreater(len(mapping), 100)
# keycode 10 is typically mapped to '1'
# xkb keycode 10 is typically mapped to '1'
self.assertEqual(mapping['1'], 10)
# linux keycodes are properly increased to the xkb keycodes
self.assertEqual(mapping['KEY_1'], 10)
self.assertEqual(mapping['KEY_LEFTSHIFT'], mapping['Shift_L'])
def test_clone(self):
mapping1 = Mapping()

Loading…
Cancel
Save