mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
tools: ratbagctl: fix printing of special key map
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
96067f18ca
commit
ae65ab3ae8
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/input-event-codes.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <libratbag.h>
|
||||
@@ -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 },
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user