diff options
-rw-r--r-- | src/property.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/property.c b/src/property.c index 9641d21..c0edc88 100644 --- a/src/property.c +++ b/src/property.c @@ -428,7 +428,7 @@ do_set_prop_xi1(Display *dpy, Atom type, int format, unsigned int mode, int argc #if HAVE_XI2 static void -print_property_xi2(Display *dpy, int deviceid, Atom property) +print_property_xi2(Display *dpy, int deviceid, Atom property, Bool use_hex) { Atom act_type; char *name; @@ -460,13 +460,13 @@ print_property_xi2(Display *dpy, int deviceid, Atom property) switch(act_format) { case 8: - printf("%d", *((int8_t*)ptr)); + printf(use_hex ? "0x%x" : "%d", *((int8_t*)ptr)); break; case 16: - printf("%d", *((int16_t*)ptr)); + printf(use_hex ? "0x%x" : "%d", *((int16_t*)ptr)); break; case 32: - printf("%d", *((int32_t*)ptr)); + printf(use_hex ? "0x%x" : "%d", *((int32_t*)ptr)); break; } break; @@ -474,13 +474,13 @@ print_property_xi2(Display *dpy, int deviceid, Atom property) switch(act_format) { case 8: - printf("%u", *((uint8_t*)ptr)); + printf(use_hex ? "0x%x" : "%u", *((uint8_t*)ptr)); break; case 16: - printf("%u", *((uint16_t*)ptr)); + printf(use_hex ? "0x%x" : "%u", *((uint16_t*)ptr)); break; case 32: - printf("%u", *((uint32_t*)ptr)); + printf(use_hex ? "0x%x" : "%u", *((uint32_t*)ptr)); break; } break; @@ -542,6 +542,15 @@ list_props_xi2(Display *dpy, int argc, char** argv, char* name, char *desc) int nprops; Atom *props; int rc = EXIT_SUCCESS; + Bool use_hex = False; + + if (argc >= 1) { + if (strcmp(argv[0], "--hex") == 0) { + use_hex = True; + argv++; + argc--; + } + } if (argc == 0) { @@ -569,7 +578,7 @@ list_props_xi2(Display *dpy, int argc, char** argv, char* name, char *desc) printf("Device '%s':\n", info->name); while(nprops--) { - print_property_xi2(dpy, info->deviceid, props[nprops]); + print_property_xi2(dpy, info->deviceid, props[nprops], use_hex); } XFree(props); |