From 2e4aa5ee228708a9dcfa161eabc42e6d87dd8be2 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 7 Jun 2021 09:28:59 +0200 Subject: [PATCH] print the name of the stick --- functions/joyutils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/joyutils.c b/functions/joyutils.c index 000435b..a1b1083 100644 --- a/functions/joyutils.c +++ b/functions/joyutils.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include @@ -33,12 +34,17 @@ int joy_fd, foo; struct js_event js; int flag = 0; unsigned long debut; +char joy_name[128]; if( ( joy_fd = open(joy_device , O_RDONLY)) == -1 ) { fprintf(stderr, "%s: couldn't open %s\n", __func__, joy_device); exit(1); } +if (ioctl(joy_fd, JSIOCGNAME(sizeof(joy_name)), joy_name) < 0) + strncpy(joy_name, "Unknown", sizeof(joy_name)); +fprintf(stderr, "Name: \"%s\"\n", joy_name); + for (;;) { foo = read(joy_fd, &js, sizeof(struct js_event)); if ( ! flag ) {