From 5e19d4e536a09a401170cbc8249d7b6c37f0e2f8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 21 Aug 2015 10:00:02 +1000 Subject: [PATCH] Print feature names as we're initializing them Signed-off-by: Peter Hutterer --- src/driver-logitech-unifying.c | 4 +++- src/hidpp20.c | 24 ++++++++++++++++++++++++ src/hidpp20.h | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/driver-logitech-unifying.c b/src/driver-logitech-unifying.c index d812ed88..256adfe4 100644 --- a/src/driver-logitech-unifying.c +++ b/src/driver-logitech-unifying.c @@ -177,7 +177,9 @@ unifying_20_probe(struct ratbag_device *device, const struct ratbag_id id) if (rc > 0) { log_debug(device->ratbag, "'%s' has %d features\n", ratbag_device_get_name(device), rc); for (i = 0; i < rc; i++) { - log_debug(device->ratbag, "Init feature 0x%04x\n", feature_list[i].feature); + log_debug(device->ratbag, "Init feature %s (0x%04x) \n", + hidpp20_feature_get_name(feature_list[i].feature), + feature_list[i].feature); unifying_init_feature(device, feature_list[i].feature); } } diff --git a/src/hidpp20.c b/src/hidpp20.c index a5cfe35d..cfdb0ac7 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -40,6 +40,30 @@ #include "libratbag-util.h" #include "libratbag-private.h" +const char* +hidpp20_feature_get_name(uint16_t feature) +{ + static char numeric[8]; + const char *str; +#define CASE_RETURN_STRING(a) case a: return #a; break + + switch(feature) + { + CASE_RETURN_STRING(HIDPP_PAGE_ROOT); + CASE_RETURN_STRING(HIDPP_PAGE_FEATURE_SET); + CASE_RETURN_STRING(HIDPP_PAGE_MOUSE_POINTER_BASIC); + CASE_RETURN_STRING(HIDPP_PAGE_ADJUSTABLE_DPI); + CASE_RETURN_STRING(HIDPP_PAGE_SPECIAL_KEYS_BUTTONS); + default: + sprintf(numeric, "%#4x", feature); + str = numeric; + break; + } + +#undef CASE_RETURN_STRING + return str; +} + static int hidpp20_write_command(struct ratbag_device *device, uint8_t *cmd, int size) { diff --git a/src/hidpp20.h b/src/hidpp20.h index e5d3021f..fab05b7c 100644 --- a/src/hidpp20.h +++ b/src/hidpp20.h @@ -48,6 +48,8 @@ union hidpp20_message { int hidpp20_request_command(struct ratbag_device *device, union hidpp20_message *msg); +const char *hidpp20_feature_get_name(uint16_t feature); + /* -------------------------------------------------------------------------- */ /* 0x0000: Root */ /* -------------------------------------------------------------------------- */