diff -ur gpm-1.99.2.2/src/daemon/cmdline.c gpm-1.99.2.2-patched/src/daemon/cmdline.c --- gpm-1.99.2.2/src/daemon/cmdline.c 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/daemon/cmdline.c 2008-03-25 22:59:16.000000000 +0100 @@ -32,7 +32,7 @@ void cmdline(int argc, char **argv) { extern struct options option; - char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV::23"; + char options[]="a:A::b:B:c:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV::23"; int opt; /* initialize for the dual mouse */ @@ -47,6 +47,7 @@ opt_age_limit = atoi(optarg); break; case 'b': (which_mouse->opt_baud) = atoi(optarg); break; case 'B': (which_mouse->opt_sequence) = optarg; break; + case 'c': (which_mouse->opt_calib) = optarg; break; case 'd': (which_mouse->opt_delta) = atoi(optarg); break; case 'D': option.run_status = GPM_RUN_DEBUG; break; case 'g': (which_mouse->opt_glidepoint_tap)=atoi(optarg); break; diff -ur gpm-1.99.2.2/src/daemon/gpm.c gpm-1.99.2.2-patched/src/daemon/gpm.c --- gpm-1.99.2.2/src/daemon/gpm.c 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/daemon/gpm.c 2008-03-25 21:14:32.000000000 +0100 @@ -73,9 +73,11 @@ struct mouse_features mouse_table[3] = { { - DEF_TYPE, DEF_DEV, DEF_SEQUENCE, + DEF_TYPE, DEF_DEV, DEF_SEQUENCE, DEF_CALIB, DEF_BAUD, DEF_SAMPLE, DEF_DELTA, DEF_ACCEL, DEF_SCALE, 0 /* scaley */, DEF_TIME, DEF_CLUSTER, DEF_THREE, DEF_GLIDEPOINT_TAP, + DEF_DMINX, DEF_DMAXX, DEF_DMINY, DEF_DMAXY, + DEF_OMINX, DEF_OMAXX, DEF_OMINY, DEF_OMAXY, (char *)NULL /* extra */, (Gpm_Type *)NULL, -1 diff -ur gpm-1.99.2.2/src/daemon/processmouse.c gpm-1.99.2.2-patched/src/daemon/processmouse.c --- gpm-1.99.2.2/src/daemon/processmouse.c 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/daemon/processmouse.c 2008-03-25 22:59:11.000000000 +0100 @@ -55,6 +55,8 @@ static struct timeval tv1={0,0}, tv2; /* tv1==0: first click is single */ static struct timeval timeout={0,0}; fd_set fdSet; + int tempx, tempy; + static int oldx, oldy; oldT = event->type; @@ -77,6 +79,12 @@ FD_ZERO(&fdSet); FD_SET(fd,&fdSet); + /* use uncalibrated values as base values */ + if((which_mouse->opt_calib!=NULL)&&(which_mouse->m_type->absolute)){ + nEvent.x = oldx; + nEvent.y = oldy; + } + do { /* cluster loop */ if(((data=getMouseData(fd, (which_mouse->m_type), kd_mode)) == NULL) || ((*((which_mouse->m_type)->fun))(&nEvent,data)==-1) ) { @@ -123,6 +131,31 @@ } while (i++ <(which_mouse->opt_cluster) && nEvent.buttons==oldB && FD_ISSET(fd,&fdSet)); + /* apply calibration */ + if((which_mouse->opt_calib!=NULL)&&(which_mouse->m_type->absolute)){ + /* save uncalibrated values for use next time around */ + oldx = nEvent.x; + oldy = nEvent.y; + + /* do calculations in a larger variable */ + tempx = nEvent.x; + tempy = nEvent.y; + tempx -= which_mouse->opt_dminx; + tempx *= ( which_mouse->opt_omaxx - which_mouse->opt_ominx ); + tempx /= ( which_mouse->opt_dmaxx - which_mouse->opt_dminx ); + tempx += which_mouse->opt_ominx; + + tempy -= which_mouse->opt_dminy; + tempy *= ( which_mouse->opt_omaxy - which_mouse->opt_ominy ); + tempy /= ( which_mouse->opt_dmaxy - which_mouse->opt_dminy ); + tempy += which_mouse->opt_ominy; + + nEvent.x = tempx; + nEvent.y = tempy; + + event->dx = (nEvent.x) - (event->x); + event->dy = (nEvent.y) - (event->y); + } } /* if(eventFlag) */ /*....................................... update the button number */ @@ -144,11 +177,63 @@ } rept1=rept2; - event->dy=event->dy*((win.ws_col/win.ws_row)+1); + /* if the values are calibrated, this is not necessary */ + if(which_mouse->opt_calib==NULL) + event->dy=event->dy*((win.ws_col/win.ws_row)+1); + event->x=nEvent.x; event->y=nEvent.y; } - repeated_type->repeat_fun(event, fifofd); /* itz Jan 11 1999 */ + + /* not all relative repeaters can handle big changes, + so repackage into several smaller updates */ + if (!repeated_type->absolute) { + int remx, remy; + remx = event->dx; + remy = event->dy; + + do { + if (remx<0) { + if (remx>=-127) { + event->dx = remx; + remx = 0; + } else { + event->dx = -127; + remx += 127; + } + } + if (remx>0) { + if (remx<=127) { + event->dx = remx; + remx = 0; + } else { + event->dx = 127; + remx -= 127; + } + } + if (remy<0) { + if (remy>=-127) { + event->dy = remy; + remy = 0; + } else { + event->dy = -127; + remy += 127; + } + } + if (remy>0) { + if (remy<=127) { + event->dy = remy; + remy = 0; + } else { + event->dy = 127; + remy -= 127; + } + } + repeated_type->repeat_fun(event, fifofd); + } while((remx!= 0)||(remy!=0)); + } + else + repeated_type->repeat_fun(event, fifofd); /* itz Jan 11 1999 */ } return 0; /* no events nor information for clients */ } /* first if of these three */ diff -ur gpm-1.99.2.2/src/daemon/startup.c gpm-1.99.2.2-patched/src/daemon/startup.c --- gpm-1.99.2.2/src/daemon/startup.c 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/daemon/startup.c 2008-03-25 21:51:07.000000000 +0100 @@ -36,6 +36,7 @@ void startup(int argc, char **argv) { int i, opt; + FILE* calib_file; static struct { char *in; @@ -104,6 +105,21 @@ (which_mouse->m_type) = find_mouse_by_name((which_mouse->opt_type)); if (!(which_mouse->m_type)) /* not found */ exit(M_listTypes()); + if (which_mouse->opt_calib!=NULL) { + calib_file = fopen(which_mouse->opt_calib,"r"); + if (calib_file) { + if (fscanf(calib_file, "%i %i %i %i %i %i %i %i", + &which_mouse->opt_dminx, &which_mouse->opt_dmaxx, &which_mouse->opt_dminy, &which_mouse->opt_dmaxy, + &which_mouse->opt_ominx, &which_mouse->opt_omaxx, &which_mouse->opt_ominy, &which_mouse->opt_omaxy)!= 8) + which_mouse->opt_calib = NULL; + if ((which_mouse->opt_dminx>=which_mouse->opt_dmaxx)|| + (which_mouse->opt_dminy>=which_mouse->opt_dmaxy)|| + (which_mouse->opt_ominx>=which_mouse->opt_omaxx)|| + (which_mouse->opt_ominy>=which_mouse->opt_omaxy)) + which_mouse->opt_calib = NULL; + } + fclose(calib_file); + } } /* Check repeater status */ diff -ur gpm-1.99.2.2/src/headers/daemon.h gpm-1.99.2.2-patched/src/headers/daemon.h --- gpm-1.99.2.2/src/headers/daemon.h 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/headers/daemon.h 2008-03-25 21:35:10.000000000 +0100 @@ -82,7 +82,8 @@ struct mouse_features { char *opt_type, *opt_dev, - *opt_sequence; + *opt_sequence, + *opt_calib; int opt_baud, opt_sample, opt_delta, @@ -92,7 +93,15 @@ opt_time, opt_cluster, opt_three, - opt_glidepoint_tap; + opt_glidepoint_tap, + opt_dminx, + opt_dmaxx, + opt_dminy, + opt_dmaxy, + opt_ominx, + opt_omaxx, + opt_ominy, + opt_omaxy; char *opt_options; /* extra textual configuration */ Gpm_Type *m_type; int fd; @@ -142,6 +151,7 @@ #define DEF_DEV NULL /* use the type-related one */ #define DEF_LUT "-a-zA-Z0-9_./\300-\326\330-\366\370-\377" #define DEF_SEQUENCE "123" /* how buttons are reordered */ +#define DEF_CALIB NULL /* don't load calibration data */ #define DEF_BAUD 1200 #define DEF_SAMPLE 100 #define DEF_DELTA 25 @@ -151,6 +161,16 @@ #define DEF_THREE 0 /* have three buttons? */ #define DEF_KERNEL 0 /* no kernel module, by default */ +#define DEF_DMINX 0 +#define DEF_DMAXX 1 +#define DEF_DMINY 0 +#define DEF_DMAXY 1 + +#define DEF_OMINX 0 +#define DEF_OMAXX 1 +#define DEF_OMINY 0 +#define DEF_OMAXY 1 + /* 10 on old computers (<=386), 0 on current machines */ #define DEF_CLUSTER 0 /* maximum number of clustered events */ diff -ur gpm-1.99.2.2/src/headers/gpmCfg.h gpm-1.99.2.2-patched/src/headers/gpmCfg.h --- gpm-1.99.2.2/src/headers/gpmCfg.h 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/headers/gpmCfg.h 2008-03-25 21:33:05.000000000 +0100 @@ -48,6 +48,7 @@ #define DEF_DEV NULL /* use the type-related one */ #define DEF_LUT "-a-zA-Z0-9_./\300-\326\330-\366\370-\377" #define DEF_SEQUENCE "123" /* how buttons are reordered */ +#define DEF_CALIB NULL /* don't load calibration data */ #define DEF_BAUD 1200 #define DEF_SAMPLE 100 #define DEF_DELTA 25 @@ -57,6 +58,16 @@ #define DEF_THREE 0 /* have three buttons? */ #define DEF_KERNEL 0 /* no kernel module, by default */ +#define DEF_DMINX 0 +#define DEF_DMAXX 1 +#define DEF_DMINY 0 +#define DEF_DMAXY 1 + +#define DEF_OMINX 0 +#define DEF_OMAXX 1 +#define DEF_OMINY 0 +#define DEF_OMAXY 1 + /* 10 on old computers (<=386), 0 on current machines */ #define DEF_CLUSTER 0 /* maximum number of clustered events */ diff -ur gpm-1.99.2.2/src/headers/message.h gpm-1.99.2.2-patched/src/headers/message.h --- gpm-1.99.2.2/src/headers/message.h 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/headers/message.h 2008-03-25 21:37:00.000000000 +0100 @@ -75,6 +75,7 @@ " -A [limit] start with selection disabled (`aged')\n" \ " -b baud-rate sets the baud rate (default %d)\n" \ " -B sequence allows changing the buttons (default '%s')\n" \ + " -c calib-file load calibration data for absolute devices from calib-file\n" \ " -d delta sets the delta value (default %d) (must be 2 or more)\n" \ " -D debug mode: don't auto-background\n" \ " -g tap-button sets the button (1-3) that is emulated by tapping on\n" \ diff -ur gpm-1.99.2.2/src/mice.c gpm-1.99.2.2-patched/src/mice.c --- gpm-1.99.2.2/src/mice.c 2008-03-17 17:31:07.000000000 +0100 +++ gpm-1.99.2.2-patched/src/mice.c 2008-03-25 21:45:16.000000000 +0100 @@ -140,6 +140,27 @@ } return 0; } + +static int M_evabs (Gpm_Event * state, unsigned char *data) +{ + struct input_event thisevent; + (void) memcpy (&thisevent, data, sizeof (struct input_event)); + if (thisevent.type == EV_ABS) { + if (thisevent.code == ABS_X) + state->x = thisevent.value; + else if (thisevent.code == ABS_Y) + state->y = thisevent.value; + } else if (thisevent.type == EV_KEY) { + switch(thisevent.code) { + case BTN_LEFT: state->buttons ^= GPM_B_LEFT; break; + case BTN_MIDDLE: state->buttons ^= GPM_B_MIDDLE; break; + case BTN_RIGHT: state->buttons ^= GPM_B_RIGHT; break; + case BTN_SIDE: state->buttons ^= GPM_B_MIDDLE; break; + case BTN_TOUCH: state->buttons ^= GPM_B_LEFT; break; + } + } + return 0; +} #endif /* HAVE_LINUX_INPUT_H */ static int M_ms_plus(Gpm_Event *state, unsigned char *data) @@ -2153,6 +2174,9 @@ {"evdev", "Linux Event Device", "", M_evdev, I_empty, STD_FLG, {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, + {"evabs", "Linux Event Device - absolute mode", + "", M_evabs, I_empty, STD_FLG, + {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 1, NULL}, #endif /* HAVE_LINUX_INPUT_H */ {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons, wheel unused", "ExplorerPS/2", M_imps2, I_exps2, STD_FLG,