From 45bb7435e90ee03de8c4fef6b3f691ff1045d2f0 Mon Sep 17 00:00:00 2001 From: tissoire Date: Fri, 21 Dec 2007 13:27:59 +0000 Subject: mode relatif par defaut lors de l'utilisation de la wacom. on bascule en mode absolu avec les touches 11 et 15 (les grandes) de la cintiq. --- src/ivypointer.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ivypointer.c b/src/ivypointer.c index 5a6a76d..984ec43 100644 --- a/src/ivypointer.c +++ b/src/ivypointer.c @@ -65,6 +65,8 @@ #define WIDTH_WACOM 1600.0 #define HEIGHT_WACOM 1200.0 +#define TIME_CLICK 200 +#define TIME_BETWEEN_CLICK 200 Display* display = NULL; int width,height; @@ -72,6 +74,7 @@ float coords_input[4] = {0.0,0.0,100.0,100.0}; int width_input,height_input; int dragged = 0; +int relative = 1; Display* openDisplay(const char* displayName) @@ -270,21 +273,76 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[]) // char *id = argv[0]; float x = atof(argv[1]); float y = atof(argv[2]); + int time = atoi(argv[11]); int presure = atoi(argv[3]); + static float old_x = 0; + static float old_y = 0; + static int old_time = 0; + static int should_click = 0; + static int clicked = 0; if (dragged && presure==0){ - fakeMouseButton(1,0); - dragged = 0; + fakeMouseButton(1,0); + dragged = 0; } - if (!dragged && presure>0){ - fakeMouseButton(1,1); - dragged = 1; + if (!relative) { + if (!dragged && presure>0){ + fakeMouseButton(1,1); + dragged = 1; + } } // printf("x = %f,y = %f; ",x,y); if (valid(x,y)){ x = (x-coords_input[0])*width/width_input; y = (y-coords_input[1])*height/height_input; // printf("x = %f,y = %f\n",x,y); - fakeMouseMove((int)x,(int)y); + if (!relative) { + fakeMouseMove((int)x,(int)y); + } else { + int dx = (int)(x-old_x); + int dy = (int)(y-old_y); + int dt = time-old_time; +// if (old_time) +// printf("time=%d, old_time=%d, dt=%d\n",time, old_time, dt); + if (presure > 0) { + if (!should_click){ + old_time = time; + dt = 0; + should_click = 1; +// printf("armement du timeout\n"); + } else { + if (should_click ==1 && dt > TIME_CLICK){ + should_click = 2; +// printf("timeout\n"); + } + } + fakeMouseRelativeMove(dx,dy); + } else { + if (should_click == 1) { +// printf("dt = %d\n",dt); + if (clicked) { + //double click +// printf("ck\n"); + fakeMouseButton(1,0); + } +// printf("cli\n"); + clicked = 1; + old_time = time; + fakeMouseButton(1,1); + } + should_click = 0; + if (clicked) { + if (dt > TIME_BETWEEN_CLICK){ +// printf("ck\n"); + fakeMouseButton(1,0); + clicked = 0; + } + } else { + old_time = 0; + } + } + } + old_x = x; + old_y = y; // } else { // printf("bad event\n"); } @@ -293,10 +351,19 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[]) void CallbackPad (IvyClientPtr app, void *user_data, int argc, char *argv[]) { // char *id = argv[0]; int b = atoi(argv[1]); - int press = atoi(argv[2]); + int press = 0; // if (!b) // return - fakeMouseButton(b,press); + if (strcmp(argv[2],"up")){ + press = 1; + } +// printf("Pad button=%d pressed%d event received\n",b, press); + if (b==11 || b==15){ + //mode relatif + relative = !press; + } else { + fakeMouseButton(b,press); + } } void CallbackSlider (IvyClientPtr app, void *user_data, int argc, char *argv[]) { -- cgit v1.1