|
@@ -131,6 +131,7 @@ static void la_RegisterWacomEventMasks(Display *display, int deviceid, real* max
|
|
|
for (i = 0; i < dev->num_classes; i++) {
|
|
for (i = 0; i < dev->num_classes; i++) {
|
|
|
if (dev->classes[i]->type == XIValuatorClass) {
|
|
if (dev->classes[i]->type == XIValuatorClass) {
|
|
|
XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev->classes[i];
|
|
XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev->classes[i];
|
|
|
|
|
+ printf("%s\n",XGetAtomName(MAIN.dpy, v->label));
|
|
|
if(v->number==2){ *max_pressure=v->max; FoundMax=1; break; }
|
|
if(v->number==2){ *max_pressure=v->max; FoundMax=1; break; }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -141,15 +142,16 @@ static void la_RegisterWacomEventMasks(Display *display, int deviceid, real* max
|
|
|
|
|
|
|
|
XIFreeDeviceInfo(dev);
|
|
XIFreeDeviceInfo(dev);
|
|
|
}
|
|
}
|
|
|
-int la_DeviceProbablyHasPressure(XIDeviceInfo* dev){
|
|
|
|
|
- int axis=0;
|
|
|
|
|
|
|
+int la_DeviceHasPressure(XIDeviceInfo* dev){
|
|
|
for (int i = 0; i < dev->num_classes; i++) {
|
|
for (int i = 0; i < dev->num_classes; i++) {
|
|
|
- if (dev->classes[i]->type == XIValuatorClass){ axis++; }
|
|
|
|
|
|
|
+ if (dev->classes[i]->type == XIValuatorClass){ XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev->classes[i];
|
|
|
|
|
+ if(strSame(XGetAtomName(MAIN.dpy,v->label),"Abs Pressure")){ return 1; };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return axis>=3;
|
|
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
#define LA_G_STYLUS(dev) \
|
|
#define LA_G_STYLUS(dev) \
|
|
|
- (la_DeviceProbablyHasPressure(dev)&&(!MAIN.WacomDeviceStylus))
|
|
|
|
|
|
|
+ (la_DeviceHasPressure(dev)&&(!MAIN.WacomDeviceStylus))
|
|
|
#define LA_G_ERASER \
|
|
#define LA_G_ERASER \
|
|
|
(!MAIN.WacomDeviceEraser)
|
|
(!MAIN.WacomDeviceEraser)
|
|
|
void la_ScanWacomDevices(Display *display, int deviceid){
|
|
void la_ScanWacomDevices(Display *display, int deviceid){
|
|
@@ -173,36 +175,13 @@ void la_ScanWacomDevices(Display *display, int deviceid){
|
|
|
word = strtok (orig_name," ");
|
|
word = strtok (orig_name," ");
|
|
|
while (1) {
|
|
while (1) {
|
|
|
word = strtok (NULL, " "); if (!word) break;
|
|
word = strtok (NULL, " "); if (!word) break;
|
|
|
- if (strstr("stylus", word)){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// wacom
|
|
|
|
|
|
|
+ if (strstr("stylus", word)){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// wacom, also handles cases like stylus:10
|
|
|
elif (strstr("eraser", word)){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; }// wacom
|
|
elif (strstr("eraser", word)){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; }// wacom
|
|
|
elif (is_ipts && strcmp("pen", word) == 0){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// surface ipts
|
|
elif (is_ipts && strcmp("pen", word) == 0){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// surface ipts
|
|
|
elif (is_ipts && strcmp("eraser", word) == 0){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; }// surface ipts
|
|
elif (is_ipts && strcmp("eraser", word) == 0){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; }// surface ipts
|
|
|
elif (strstr("pen", word)){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// generic pen
|
|
elif (strstr("pen", word)){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// generic pen
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(!MAIN.WacomDeviceStylus){
|
|
|
|
|
- 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]; 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){
|
|
|
|
|
- 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]; 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
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
if(MAIN.WacomDeviceStylus || MAIN.WacomDeviceEraser){
|
|
if(MAIN.WacomDeviceStylus || MAIN.WacomDeviceEraser){
|
|
|
logPrintNew("Found wacom devices:\n");
|
|
logPrintNew("Found wacom devices:\n");
|
|
|
if(MAIN.WacomDeviceStylus) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceStylus,&MAIN.StylusMaxPressure);
|
|
if(MAIN.WacomDeviceStylus) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceStylus,&MAIN.StylusMaxPressure);
|