1
0
forked from drath/libratbag

tools/ratbagctl.in: use RatbagdMacro to print the macro

This commit is contained in:
Jente Hidskes
2017-08-23 11:41:29 +02:00
committed by Benjamin Tissoires
parent 39762718b9
commit 623c53f1e4
2 changed files with 6 additions and 20 deletions

View File

@@ -205,21 +205,7 @@ def print_button(d, p, b, level):
elif b.action_type == RatbagdButton.ACTION_TYPE_SPECIAL:
print("{}'{}'".format(header, button_specials_strmap[b.special]))
elif b.action_type == RatbagdButton.ACTION_TYPE_MACRO:
bmap = ""
for t, v in b.macro:
bt = 'unknown'
if t == RatbagdButton.MACRO_KEY_PRESS:
bt = '+'
bv = evdev.ecodes.KEY.get(v, v)
elif t == RatbagdButton.MACRO_KEY_RELEASE:
bt = '-'
bv = evdev.ecodes.KEY.get(v, v)
elif t == RatbagdButton.MACRO_WAIT:
bt = 't'
bv = v
bmap = bmap + "{}{} ".format(bt, bv)
print("{}macro '{}'".format(header, bmap[:-1]))
print("{}macro '{}'".format(header, str(b.macro)))
elif b.action_type == RatbagdButton.ACTION_TYPE_NONE:
print("{}none".format(header))
else:

View File

@@ -390,7 +390,7 @@ class TestRatbagCtlButton(TestRatbagCtl):
r = self.launch_good_test("button 2 get test_device")
self.assertEqual(r, "Button: 2 type right is mapped to 'profile-cycle-up'")
r = self.launch_good_test("button 3 get test_device")
self.assertEqual(r, "Button: 3 type unknown is mapped to macro '+KEY_B -KEY_B t300'")
self.assertEqual(r, "Button: 3 type unknown is mapped to macro '↕B 300ms'")
self.launch_fail_test("button 1 get 10 test_device")
self.launch_fail_test("button 10 get test_device")
self.launch_fail_test("button 1 get test_device X")
@@ -433,16 +433,16 @@ class TestRatbagCtlButton(TestRatbagCtl):
command = "button 2 action set macro "
self.launch_good_test(command + '+KEY_B KEY_A -KEY_B KEY_C test_device')
r = self.launch_good_test("button 2 get test_device")
self.assertEqual(r, "Button: 2 type right is mapped to macro '+KEY_B +KEY_A -KEY_A -KEY_B +KEY_C -KEY_C'")
self.assertEqual(r, "Button: 2 type right is mapped to macro '↓B ↕A ↑B ↕C'")
self.launch_good_test(command + 't100 t200 test_device')
r = self.launch_good_test("button 2 get test_device")
self.assertEqual(r, "Button: 2 type right is mapped to macro 't100 t200'")
self.assertEqual(r, "Button: 2 type right is mapped to macro '100ms 200ms'")
self.launch_good_test(command + 'KeY_z test_device')
r = self.launch_good_test("button 2 get test_device")
self.assertEqual(r, "Button: 2 type right is mapped to macro '+KEY_Z -KEY_Z'")
self.assertEqual(r, "Button: 2 type right is mapped to macro '↕Z'")
self.launch_good_test(command + ' test_device')
r = self.launch_good_test("button 2 get test_device")
self.assertEqual(r, "Button: 2 type right is mapped to macro ''")
self.assertEqual(r, "Button: 2 type right is mapped to macro 'None'")
self.launch_fail_test(command)
self.launch_fail_test(command + " KEY_A test_device X")