From 7c313a31fd7e9e7c8a7bb7365de58156574f856c Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 26 Jul 2017 18:08:39 +0200 Subject: [PATCH] tools: ratbagctl: fixes for specials few minor issues which were unseen because driver-test was missing to set the special key mappings Signed-off-by: Benjamin Tissoires --- src/driver-test.c | 4 ++++ tools/ratbagctl.test.in | 9 +++------ tools/ratbagd.py | 38 +++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/driver-test.c b/src/driver-test.c index e86b7421..30748dda 100644 --- a/src/driver-test.c +++ b/src/driver-test.c @@ -127,6 +127,10 @@ test_read_button(struct ratbag_button *button) ratbag_button_copy_macro(button, m); ratbag_button_macro_unref(m); break; + case RATBAG_BUTTON_ACTION_TYPE_SPECIAL: + button->action.type = RATBAG_BUTTON_ACTION_TYPE_SPECIAL; + button->action.action.special = p->buttons[button->index].special; + break; default: button->action.type = RATBAG_BUTTON_ACTION_TYPE_UNKNOWN; } diff --git a/tools/ratbagctl.test.in b/tools/ratbagctl.test.in index 5909d047..aff7e672 100755 --- a/tools/ratbagctl.test.in +++ b/tools/ratbagctl.test.in @@ -375,8 +375,7 @@ class TestRatbgagCtlButton(TestRatbagCtl): r = self.launch_good_test("button 1 get test_device") self.assertEqual(r, "Button: 1 type middle is mapped to 'KEY_3'") r = self.launch_good_test("button 2 get test_device") - # FIXME: special maps to UNKNOWN???? - self.assertEqual(r, "Button: 2 type right is mapped to UNKNOWN") + 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.launch_fail_test("button 1 get 10 test_device") @@ -408,13 +407,11 @@ class TestRatbgagCtlButton(TestRatbagCtl): self.setProfile(2) command = "button 0 action set special " r = self.launch_good_test("button 0 action get test_device") - # FIXME: special maps to UNKNOWN???? - self.assertEqual(r, "Button: 0 type left is mapped to UNKNOWN")#'profile-cycle-up'") + self.assertEqual(r, "Button: 0 type left is mapped to 'profile-cycle-up'") r = self.launch_good_test(command + " second-mode test_device") self.assertEqual(r, '') r = self.launch_good_test("button 0 action get test_device") - # FIXME: special maps to UNKNOWN???? - self.assertEqual(r, "Button: 0 type left is mapped to UNKNOWN")#'second-mode'") + self.assertEqual(r, "Button: 0 type left is mapped to 'second-mode'") self.launch_fail_test(command) self.launch_fail_test(command + " X test_device") self.launch_fail_test(command + " 100 test_device X") diff --git a/tools/ratbagd.py b/tools/ratbagd.py index 289351cc..9b628fa8 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -440,25 +440,25 @@ class RatbagdButton(_RatbagdDBus): ACTION_TYPE_KEY = 3 ACTION_TYPE_MACRO = 4 - ACTION_SPECIAL_UNKNOWN = (1 << 30), - ACTION_SPECIAL_DOUBLECLICK = (1 << 30) + 1, - ACTION_SPECIAL_WHEEL_LEFT = (1 << 30) + 2, - ACTION_SPECIAL_WHEEL_RIGHT = (1 << 30) + 3, - ACTION_SPECIAL_WHEEL_UP = (1 << 30) + 4, - ACTION_SPECIAL_WHEEL_DOWN = (1 << 30) + 5, - ACTION_SPECIAL_RATCHET_MODE_SWITCH = (1 << 30) + 6, - ACTION_SPECIAL_RESOLUTION_CYCLE_UP = (1 << 30) + 7, - ACTION_SPECIAL_RESOLUTION_CYCLE_DOWN = (1 << 30) + 8, - ACTION_SPECIAL_RESOLUTION_UP = (1 << 30) + 9, - ACTION_SPECIAL_RESOLUTION_DOWN = (1 << 30) + 10, - ACTION_SPECIAL_RESOLUTION_ALTERNATE = (1 << 30) + 11, - ACTION_SPECIAL_RESOLUTION_DEFAULT = (1 << 30) + 12, - ACTION_SPECIAL_PROFILE_CYCLE_UP = (1 << 30) + 13, - ACTION_SPECIAL_PROFILE_CYCLE_DOWN = (1 << 30) + 14, - ACTION_SPECIAL_PROFILE_UP = (1 << 30) + 15, - ACTION_SPECIAL_PROFILE_DOWN = (1 << 30) + 16, - ACTION_SPECIAL_SECOND_MODE = (1 << 30) + 17, - ACTION_SPECIAL_BATTERY_LEVEL = (1 << 30) + 18, + ACTION_SPECIAL_UNKNOWN = (1 << 30) + ACTION_SPECIAL_DOUBLECLICK = (1 << 30) + 1 + ACTION_SPECIAL_WHEEL_LEFT = (1 << 30) + 2 + ACTION_SPECIAL_WHEEL_RIGHT = (1 << 30) + 3 + ACTION_SPECIAL_WHEEL_UP = (1 << 30) + 4 + ACTION_SPECIAL_WHEEL_DOWN = (1 << 30) + 5 + ACTION_SPECIAL_RATCHET_MODE_SWITCH = (1 << 30) + 6 + ACTION_SPECIAL_RESOLUTION_CYCLE_UP = (1 << 30) + 7 + ACTION_SPECIAL_RESOLUTION_CYCLE_DOWN = (1 << 30) + 8 + ACTION_SPECIAL_RESOLUTION_UP = (1 << 30) + 9 + ACTION_SPECIAL_RESOLUTION_DOWN = (1 << 30) + 10 + ACTION_SPECIAL_RESOLUTION_ALTERNATE = (1 << 30) + 11 + ACTION_SPECIAL_RESOLUTION_DEFAULT = (1 << 30) + 12 + ACTION_SPECIAL_PROFILE_CYCLE_UP = (1 << 30) + 13 + ACTION_SPECIAL_PROFILE_CYCLE_DOWN = (1 << 30) + 14 + ACTION_SPECIAL_PROFILE_UP = (1 << 30) + 15 + ACTION_SPECIAL_PROFILE_DOWN = (1 << 30) + 16 + ACTION_SPECIAL_SECOND_MODE = (1 << 30) + 17 + ACTION_SPECIAL_BATTERY_LEVEL = (1 << 30) + 18 MACRO_KEY_PRESS = 1 MACRO_KEY_RELEASE = 2