*/}}
Procházet zdrojové kódy

Slightly better stylus handling

YimingWu před 23 hodinami
rodič
revize
54ab0e2593
1 změnil soubory, kde provedl 17 přidání a 12 odebrání
  1. 17 12
      la_kernel.c

+ 17 - 12
la_kernel.c

@@ -157,6 +157,7 @@ void la_ScanWacomDevices(Display *display, int deviceid){
     int ndevices;
     int i; char * word;
     int LikelyPen=-1,LikelyEraser=-1;
+    char orig_name[1024];
 
     int _event, _error;
     if (!XQueryExtension(MAIN.dpy, "XInputExtension", &MAIN.xi_opcode, &_event, &_error)) {
@@ -165,11 +166,11 @@ void la_ScanWacomDevices(Display *display, int deviceid){
 
     info = XIQueryDevice(display, deviceid, &ndevices);
     for(i = 0; i < ndevices; i++) {
-        dev = &info[i]; strToLower(dev->name);
-        if (strstr(dev->name, "pen pen")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // some wacom tablets "wacom bamboo connect pen pen"
-        elif (strstr(dev->name, "stylus pen")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // some huion ones "HUION 256C PEN STYLUS Pen"
-        int is_ipts=0; if(strstr(dev->name, "ipts")){ is_ipts=1; }
-        word = strtok (dev->name," ");
+        dev = &info[i]; strcpy(orig_name,dev->name); strToLower(orig_name);
+        if (strstr(orig_name, "pen pen")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // some wacom tablets "wacom bamboo connect pen pen"
+        elif (strstr(orig_name, "stylus pen")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // some huion ones "HUION 256C PEN STYLUS Pen"
+        int is_ipts=0; if(strstr(orig_name, "ipts")){ is_ipts=1; }
+        word = strtok (orig_name," ");
         while (1) {
             word = strtok (NULL, " "); if (!word) break;
             if (strstr("stylus", word)){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// wacom
@@ -180,21 +181,25 @@ void la_ScanWacomDevices(Display *display, int deviceid){
         }
     }
     if(!MAIN.WacomDeviceStylus){
-        for(i = 0; i < ndevices; i++) {
-            dev = &info[i]; strToLower(dev->name);
-            if (strstr(dev->name, "stylus")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // xwayland reports "stylus:10" etc
+        for(i = 0; i < ndevices; i++) { dev = &info[i]; strcpy(orig_name,dev->name); strToLower(orig_name);
+            if (strstr(orig_name, "stylus")){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; } // xwayland reports "stylus:10" etc
         }
     }
     if(!MAIN.WacomDeviceStylus){
-        for(i = 0; i < ndevices; i++) { dev = &info[i];
+        for(i = 0; i < ndevices; i++) { dev = &info[i]; strcpy(orig_name,dev->name); strToLower(orig_name);
+            if(strstr(orig_name,"mouse")){ continue; }
             if(la_DeviceProbablyHasPressure(dev)){ MAIN.WacomDeviceStylus=dev->deviceid; break; } // generic stylus with unknown name
         }
     }
-    if(!MAIN.WacomDeviceEraser){
-        if (strstr(dev->name, "eraser")){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; } // xwayland reports "eraser:10" etc
+    if(!MAIN.WacomDeviceEraser){ 
+        for(i = 0; i < ndevices; i++) { dev = &info[i]; strcpy(orig_name,dev->name); strToLower(orig_name);
+            if (strstr(orig_name, "eraser")){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; } // xwayland reports "eraser:10" etc
+        }
     }
     if(!MAIN.WacomDeviceEraser){
-        for(i = 0; i < ndevices; i++) { dev = &info[i]; if(MAIN.WacomDeviceStylus == dev->deviceid) continue;
+        for(i = 0; i < ndevices; i++) { dev = &info[i]; strcpy(orig_name,dev->name); strToLower(orig_name);
+            if(MAIN.WacomDeviceStylus == dev->deviceid){ continue; }
+            if(strstr(orig_name,"mouse")){ continue; }
             if(la_DeviceProbablyHasPressure(dev)){ MAIN.WacomDeviceStylus=dev->deviceid;  break; } // generic eraser with unknown name
         }
     }