diff options
author | B. Watson <urchlay@slackware.uk> | 2025-05-11 05:39:43 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-05-11 05:39:43 -0400 |
commit | fe074451e1e993a3ab1b18ac29d434a18970d344 (patch) | |
tree | 62db4ab45e0014a57e73419ee453b0cffe15eaea /marsond.c | |
parent | a68d256cd2be29e63e8a2dd75522491bdab1cb75 (diff) | |
download | marsond-fe074451e1e993a3ab1b18ac29d434a18970d344.tar.gz |
improve --help and debugging output.
Diffstat (limited to 'marsond.c')
-rw-r--r-- | marsond.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -83,6 +83,10 @@ void print_help(void) { for(helpline = helptext; *helpline; helpline++) puts(*helpline); + + puts( "Compiled-in defaults:"); + puts( " -k: " DEFAULT_KBD); + printf(" -d: %d\n", DEFAULT_DELAY_MS); } void version(void) { @@ -276,6 +280,16 @@ void set_evbit(int outfd, int event) { } } +void print_device_name(void) { + char name[UINPUT_MAX_NAME_SIZE]; + + if(ioctl(outfd, UI_GET_SYSNAME(UINPUT_MAX_NAME_SIZE), name) >= 0) { + debug("created virtual keyboard device: /sys/devices/virtual/input/%s/", name); + } else { + debug("created virtual keyboard device but couldn't get its name (old kernel?)"); + } +} + int main(int argc, char **argv) { int i; struct uinput_user_dev dev; @@ -346,14 +360,7 @@ int main(int argc, char **argv) { /* I was hoping the return value of this ioctl would be the device number, but it's just 0 for no error. */ if(ioctl(outfd, UI_DEV_CREATE) >= 0) { - if(debugging) { - char name[UINPUT_MAX_NAME_SIZE]; - if(ioctl(outfd, UI_GET_SYSNAME(UINPUT_MAX_NAME_SIZE), name) >= 0) { - debug("created virtual keyboard device: /sys/devices/virtual/input/%s/", name); - } else { - debug("created virtual keyboard device but couldn't get its name (old kernel?)"); - } - } + if(debugging) print_device_name(); } else { die("UI_DEV_CREATE failed: %s", strerror(errno)); } @@ -383,7 +390,7 @@ int main(int argc, char **argv) { } if(foreground) { - debug("got event: type %d, code %d, value %d\n", + debug("got event: type %d, code %d, value %d", ev.type, ev.code, ev.value); } |