|  | @@ -67,7 +67,7 @@ static void la_PrintWacomValuators(Display *display, XIAnyClassInfo **classes, i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -static void la_RegisterWacomEventMasks(Display *display, int deviceid)
 | 
	
		
			
				|  |  | +static void la_RegisterWacomEventMasks(Display *display, int deviceid, real* max_pressure)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	XIDeviceInfo *info, *dev;
 | 
	
		
			
				|  |  |  	int i, ndevices;
 | 
	
	
		
			
				|  | @@ -82,6 +82,15 @@ static void la_RegisterWacomEventMasks(Display *display, int deviceid)
 | 
	
		
			
				|  |  |  	XISetMask(mask->mask, XI_RawMotion);
 | 
	
		
			
				|  |  |      XISelectEvents(display, DefaultRootWindow(display), mask, 1);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    int FoundMax=0;
 | 
	
		
			
				|  |  | +    for (i = 0; i < dev->num_classes; i++) {
 | 
	
		
			
				|  |  | +        if (dev->classes[i]->type == XIValuatorClass) {
 | 
	
		
			
				|  |  | +            XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev->classes[i];
 | 
	
		
			
				|  |  | +            if(v->number==2){ *max_pressure=v->max; FoundMax=1; break; }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if(!FoundMax){*max_pressure=65535;}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	logPrint("    Device Name: '%s' (%d)\n", dev->name, dev->deviceid);
 | 
	
		
			
				|  |  |  	//la_PrintWacomValuators(display, dev->classes, dev->num_classes);
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -98,17 +107,20 @@ void la_ScanWacomDevices(Display *display, int deviceid){
 | 
	
		
			
				|  |  |      info = XIQueryDevice(display, deviceid, &ndevices);
 | 
	
		
			
				|  |  |      for(i = 0; i < ndevices; i++) {
 | 
	
		
			
				|  |  |          dev = &info[i];
 | 
	
		
			
				|  |  | +        printf("%s\n",dev->name);
 | 
	
		
			
				|  |  |          word = strtok (dev->name," ");
 | 
	
		
			
				|  |  |          while (1) {
 | 
	
		
			
				|  |  |              word = strtok (NULL, " "); if (!word) break;
 | 
	
		
			
				|  |  | -            if (strcmp("stylus", word) == 0) MAIN.WacomDeviceStylus = dev->deviceid;
 | 
	
		
			
				|  |  | -            elif (strcmp("eraser", word) == 0) MAIN.WacomDeviceEraser = dev->deviceid;
 | 
	
		
			
				|  |  | +            if (strcmp("stylus", word) == 0) MAIN.WacomDeviceStylus = dev->deviceid; // wacom
 | 
	
		
			
				|  |  | +            elif (strcmp("eraser", word) == 0) MAIN.WacomDeviceEraser = dev->deviceid; // wacom
 | 
	
		
			
				|  |  | +            elif (strcmp("Pen", word) == 0) MAIN.WacomDeviceStylus = dev->deviceid; // surface ipts
 | 
	
		
			
				|  |  | +            elif (strcmp("Eraser", word) == 0) MAIN.WacomDeviceEraser = dev->deviceid; // surface ipts
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if(MAIN.WacomDeviceStylus || MAIN.WacomDeviceEraser){
 | 
	
		
			
				|  |  |          logPrintNew("Found wacom devices:\n");
 | 
	
		
			
				|  |  | -        if(MAIN.WacomDeviceStylus) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceStylus);
 | 
	
		
			
				|  |  | -        if(MAIN.WacomDeviceEraser) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceEraser);
 | 
	
		
			
				|  |  | +        if(MAIN.WacomDeviceStylus) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceStylus,&MAIN.StylusMaxPressure);
 | 
	
		
			
				|  |  | +        if(MAIN.WacomDeviceEraser) la_RegisterWacomEventMasks(display, MAIN.WacomDeviceEraser,&MAIN.EraserMaxPressure);
 | 
	
		
			
				|  |  |  	}else{
 | 
	
		
			
				|  |  |          logPrintNew("No wacom pen device connected.\n");
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -6127,7 +6139,7 @@ static void la_RecordWacomMotions(XIRawEvent *event)
 | 
	
		
			
				|  |  |      //
 | 
	
		
			
				|  |  |      //printf("root: x %d y %d\n", win_x_return, win_y_return);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if(XIMaskIsSet(event->valuators.mask, 2)){ if(IsStylus) MAIN.StylusPressure=valuator[2]/65536; else MAIN.EraserPressure=valuator[2]/65536; }
 | 
	
		
			
				|  |  | +    if(XIMaskIsSet(event->valuators.mask, 2)){ if(IsStylus) MAIN.StylusPressure=valuator[2]/MAIN.StylusMaxPressure; else MAIN.EraserPressure=valuator[2]/MAIN.EraserMaxPressure; }
 | 
	
		
			
				|  |  |      if(XIMaskIsSet(event->valuators.mask, 3)){ if(IsStylus) MAIN.StylusAngleX=valuator[3]; else MAIN.EraserAngleX=valuator[3]; }
 | 
	
		
			
				|  |  |      if(XIMaskIsSet(event->valuators.mask, 4)){ if(IsStylus) MAIN.StylusAngleY=valuator[4]; else MAIN.EraserAngleY=valuator[4]; }
 | 
	
		
			
				|  |  |  
 |