test for correct linux header keycode usage

This commit is contained in:
sezanzeb 2020-12-02 00:58:48 +01:00
parent 5e5784a28e
commit 6771e8d8dc
4 changed files with 9 additions and 5 deletions

View File

@ -31,7 +31,7 @@ Examples
-------- --------
r(3, k(a).w(10)): a <10ms> a <10ms> a r(3, k(a).w(10)): a <10ms> a <10ms> a
r(2, k(a).k(-)).k(b): a - a - b 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 macro : string
"r(3, k(a).w(10))" "r(3, k(a).w(10))"
"r(2, k(a).k(-)).k(b)" "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 handler : func
A function that accepts keycodes as the first parameter and the 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 key-press state as the second. 1 for down and 0 for up. The

View File

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

View File

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

View File

@ -33,8 +33,11 @@ class TestMapping(unittest.TestCase):
def test_populate_system_mapping(self): def test_populate_system_mapping(self):
mapping = populate_system_mapping() mapping = populate_system_mapping()
self.assertGreater(len(mapping), 100) 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) 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): def test_clone(self):
mapping1 = Mapping() mapping1 = Mapping()