diff -u gpm-1.20.1-orig/src/mice.c gpm-1.20.1-flybook/src/mice.c --- gpm-1.20.1-orig/src/mice.c 2002-12-25 00:57:16.000000000 +0200 +++ gpm-1.20.1-flybook/src/mice.c 2005-02-13 15:02:01.970790080 +0200 @@ -53,6 +53,7 @@ #include #include +#include #include /* stat() */ #include /* select() */ @@ -233,18 +234,34 @@ /*========================================================================*/ #ifdef HAVE_LINUX_INPUT_H + +struct input_absinfo absinfo_x; +struct input_absinfo absinfo_y; + +#define EV_TO_XCELL(x) ((x - absinfo_x.minimum) * win.ws_col / absinfo_x.maximum) +#define EV_TO_YCELL(y) ((y - absinfo_y.minimum) * win.ws_row / absinfo_y.maximum) + static int M_evdev (Gpm_Event * state, unsigned char *data) { struct input_event thisevent; + + (void) memcpy (&thisevent, data, sizeof (struct input_event)); if (thisevent.type == EV_REL) { if (thisevent.code == REL_X) state->dx = (signed char) thisevent.value; else if (thisevent.code == REL_Y) state->dy = (signed char) thisevent.value; + } else if (thisevent.type == EV_ABS) { + if(thisevent.code == ABS_X) { + state->x = (signed short) EV_TO_XCELL(thisevent.value); + } else if(thisevent.code == ABS_Y) { + state->y = (signed short) EV_TO_YCELL(thisevent.value); + } } else if (thisevent.type == EV_KEY) { switch(thisevent.code) { case BTN_LEFT: state->buttons ^= GPM_B_LEFT; break; + case BTN_TOUCH: 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; @@ -705,6 +722,66 @@ return 0; } +#ifdef HAVE_LINUX_INPUT_H + +/* this macro is used to tell if "bit" is set in "array" + * it selects a byte from the array, and does a boolean AND + * operation with a byte that only has the relevant bit set. + * eg. to check for the 12th bit, we do (array[1] & 1<<4) + */ +#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) + +/* Linux generic event device */ +static Gpm_Type *I_evdev(int fd, unsigned short flags, + struct Gpm_Type *type, int argc, char **argv) +{ + + unsigned char evtype_bitmask[EV_MAX/8 + 1]; + + if(ioctl(fd, EVIOCGBIT(0, sizeof(evtype_bitmask)), evtype_bitmask) < 0) { + + } + + if(test_bit(EV_ABS, evtype_bitmask)) { + unsigned char abs_bitmask[ABS_MAX/8 + 1]; + + memset(abs_bitmask, 0, sizeof(abs_bitmask)); + if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) < 0) { + + } + + if(test_bit(ABS_X, abs_bitmask)) { + if(ioctl(fd, EVIOCGABS(ABS_X), &absinfo_x)) { + + } + printf("(min: %d, max: %d, flatness: %d, fuzz: %d)\n", + absinfo_x.minimum, + absinfo_x.maximum, + absinfo_x.flat, + absinfo_x.fuzz); + + type->absolute = 1; + } + if(test_bit(ABS_Y, abs_bitmask)) { + /* this means that the bit is set in the axes list */ + if(ioctl(fd, EVIOCGABS(ABS_Y), &absinfo_y)) { + perror("evdev EVIOCGABS ioctl"); + } + printf("(min: %d, max: %d, flatness: %d, fuzz: %d)\n", + absinfo_y.minimum, + absinfo_y.maximum, + absinfo_y.flat, + absinfo_y.fuzz); + type->absolute = 1; + + } + } + + return type; +} + +#endif + /* standard ps2 */ static Gpm_Type *I_ps2(int fd, unsigned short flags, struct Gpm_Type *type, int argc, char **argv) @@ -2241,7 +2318,7 @@ {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 0, 0}, #ifdef HAVE_LINUX_INPUT_H {"evdev", "Linux Event Device", - "", M_evdev, I_empty, STD_FLG, + "", M_evdev, I_evdev, STD_FLG, {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, #endif /* HAVE_LINUX_INPUT_H */ {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons, wheel unused",