imwheel.patch
来自「gpm-1.20.0.tar.gz」· PATCH 代码 · 共 1,225 行 · 第 1/4 页
PATCH
1,225 行
+ printf("mouse: event 0x%02X, at %2i,%2i (delta %2i,%2i), (stick %2i,%2i), " "buttons %i, modifiers 0x%02X\r\n", event->type, event->x, event->y, event->dx, event->dy,+ event->stick_x, event->stick_y, event->buttons, event->modifiers); if (event->type & (GPM_DRAG|GPM_DOWN)) {Only in ../imwheel/gpm-imwheel: mev.c.origdiff -ru --exclude=Makefile ./mice.c ../imwheel/gpm-imwheel/mice.c--- ./mice.c Fri Nov 12 08:27:37 1999+++ ../imwheel/gpm-imwheel/mice.c Sun Feb 27 16:43:42 2000@@ -6,6 +6,9 @@ * Copyright (C) 1994-1999 Alessandro Rubini <rubini@linux.it> * Copyright (C) 1998,1999 Ian Zimmerman <itz@rahul.net> *+ * Modified on 9/8/1998 by Jonathan Atkins for use with wheel mice+ * <jcatki@home.com>+ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or@@ -83,7 +86,9 @@ static unsigned char prev=0; if (data[0] == 0x40 && !(prev|data[1]|data[2]))- state->buttons = GPM_B_MIDDLE; /* third button on MS compatible mouse */+ { /* third button on MS compatible mouse */+ state->buttons = (opt_nomiddle?0:GPM_B_MIDDLE);+ } else state->buttons= ((data[0] & 0x20) >> 3) | ((data[0] & 0x10) >> 4); prev = state->buttons;@@ -103,11 +108,14 @@ /* Allow motion *and* button change (Michael Plass) */ - if ((state->dx==0) && (state->dy==0) - && (state->buttons == (prev&~GPM_B_MIDDLE)))- state->buttons = prev^GPM_B_MIDDLE; /* no move or change: toggle middle */- else- state->buttons |= prev&GPM_B_MIDDLE; /* change: preserve middle */+ if(!opt_nomiddle)+ {+ if ((state->dx==0) && (state->dy==0) + && (state->buttons == (prev&~GPM_B_MIDDLE)))+ state->buttons = prev^GPM_B_MIDDLE; /* no move or change: toggle middle */+ else+ state->buttons |= prev&GPM_B_MIDDLE; /* change: preserve middle */+ } prev=state->buttons; @@ -127,11 +135,14 @@ /* Allow motion *and* button change (Michael Plass) */ - if ((state->dx==0) && (state->dy==0) - && (state->buttons == (prev&~GPM_B_MIDDLE)))- state->buttons = prev^GPM_B_MIDDLE; /* no move or change: toggle middle */- else- state->buttons |= prev&GPM_B_MIDDLE; /* change: preserve middle */+ if(!opt_nomiddle)+ {+ if ((state->dx==0) && (state->dy==0) + && (state->buttons == (prev&~GPM_B_MIDDLE)))+ state->buttons = prev^GPM_B_MIDDLE; /* no move or change: toggle middle */+ else+ state->buttons |= prev&GPM_B_MIDDLE; /* change: preserve middle */+ } /* Allow the user to reset state of middle button by pressing the other two buttons at once (Edmund GRIMLEY EVANS) */@@ -227,7 +238,11 @@ { state->buttons= ((data[0] & 0x20) >> 3) /* left */ | ((data[3] & 0x10) >> 3) /* middle */- | ((data[0] & 0x10) >> 4); /* right */+ | ((data[0] & 0x10) >> 4) /* right */+ | (((data[3] & 0x0f) == 0x0f)?GPM_W_UP:0) /* wheel up */+ | (((data[3] & 0x0f) == 0x01)?GPM_W_DOWN:0) /* wheel down */+ | (((data[3] & 0x0f) == 0x0e)?GPM_W_LEFT:0) /* wheel left */+ | (((data[3] & 0x0f) == 0x02)?GPM_W_RIGHT:0); /* wheel right */ state->dx= (signed char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); state->dy= (signed char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); /* wheel (dz??) is (data[3] & 0x0f) */@@ -240,7 +255,11 @@ { state->buttons= ((data[0] & 0x20) >> 3) /* left */ | ((data[3] & 0x20) >> 4) /* middle */- | ((data[0] & 0x10) >> 4); /* right */+ | ((data[0] & 0x10) >> 4) /* right */+ | (((data[3] & 0x0f) == 0x0f)?GPM_W_UP:0) /* wheel up */+ | (((data[3] & 0x0f) == 0x01)?GPM_W_DOWN:0) /* wheel down */+ | (((data[3] & 0x0f) == 0x0e)?GPM_W_LEFT:0) /* wheel left */+ | (((data[3] & 0x0f) == 0x02)?GPM_W_RIGHT:0); /* wheel right */ state->dx= (signed char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); state->dy= (signed char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); if (((data[0]&0xC0) != 0x40)||@@ -334,15 +353,39 @@ { static int tap_active=0; /* there exist glidepoint ps2 mice */ + state->stick_x=state->stick_y=0; state->buttons=- !!(data[0]&1) * GPM_B_LEFT +- !!(data[0]&2) * GPM_B_RIGHT +- !!(data[0]&4) * GPM_B_MIDDLE;+ !!(data[0]&1) * GPM_B_LEFT |+ !!(data[0]&2) * GPM_B_RIGHT |+ (opt_nomiddle?0:!!(data[0]&4) * GPM_B_MIDDLE); + if(data[0]&0xc0)+ {+ state->buttons|=GPM_STICK;+ state->stick_x=(data[2]&0x0F)<<28>>28;+ state->stick_y=(data[2]>>4)<<28>>28;+ gpm_debug_log(LOG_DEBUG,"Stick: %d %d\n",state->stick_x,state->stick_y);+ }+ else+ state->buttons|=((data[3]==0xff) ? GPM_W_UP : 0) | /* wheel up */+ ((data[3]==0x01) ? GPM_W_DOWN : 0) | /* wheel down */+ ((data[3]==0x0e) ? GPM_W_LEFT : 0) | /* wheel left */+ ((data[3]==0xfe) ? GPM_W_LEFT : 0) | /* wheel left:a4tech*/+ ((data[3]==0x02) ? GPM_W_RIGHT : 0); /* wheel right */+ gpm_debug_log(LOG_DEBUG,"Buttons: %d %d %d (%d %d %d %d) (%d)\n",+ (state->buttons&GPM_B_LEFT),+ (state->buttons&GPM_B_MIDDLE),+ (state->buttons&GPM_B_RIGHT),+ (state->buttons&GPM_W_UP),+ (state->buttons&GPM_W_DOWN),+ (state->buttons&GPM_W_LEFT),+ (state->buttons&GPM_W_RIGHT),+ (state->buttons&GPM_STICK));+ gpm_debug_log(LOG_DEBUG,"wheel? %d\n",opt_wheel); if (data[0]==0 && opt_glidepoint_tap) /* by default this is false */ state->buttons = tap_active = opt_glidepoint_tap; else if (tap_active)- if (data[0]==8)+ if (data[0]==8 && !opt_wheel) state->buttons = tap_active = 0; else state->buttons = tap_active; @@ -353,11 +396,11 @@ * rate is set to a reasonable value; the default of 100 Hz is plenty. * (Stephen Tell) */- if(data[1] != 0)+ if(data[1] != 0 && !(data[0]&0xc0)) state->dx= (data[0] & 0x10) ? data[1]-256 : data[1]; else state->dx = 0;- if(data[2] != 0)+ if(data[2] != 0 && !(data[0]&0xc0)) state->dy= -((data[0] & 0x20) ? data[2]-256 : data[2]); else state->dy = 0;@@ -389,7 +432,7 @@ state->buttons= !!(data[0]&1) * GPM_B_LEFT + !!(data[0]&2) * GPM_B_RIGHT +- !!(data[3]) * GPM_B_MIDDLE;+ (opt_nomiddle?0:!!(data[3]) * GPM_B_MIDDLE); if(data[1] != 0) state->dx= (data[0] & 0x10) ? data[1]-256 : data[1];@@ -513,7 +556,7 @@ ((data[0] & 32)? ((z) ? GPM_B_LEFT :0) /* graphire stylus */ : ((data[3] & 8)? GPM_B_LEFT :0)) /* graphire mouse */ + ((data[3] & 16)? GPM_B_RIGHT :0) - + ((data[3] & 32)? GPM_B_MIDDLE :0);+ + ((data[3] & 32) && !opt_nomiddle? GPM_B_MIDDLE :0); state->dx = (x-ox); state->dy = (y-oy); /* divide by 5, 'cause it's too much sensitive */@@ -666,12 +709,13 @@ switch (message & TW_ANY1) { case TW_L1: state->buttons = GPM_B_RIGHT; break;- case TW_M1: state->buttons = GPM_B_MIDDLE; break;- case TW_R1: state->buttons = GPM_B_LEFT; break;- case 0: state->buttons = 0; break;+ case TW_M1: state->buttons = (opt_nomiddle?0:GPM_B_MIDDLE);+ break;+ case TW_R1: state->buttons = GPM_B_LEFT; break;+ case 0: state->buttons = 0; break; } /* also, allow R1 R2 R3 (or L1 L2 L3) to be used as mouse buttons */- if (message & TW_ANY2)+ if ((message & TW_ANY2) && !opt_nomiddle) state->buttons |= GPM_B_MIDDLE; if (message & TW_L3) state->buttons |= GPM_B_LEFT;@@ -1011,11 +1055,12 @@ static Gpm_Type* I_serial(int fd, unsigned short flags, struct Gpm_Type *type) {- int i; unsigned char c;+ int i;+#ifndef DEBUG+ unsigned char c; fd_set set; struct timeval timeout={0,0}; /* used when not debugging */ -#ifndef DEBUG /* flush any pending input (thanks, Miguel) */ FD_ZERO(&set); for(i=0; /* always */ ; i++)@@ -1186,6 +1231,7 @@ * the vendor name: it is only propaganda, with no information. */ + opt_wheel=type->wheel; return type; } @@ -1199,9 +1245,221 @@ write (fd, s2, sizeof (s2)); usleep (30000); tcflush (fd, TCIFLUSH);+ opt_wheel=1;+ return type;+}++/* MouseManPlus, ps2 version: Jon Atkins (XFree86 & hacking!) */+static Gpm_Type *I_mmplusps2(int fd, unsigned short flags, struct Gpm_Type *type)+{+ static unsigned char s1[] = { 0xe6,0xe8,0,0xe8,3,0xe8,2,0xe8,1,0xe6,0xe8,3,0xe8,1,0xe8,2,0xe8,3, };+ //static unsigned char s2[] = { 246, 230, 244, 243, 100, 232, 3, };+ write (fd, s1, sizeof (s1));+ sleep(1);+ //usleep (30000);+ //write (fd, s2, sizeof (s2));+ //usleep (30000);+ tcflush (fd, TCIFLUSH);+ opt_wheel=1; return type; } +/* Logitech Trackman Marblefx routine by Ric Klaren <klaren@cs.utwente.nl> */+static int M_marblefx(Gpm_Event *state, unsigned char *data)+{+ static unsigned int wheel = 0; /* for state machine */++ state->buttons = !!(data[0]&1) * GPM_B_LEFT |+ !!(data[0]&2) * GPM_B_RIGHT |+ !!(data[0]&4) * GPM_B_MIDDLE;++ /* the red button pressed or depressed.+ * the depress event is fired 3 times followed by a 8 0 0 packet+ */+ if( (data[0] & 0xc0) && (data[1] == 0xD2) )+ {+ if (( data[2] & 0x10 ) != 0) /* pressed? */+ wheel = 3;+ else+ wheel--;++ return -1;+ }++ if( (wheel == 1) && data[0] == 0x08 && data[1] == 0 && data[2] == 0 )+ {+ wheel--;+ return -1;+ }++ if( wheel == 3 ) /* wheel 'level' 3 is the real stuff.. else it i+ s 'depressing' ;) */+ {+ /* eat another dummy packet? */+ if( data[0] == 0x08 && data[1] == 0 && data[2] == 0 )+ return -1;++ /* or is it smarter to emulate a wheel? */+ state->buttons |= GPM_STICK; // pressed++ /* if red button is pressed take mouse movement as wheel */+ state->stick_x = (data[0] & 0x10) ? (data[1]-256) : data[1];+ state->stick_y = -((data[0] & 0x20) ? data[2]-256 : data[2]);++ /* shut the rest of the mouse up.. */+ state->dy = state->dx = 0;+ }+ else /* it's normal movement */+ {+ state->dx = (data[0] & 0x10) ? data[1]-256 : data[1];+ state->dy= -((data[0] & 0x20) ? data[2]-256 : data[2]);+ state->stick_x = state->stick_y = 0;+ }+ return 0;+}++#define GPM_B_BOTH (GPM_B_LEFT|GPM_B_RIGHT)+static int M_tmmfx(Gpm_Event *state, unsigned char *data)+{++ /* The Logitech TrackMan Marble FX, mostly cut-n-paste from M_mman */+ /* Tido Klaassen (tidklaas@hermes.fho-emden.de), 5.1.2000 */++ static unsigned char buttons=0;+ static Gpm_Type *mytype=0;+ unsigned char extended;+ signed char my_x, my_y;++ /* find mice-entry for toggeling between 3/4-byte-protocoll */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?