From 623c53f1e4f38b7f1b164dfcb17e956c843811fa Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Wed, 23 Aug 2017 11:41:29 +0200 Subject: [PATCH] tools/ratbagctl.in: use RatbagdMacro to print the macro --- tools/ratbagctl.in | 16 +--------------- tools/ratbagctl.test.in | 10 +++++----- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index e7704128..68349eba 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -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: diff --git a/tools/ratbagctl.test.in b/tools/ratbagctl.test.in index 09f7502a..ee0272e8 100755 --- a/tools/ratbagctl.test.in +++ b/tools/ratbagctl.test.in @@ -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")