Ticket #4731: wacom_filter.patch
File wacom_filter.patch, 2.5 KB (added by , 14 years ago) |
---|
-
src/add-ons/input_server/devices/wacom/TabletDevice.h
14 14 15 15 #include "PointingDevice.h" 16 16 17 #define MAX_FILTER_SAMPLES 4 18 17 19 class TabletDevice : public PointingDevice { 18 20 public: 19 21 TabletDevice(MasterServerDevice* parent, … … 108 110 109 111 float fJitterX; 110 112 float fJitterY; 113 114 float fFilterX[MAX_FILTER_SAMPLES]; 115 float fFilterY[MAX_FILTER_SAMPLES]; 111 116 }; 112 117 113 118 #endif // WACOM_TABLET_H -
src/add-ons/input_server/devices/wacom/TabletDevice.cpp
230 230 fMaxY = maxY; 231 231 fJitterX = JITTER_X; 232 232 fJitterY = JITTER_Y; 233 for (int i = 0; i < MAX_FILTER_SAMPLES; i++) { 234 fFilterX[i] = 0.0; 235 fFilterY[i] = 0.0; 236 } 233 237 } 234 238 235 239 // ReadData … … 427 431 float unfilteredY = y; 428 432 429 433 if (fHasContact) { 434 // apply a bit of filtering 435 for (int i = 0; i < MAX_FILTER_SAMPLES - 1; i++) { 436 fFilterX[i] = fFilterX[i + 1]; 437 fFilterY[i] = fFilterY[i + 1]; 438 x += fFilterX[i]; 439 y += fFilterY[i]; 440 } 441 fFilterX[MAX_FILTER_SAMPLES - 1] = unfilteredX; 442 fFilterY[MAX_FILTER_SAMPLES - 1] = unfilteredY; 443 x /= MAX_FILTER_SAMPLES; 444 y /= MAX_FILTER_SAMPLES; 445 430 446 deltaX = x - fPosX; 431 447 deltaY = y - fPosY; 432 448 433 449 absDeltaX = fabsf(deltaX); 434 450 absDeltaY = fabsf(deltaY); 435 436 #if 0 //DEBUG 437 fParent->LogString() << "x: " << x << ", y: " << y << ", pressure: " << pressure << "\n"; 438 fParent->LogString() << "tilt x: " << tiltX << ", tilt y: " << tiltY << "\n\n"; 439 #endif 440 // apply a bit of filtering 441 if (absDeltaX < fJitterX) 442 x = fPosX; 443 if (absDeltaY < fJitterY) 444 y = fPosY; 451 } else { 452 for (int i = 0; i < MAX_FILTER_SAMPLES; i++) { 453 fFilterX[i] = x; 454 fFilterY[i] = y; 455 } 445 456 } 446 457 447 458 // only do send message if something changed … … 468 479 // adjust mouse coordinates as well 469 480 // to have the mouse appear at the pens 470 481 // last position when switching 471 fFakeMouseX = unfilteredX;472 fFakeMouseY = unfilteredY;482 fFakeMouseX = x; 483 fFakeMouseY = y; 473 484 } else if (mode == MODE_MOUSE) { 474 485 // apply acceleration 475 486 float accelerationX = fJitterX * ACCELERATION_KICK_IN;