diff --git a/ratbagd/ratbagd.c b/ratbagd/ratbagd.c index 25b2ce40..6a944b29 100644 --- a/ratbagd/ratbagd.c +++ b/ratbagd/ratbagd.c @@ -25,6 +25,8 @@ #include "config.h" +#include + #include #include #include @@ -201,7 +203,7 @@ static const struct ratbag_test_device ratbagd_test_device_descr = { { .type = RATBAG_BUTTON_ACTION_TYPE_BUTTON, .button = 0 }, { .type = RATBAG_BUTTON_ACTION_TYPE_KEY, - .key = 4 }, + .key = KEY_3 }, { .type = RATBAG_BUTTON_ACTION_TYPE_SPECIAL, .special = RATBAG_BUTTON_ACTION_SPECIAL_PROFILE_CYCLE_UP }, { .type = RATBAG_BUTTON_ACTION_TYPE_MACRO }, diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index ced2255a..67bf0525 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -23,6 +23,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import evdev import sys import argparse @@ -140,7 +141,15 @@ def print_button(d, p, b, level): if b.action_type == RatbagdButton.ACTION_TYPE_BUTTON: print("{}'button {}'".format(header, b.mapping)) elif b.action_type == RatbagdButton.ACTION_TYPE_KEY: - print("{}'{}'".format(header, b.key)) + bmap = "" + for m in b.key: + try: + code = evdev.ecodes.KEY[m] + except KeyError: + code = m + + bmap = bmap + "{}".format(code) + print("{}'{}'".format(header, bmap)) elif b.action_type == RatbagdButton.ACTION_TYPE_SPECIAL: print("{}'{}'".format(header, b.special)) elif b.action_type == RatbagdButton.ACTION_TYPE_MACRO: diff --git a/tools/ratbagctl.test.in b/tools/ratbagctl.test.in index 6d558359..8424f4b2 100755 --- a/tools/ratbagctl.test.in +++ b/tools/ratbagctl.test.in @@ -372,8 +372,7 @@ class TestRatbgagCtlButton(TestRatbagCtl): r = self.launch_good_test("button 0 get test_device") self.assertEqual(r, "Button: 0 type unknown is mapped to 'button 0'") r = self.launch_good_test("button 1 get test_device") - # FIXME: we should probably have keys here, not int - self.assertEqual(r, "Button: 1 type unknown is mapped to '[4]'") + self.assertEqual(r, "Button: 1 type unknown 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 unknown is mapped to UNKNOWN")