From c99b62efc4618ac5a0474ddb3ed17d7b8b2c2081 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 7 Nov 2024 16:56:04 +1000 Subject: [PATCH 1/3] tools/list-local-devices: fix and improve indentation of the yaml output This provides a more consistent 2 space indent across the output. Previously it was mixed with no indent or "other". --- tools/list-local-devices.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/list-local-devices.c b/tools/list-local-devices.c index b6fa8538..01c0c3d9 100644 --- a/tools/list-local-devices.c +++ b/tools/list-local-devices.c @@ -103,7 +103,7 @@ print_devnode(gpointer data, gpointer user_data) g_free(basename); if (g_file_get_contents(path, &name, &size, &error)) { - printf(" - %s: '%.*s'\n", devnode, (int)(size - 1), name); + printf(" - %s: '%.*s'\n", devnode, (int)(size - 1), name); } else { fprintf(stderr, "%s\n", error->message); } @@ -134,15 +134,15 @@ tablet_print_yaml(gpointer data, gpointer user_data) break; } - printf("- name: '%s'\n", name); - printf(" bus: '%s'\n", bus); - printf(" vid: '0x%04x'\n", vid); - printf(" pid: '0x%04x'\n", pid); - printf(" nodes: \n"); + printf(" - name: '%s'\n", name); + printf(" bus: '%s'\n", bus); + printf(" vid: '0x%04x'\n", vid); + printf(" pid: '0x%04x'\n", pid); + printf(" nodes: \n"); g_list_foreach(d->nodes, print_devnode, NULL); styli = libwacom_get_styli(d->dev, &nstyli); - printf(" styli:%s\n", nstyli > 0 ? "" : " []"); + printf(" styli:%s\n", nstyli > 0 ? "" : " []"); for (int i = 0; i < nstyli; i++) { const WacomStylus *stylus = styli[i]; const char *type = "invalid"; @@ -166,16 +166,16 @@ tablet_print_yaml(gpointer data, gpointer user_data) case WSTYLUS_3D: type = "3D"; break; case WSTYLUS_MOBILE: type = "mobile"; break; } - printf(" - id: 0x%x\n", libwacom_stylus_get_id(stylus)); - printf(" name: '%s'\n", libwacom_stylus_get_name(stylus)); - printf(" type: '%s'\n", type); - printf(" axes: ['x', 'y' %s%s%s%s%s]\n", + printf(" - id: 0x%x\n", libwacom_stylus_get_id(stylus)); + printf(" name: '%s'\n", libwacom_stylus_get_name(stylus)); + printf(" type: '%s'\n", type); + printf(" axes: ['x', 'y' %s%s%s%s%s]\n", axes & WACOM_AXIS_TYPE_TILT ? ", 'tilt'" : "", axes & WACOM_AXIS_TYPE_ROTATION_Z ? ", 'rotation'" : "", axes & WACOM_AXIS_TYPE_DISTANCE ? ", 'distance'" : "", axes & WACOM_AXIS_TYPE_PRESSURE ? ", 'pressure'" : "", axes & WACOM_AXIS_TYPE_SLIDER ? ", 'slider'" : ""); - printf(" buttons: %d\n", libwacom_stylus_get_num_buttons(stylus)); + printf(" buttons: %d\n", libwacom_stylus_get_num_buttons(stylus)); switch (eraser_type) { case WACOM_ERASER_UNKNOWN: etype = "unknown"; break; @@ -185,10 +185,10 @@ tablet_print_yaml(gpointer data, gpointer user_data) } if (libwacom_stylus_is_eraser(stylus)) { - printf(" is_eraser: 'true'\n"); - printf(" eraser_type: '%s'\n", etype); + printf(" is_eraser: 'true'\n"); + printf(" eraser_type: '%s'\n", etype); } else { - printf(" erasers: ["); + printf(" erasers: ["); if (libwacom_stylus_has_eraser(stylus)) { int npaired; const WacomStylus **paired = libwacom_stylus_get_paired_styli(stylus, &npaired); From 18ca640910a1b431444663a2b81704fd78c957ba Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 8 Nov 2024 08:03:46 +1000 Subject: [PATCH 2/3] tools/list-local-devices: print the stylus VID as well --- tools/list-local-devices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/list-local-devices.c b/tools/list-local-devices.c index 01c0c3d9..a90fa401 100644 --- a/tools/list-local-devices.c +++ b/tools/list-local-devices.c @@ -167,6 +167,7 @@ tablet_print_yaml(gpointer data, gpointer user_data) case WSTYLUS_MOBILE: type = "mobile"; break; } printf(" - id: 0x%x\n", libwacom_stylus_get_id(stylus)); + printf(" vid: 0x%04x\n", libwacom_stylus_get_vendor_id(stylus)); printf(" name: '%s'\n", libwacom_stylus_get_name(stylus)); printf(" type: '%s'\n", type); printf(" axes: ['x', 'y' %s%s%s%s%s]\n", From 159cc69510aa5837554986a3b7f96ec994a51083 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 11 Nov 2024 09:22:42 +1000 Subject: [PATCH 3/3] tools/list-local-devices: print vid/pid as number YAML does upport hex so let's print it as normal number to make for easier parsing --- tools/list-local-devices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/list-local-devices.c b/tools/list-local-devices.c index a90fa401..361ac3f7 100644 --- a/tools/list-local-devices.c +++ b/tools/list-local-devices.c @@ -136,8 +136,8 @@ tablet_print_yaml(gpointer data, gpointer user_data) printf(" - name: '%s'\n", name); printf(" bus: '%s'\n", bus); - printf(" vid: '0x%04x'\n", vid); - printf(" pid: '0x%04x'\n", pid); + printf(" vid: 0x%04x\n", vid); + printf(" pid: 0x%04x\n", pid); printf(" nodes: \n"); g_list_foreach(d->nodes, print_devnode, NULL);