From 7a9cd0a2ad46153ce3ed23c29ad4438edb807ea3 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Sun, 5 Jul 2020 03:56:44 +0800 Subject: [PATCH] input: fix: some BT devices(wiimote) don't have phys field, so use uniq field only. --- input.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/input.cpp b/input.cpp index 879b37e..04fccd7 100644 --- a/input.cpp +++ b/input.cpp @@ -2668,6 +2668,7 @@ void mergedevs() static char str[1024]; char phys[64] = {}; char uniq[64] = {}; + char id[64] = {}; while (fgets(str, sizeof(str), f)) { @@ -2684,10 +2685,14 @@ void mergedevs() if (!strncmp("P: Phys", str, 7)) snprintf(phys, sizeof(phys), "%s", strchr(str, '=') + 1); if (!strncmp("U: Uniq", str, 7)) snprintf(uniq, sizeof(uniq), "%s", strchr(str, '=') + 1); - if (!strncmp("H: ", str, 3) && phys[0]) + if (!strncmp("H: ", str, 3)) { + if (strlen(phys) && strlen(uniq)) snprintf(id, sizeof(id), "%s/%s", phys, uniq); + else if (strlen(phys)) strcpy(id, phys); + else strcpy(id, uniq); + char *handlers = strchr(str, '='); - if (handlers) + if (handlers && id[0]) { handlers++; for (int i = 0; i < NUMDEV; i++) @@ -2698,13 +2703,9 @@ void mergedevs() if (dev) { char idsp[32]; - strcpy(idsp, dev+1); + strcpy(idsp, dev + 1); strcat(idsp, " "); - if (strstr(handlers, idsp)) - { - if(uniq[0]) snprintf(input[i].id, sizeof(input[i].id), "%s/%s", phys, uniq); - else strcpy(input[i].id, phys); - } + if (strstr(handlers, idsp)) strcpy(input[i].id, id); } } }