From 66b25c9c8303490e0510d59065e719603450cc3c Mon Sep 17 00:00:00 2001 From: workinghard Date: Sat, 22 Dec 2018 21:42:31 -0800 Subject: [PATCH] Ticket #9 specify special device --- src/jslisten.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/jslisten.c b/src/jslisten.c index 8369e48..9e0cd4f 100644 --- a/src/jslisten.c +++ b/src/jslisten.c @@ -64,6 +64,7 @@ // Global definitions //--------------------------------- char iniFile[INI_BUFFERSIZE]; +char myDevPath[NAME_LENGTH]; int joyFD; struct KeySet{ // Set Default unassigned @@ -391,7 +392,7 @@ void listenJoy (void) { sysPath = udev_device_get_syspath(mydev); devPath = udev_device_get_devnode(mydev); - if (sysPath != NULL && devPath != NULL && strstr(sysPath, "/js") != 0) { + if (sysPath != NULL && devPath != NULL && strstr(sysPath, myDevPath) != 0) { syslog(LOG_NOTICE, "Found Device: %s\n", devPath); if ((joyFD = open(devPath, O_RDONLY)) < 0) { // Open the file descriptor syslog(LOG_INFO, "error: failed to open fd\n"); @@ -566,10 +567,15 @@ int main(int argc, char* argv[]) { myKeys[i].isTriggered = false; } + // Default device path to check + strcpy(myDevPath, "/js"); + // Parse parameters to set debug level if ( argc > 1 ) { - if (strncmp(argv[1], "--debug", 7) == 0) { - logLevel = LOG_DEBUG; + for (int i=1;i 1 ) { + for (int i=1;i i+1 ) { + if ( strlen(argv[i+1]) < NAME_LENGTH ){ + strcpy(myDevPath, argv[i+1]); + syslog(LOG_NOTICE, "Using device path %s\n", myDevPath); + } + }else{ + syslog(LOG_NOTICE, "Missing device path parameter\n"); + } + } + } + } // Get the configuration file rc = getConfigFile(); if ( rc > 0 ) {