|
@@ -28,6 +28,7 @@
|
|
#include <X11/Xos.h>
|
|
#include <X11/Xos.h>
|
|
#include <X11/keysymdef.h>
|
|
#include <X11/keysymdef.h>
|
|
#include <X11/XKBlib.h>
|
|
#include <X11/XKBlib.h>
|
|
|
|
+#include <X11/extensions/XInput.h>
|
|
#include <X11/extensions/XInput2.h>
|
|
#include <X11/extensions/XInput2.h>
|
|
#include <X11/extensions/Xfixes.h>
|
|
#include <X11/extensions/Xfixes.h>
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
@@ -95,6 +96,17 @@ static void la_RegisterWacomEventMasks(Display *display, int deviceid, real* max
|
|
|
|
|
|
XIFreeDeviceInfo(dev);
|
|
XIFreeDeviceInfo(dev);
|
|
}
|
|
}
|
|
|
|
+int la_DeviceProbablyHasPressure(XIDeviceInfo* dev){
|
|
|
|
+ int axis=0;
|
|
|
|
+ for (int i = 0; i < dev->num_classes; i++) {
|
|
|
|
+ if (dev->classes[i]->type == XIValuatorClass){ axis++; }
|
|
|
|
+ }
|
|
|
|
+ return axis>=3;
|
|
|
|
+}
|
|
|
|
+#define LA_G_STYLUS(dev) \
|
|
|
|
+ (la_DeviceProbablyHasPressure(dev)&&(!MAIN.WacomDeviceStylus))
|
|
|
|
+#define LA_G_ERASER \
|
|
|
|
+ (!MAIN.WacomDeviceEraser)
|
|
void la_ScanWacomDevices(Display *display, int deviceid){
|
|
void la_ScanWacomDevices(Display *display, int deviceid){
|
|
XIDeviceInfo *info, *dev;
|
|
XIDeviceInfo *info, *dev;
|
|
int ndevices;
|
|
int ndevices;
|
|
@@ -107,15 +119,18 @@ void la_ScanWacomDevices(Display *display, int deviceid){
|
|
|
|
|
|
info = XIQueryDevice(display, deviceid, &ndevices);
|
|
info = XIQueryDevice(display, deviceid, &ndevices);
|
|
for(i = 0; i < ndevices; i++) {
|
|
for(i = 0; i < ndevices; i++) {
|
|
- dev = &info[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; }
|
|
int is_ipts=0; if(strstr(dev->name, "ipts")){ is_ipts=1; }
|
|
word = strtok (dev->name," ");
|
|
word = strtok (dev->name," ");
|
|
while (1) {
|
|
while (1) {
|
|
word = strtok (NULL, " "); if (!word) break;
|
|
word = strtok (NULL, " "); if (!word) break;
|
|
- if (strcmp("stylus", word) == 0) MAIN.WacomDeviceStylus = dev->deviceid; // wacom
|
|
|
|
- elif (strcmp("eraser", word) == 0) MAIN.WacomDeviceEraser = dev->deviceid; // wacom
|
|
|
|
- elif (is_ipts && strcmp("Pen", word) == 0) MAIN.WacomDeviceStylus = dev->deviceid; // surface ipts
|
|
|
|
- elif (is_ipts && strcmp("Eraser", word) == 0) MAIN.WacomDeviceEraser = dev->deviceid; // surface ipts
|
|
|
|
|
|
+ if (strcmp("stylus", word) == 0){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// wacom
|
|
|
|
+ elif (strcmp("eraser", word) == 0){ 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("eraser", word) == 0){ if(LA_G_ERASER) MAIN.WacomDeviceEraser = dev->deviceid; }// surface ipts
|
|
|
|
+ elif (strcmp("pen", word) == 0){ if(LA_G_STYLUS(dev)) MAIN.WacomDeviceStylus = dev->deviceid; }// generic pen
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(MAIN.WacomDeviceStylus || MAIN.WacomDeviceEraser){
|
|
if(MAIN.WacomDeviceStylus || MAIN.WacomDeviceEraser){
|