Print feature names as we're initializing them

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-08-21 10:00:02 +10:00
parent 30698f8ee2
commit 5e19d4e536
3 changed files with 29 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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)
{

View File

@@ -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 */
/* -------------------------------------------------------------------------- */