| plan 9 kernel history: overview | file list | diff list |
2001/1130/bitsy/devpenmouse.c (diff list | history)
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:90,100 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:90,101 (short | long) | ||
| 2000/1021 | pentrackxy(int x, int y) { if (x == -1) { /* pen up. associate with button 1, 2, 3 up */ | |
| 2000/1024 | mouse.buttons &= ~0x7; | |
| 2000/1021 | } else { x = (x<<16)/calibration.scalex + calibration.transx; y = (y<<16)/calibration.scaley + calibration.transy; | |
| 2000/1024 | if ((mouse.buttons & 0x7) == 0) mouse.buttons |= 0x1; | |
| 2000/1021 | } penmousetrack(mouse.buttons, x, y); } | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:204,210 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:205,210 | ||
| 2000/1021 | } } | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:211,217 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:211,216 | ||
| 2000/1021 | char buf[4*12+1]; static int map[8] = {0, 4, 2, 6, 1, 5, 3, 7 }; Mousestate m; | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:239,250 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:238,246 | ||
| 2000/1021 | m = mouse.Mousestate; } | |
| 2000/1024 | m.buttons, | |
| 2000/1021 | m.msec); mouse.lastcounter = m.counter; if(n > 1+4*12) | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:303,309 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:299,305 | ||
| 2000/1021 | { char *p; Point pt; | |
| 2000/1024 | char buf[64], *field[5]; | |
| 2000/1021 | int nf, b; p = va; | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:319,325 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:315,321 | ||
| 2000/1021 | buf[n-1] = 0; else buf[n] = 0; | |
| 2000/1024 | nf = getfields(buf, field, 5, 1, " "); | |
| 2000/1021 | if(strcmp(field[0], "swap") == 0){ if(mouseswap) setbuttonmap("123"); | |
| 2000/1021/sys/src/9/bitsy/devpenmouse.c:338,344 – 2000/1024/sys/src/9/bitsy/devpenmouse.c:334,341 | ||
| 2000/1021 | calibration.scaley = strtol(field[2], nil, 0); calibration.transx = strtol(field[3], nil, 0); calibration.transy = strtol(field[4], nil, 0); | |
| 2000/1024 | } else print("calibrate %d fields\n", nf); | |
| 2000/1021 | } return n; | |
| 2000/1024/sys/src/9/bitsy/devpenmouse.c:80,88 – 2000/1025/sys/src/9/bitsy/devpenmouse.c:80,88 (short | long) | ||
| 2000/1021 | void penbutton(int up, int b) { if (up) | |
| 2000/1025 | mouse.buttons &= ~b; | |
| 2000/1021 | else | |
| 2000/1025 | mouse.buttons |= b; | |
| 2000/1021 | penmousetrack(mouse.buttons, -1, -1); } | |
| 2000/1024/sys/src/9/bitsy/devpenmouse.c:406,417 – 2000/1025/sys/src/9/bitsy/devpenmouse.c:406,413 | ||
| 2000/1021 | { int lastb; | |
| 2000/1025 | if (x >= 0) | |
| 2000/1021 | mouse.xy = Pt(x, y); | |
| 2000/1025/sys/src/9/bitsy/devpenmouse.c:92,99 – 2000/1101/sys/src/9/bitsy/devpenmouse.c:92,99 (short | long) | ||
| 2000/1021 | /* pen up. associate with button 1, 2, 3 up */ | |
| 2000/1024 | mouse.buttons &= ~0x7; | |
| 2000/1021 | } else { | |
| 2000/1101 | x = ((x*calibration.scalex)>>16) + calibration.transx; y = ((y*calibration.scaley)>>16) + calibration.transy; | |
| 2000/1024 | if ((mouse.buttons & 0x7) == 0) mouse.buttons |= 0x1; | |
| 2000/1021 | } | |
| 2000/1025/sys/src/9/bitsy/devpenmouse.c:325,332 – 2000/1101/sys/src/9/bitsy/devpenmouse.c:325,332 | ||
| 2000/1021 | } else if(strcmp(field[0], "calibrate") == 0){ if (nf == 1) { | |
| 2000/1101 | calibration.scalex = 1<<16; calibration.scaley = 1<<16; | |
| 2000/1021 | calibration.transx = 0; calibration.transy = 0; } else if (nf == 5) { | |
| 2000/1101/sys/src/9/bitsy/devpenmouse.c:22,31 – 2000/1102/sys/src/9/bitsy/devpenmouse.c:22,31 (short | long) | ||
| 2000/1021 | long transx; long transy; } calibration = { | |
| 2000/1102 | -23540, -16858, 342, 252 | |
| 2000/1021 | }; struct Mousestate | |
| 2000/1102/sys/src/9/bitsy/devpenmouse.c:22,31 – 2000/1104/sys/src/9/bitsy/devpenmouse.c:22,31 (short | long) | ||
| 2000/1021 | long transx; long transy; } calibration = { | |
| 2000/1102 |
| |
| 2000/1104 | 23540, 252, 342 | |
| 2000/1021 | }; struct Mousestate | |
| 2000/1104/sys/src/9/bitsy/devpenmouse.c:22,31 – 2000/1120/sys/src/9/bitsy/devpenmouse.c:22,31 (short | long) | ||
| 2000/1021 | long transx; long transy; } calibration = { | |
| 2000/1102 |
| |
| 2000/1104 |
| |
| 2000/1120 | -16435, 23275, 253, -23 | |
| 2000/1021 | }; struct Mousestate | |
| 2000/1120/sys/src/9/bitsy/devpenmouse.c:425,430 – 2000/1130/sys/src/9/bitsy/devpenmouse.c:425,431 (short | long) | ||
| 2000/1021 | mouse.qfull = 1; } wakeup(&mouse.r); | |
| 2000/1130 | drawactive(1); | |
| 2000/1021 | } int | |
| 2000/1130/sys/src/9/bitsy/devpenmouse.c:223,229 – 2000/1206/sys/src/9/bitsy/devpenmouse.c:223,229 (short | long) | ||
| 2000/1021 | mouse.qfull = 0; /* | |
| 2000/1206 | * No lock of the indices is necessary here, because ri is only | |
| 2000/1021 | * updated by us, and there is only one mouse reader * at a time. I suppose that more than one process * could try to read the fd at one time, but such behavior | |
| 2000/1206/sys/src/9/bitsy/devpenmouse.c:28,37 – 2000/1207/sys/src/9/bitsy/devpenmouse.c:28,48 (short | long) | ||
| 2000/1120 | -23 | |
| 2000/1021 | }; | |
| 2000/1207 | /* The pen goes down, tracks some and goes up again. The pen alone can * only simulate a one-button mouse. * To simulate a more-button (five, in this case) mouse, we use the four * keys along the the bottom of the iPaq as modifiers. * When one (or more) of the modifier keys is (are) down, a pen-down event * causes the corresponding bottons to go down. If no modifier key is * depressed, a pen-down event is translated into a button-one down event. * Releasing the modifier keys has no direct effect. The pen-up event is * the one that triggers mouse-up events. */ | |
| 2000/1021 | struct Mousestate { Point xy; /* mouse.xy */ int buttons; /* mouse.buttons */ | |
| 2000/1207 | int modifiers; /* state of physical buttons 2, 3, 4, 5 */ | |
| 2000/1021 | ulong counter; /* increments every update */ ulong msec; /* time of last event */ }; | |
| 2000/1206/sys/src/9/bitsy/devpenmouse.c:79,101 – 2000/1207/sys/src/9/bitsy/devpenmouse.c:90,123 | ||
| 2000/1021 | void penbutton(int up, int b) { | |
| 2000/1025 |
| |
| 2000/1021 |
| |
| 2000/1025 |
| |
| 2000/1021 |
| |
| 2000/1207 | if (b & 0x20) { if (up) mouse.buttons &= ~b; else mouse.buttons |= b; penmousetrack(mouse.buttons, -1, -1); } else { if (up) mouse.modifiers &= ~b; else mouse.modifiers |= b; } | |
| 2000/1021 | } void pentrackxy(int x, int y) { if (x == -1) { | |
| 2000/1024 |
| |
| 2000/1207 | /* pen up. associate with button 1 through 5 up */ mouse.buttons &= ~0x1f; | |
| 2000/1021 | } else { | |
| 2000/1101 | x = ((x*calibration.scalex)>>16) + calibration.transx; y = ((y*calibration.scaley)>>16) + calibration.transy; | |
| 2000/1024 |
| |
| 2000/1207 | if ((mouse.buttons & 0x1f) == 0) { if (mouse.modifiers) mouse.buttons |= mouse.modifiers; else mouse.buttons |= 0x1; } | |
| 2000/1021 | } penmousetrack(mouse.buttons, x, y); } | |
| 2000/1207/sys/src/9/bitsy/devpenmouse.c:78,84 – 2000/1214/sys/src/9/bitsy/devpenmouse.c:78,84 (short | long) | ||
| 2000/1021 | static Dirtab mousedir[]={ "mouse", {Qmouse}, 0, 0666, "mousein", {Qmousein}, 0, 0220, | |
| 2000/1214 | "mousectl", {Qmousectl}, 0, 0660, | |
| 2000/1021 | }; static uchar buttonmap[8] = { | |
| 2000/1207/sys/src/9/bitsy/devpenmouse.c:237,242 – 2000/1214/sys/src/9/bitsy/devpenmouse.c:237,251 | ||
| 2000/1021 | switch(c->qid.path){ case CHDIR: return devdirread(c, va, n, mousedir, nelem(mousedir), devgen); | |
| 2000/1214 | case Qmousectl: sprint(buf, "c%11ld %11ld %11ld %11ld", calibration.scalex, calibration.scaley, calibration.transx, calibration.transy); if(n > 1+4*12) n = 1+4*12; memmove(va, buf, n); return n; | |
| 2000/1021 | case Qmouse: while(penmousechanged(0) == 0) | |
| 2000/1214/sys/src/9/bitsy/devpenmouse.c:10,15 – 2000/1215/sys/src/9/bitsy/devpenmouse.c:10,16 (short | long) | ||
| 2000/1021 | #include <memdraw.h> #include <cursor.h> #include "screen.h" | |
| 2000/1215 | #include <ctype.h> | |
| 2000/1021 | typedef struct Mouseinfo Mouseinfo; typedef struct Mousestate Mousestate; | |
| 2000/1214/sys/src/9/bitsy/devpenmouse.c:361,366 – 2000/1215/sys/src/9/bitsy/devpenmouse.c:362,372 | ||
| 2000/1021 | calibration.transx = 0; calibration.transy = 0; } else if (nf == 5) { | |
| 2000/1215 | if ((!isdigit(*field[1]) && *field[1] != '-') || (!isdigit(*field[2]) && *field[2] != '-') || (!isdigit(*field[3]) && *field[3] != '-') || (!isdigit(*field[4]) && *field[4] != '-')) error(Ectlsyntax); | |
| 2000/1021 | calibration.scalex = strtol(field[1], nil, 0); calibration.scaley = strtol(field[2], nil, 0); calibration.transx = strtol(field[3], nil, 0); | |
| 2000/1215/sys/src/9/bitsy/devpenmouse.c:269,275 – 2000/1216/sys/src/9/bitsy/devpenmouse.c:269,274 (short | long) | ||
| 2000/1021 | } else { m = mouse.Mousestate; } | |
| 2000/1024 | m.buttons, | |
| 2000/1216/sys/src/9/bitsy/devpenmouse.c:365,371 – 2001/0115/sys/src/9/bitsy/devpenmouse.c:365,371 (short | long) | ||
| 2000/1215 | || (!isdigit(*field[2]) && *field[2] != '-') || (!isdigit(*field[3]) && *field[3] != '-') || (!isdigit(*field[4]) && *field[4] != '-')) | |
| 2001/0115 | error("bad syntax in control file message"); | |
| 2000/1021 | calibration.scalex = strtol(field[1], nil, 0); calibration.scaley = strtol(field[2], nil, 0); calibration.transx = strtol(field[3], nil, 0); | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:77,85 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:77,86 (short | long) | ||
| 2000/1021 | }; static Dirtab mousedir[]={ | |
| 2000/1214 |
| |
| 2001/0529 | ".", {Qdir, 0, QTDIR}, 0, DMDIR|0555, "mouse", {Qmouse}, 0, 0666, "mousein", {Qmousein}, 0, 0220, "mousectl", {Qmousectl}, 0, 0660, | |
| 2000/1021 | }; static uchar buttonmap[8] = { | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:145,176 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:146,168 | ||
| 2000/1021 | return devattach('m', spec); } | |
| 2001/0529 | static Walkqid* penmousewalk(Chan *c, Chan *nc, char **name, int nname) | |
| 2000/1021 | { | |
| 2001/0529 | return devwalk(c, nc, name, nname, mousedir, nelem(mousedir), devgen); | |
| 2000/1021 | } static int | |
| 2001/0529 | penmousestat(Chan *c, uchar *db, int n) | |
| 2000/1021 | { | |
| 2001/0529 | return devstat(c, db, n, mousedir, nelem(mousedir), devgen); | |
| 2000/1021 | } | |
| 2001/0529 | switch((ulong)c->qid.path){ case Qdir: | |
| 2000/1021 | if(omode != OREAD) error(Eperm); break; | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:214,220 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:206,212 | ||
| 2000/1021 | static void penmouseclose(Chan *c) { | |
| 2001/0529 | if(c->qid.path != Qdir && (c->flag&COPEN)){ | |
| 2000/1021 | lock(&mouse); if(c->qid.path == Qmouse) mouse.open = 0; | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:235,242 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:227,234 | ||
| 2000/1021 | static int map[8] = {0, 4, 2, 6, 1, 5, 3, 7 }; Mousestate m; | |
| 2001/0529 | switch((ulong)c->qid.path){ case Qdir: | |
| 2000/1021 | return devdirread(c, va, n, mousedir, nelem(mousedir), devgen); | |
| 2000/1214 | case Qmousectl: | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:334,341 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:326,333 | ||
| 2000/1021 | int nf, b; p = va; | |
| 2001/0529 | switch((ulong)c->qid.path){ case Qdir: | |
| 2000/1021 | error(Eisdir); case Qmousectl: | |
| 2001/0115/sys/src/9/bitsy/devpenmouse.c:419,425 – 2001/0529/sys/src/9/bitsy/devpenmouse.c:411,416 | ||
| 2000/1021 | penmousereset, penmouseinit, penmouseattach, | |
| 2001/0529/sys/src/9/bitsy/devpenmouse.c:92,98 – 2001/0822/sys/src/9/bitsy/devpenmouse.c:92,101 (short | long) | ||
| 2000/1021 | void penbutton(int up, int b) { | |
| 2000/1207 |
| |
| 2001/0822 | // button 5 (side button) immediately causes an event // when the pen is down (button 1), other buttons also // cause events, allowing chording with button 1 if ((b & 0x20) || (mouse.buttons & 0x1)) { | |
| 2000/1207 | if (up) mouse.buttons &= ~b; else | |
| 2001/0822/sys/src/9/bitsy/devpenmouse.c:341,347 – 2001/1117/sys/src/9/bitsy/devpenmouse.c:341,347 (short | long) | ||
| 2000/1021 | buf[n-1] = 0; else buf[n] = 0; | |
| 2000/1024 |
| |
| 2001/1117 | nf = tokenize(buf, field, 5); | |
| 2000/1021 | if(strcmp(field[0], "swap") == 0){ if(mouseswap) setbuttonmap("123"); | |
| 2001/1117/sys/src/9/bitsy/devpenmouse.c:83,88 – 2001/1121/sys/src/9/bitsy/devpenmouse.c:83,100 (short | long) | ||
| 2001/0529 | "mousectl", {Qmousectl}, 0, 0660, | |
| 2000/1021 | }; | |
| 2001/1121 | enum { CMcalibrate, CMswap, }; static Cmdtab penmousecmd[] = { CMcalibrate, "calibrate", 0, CMswap, "swap", 1, }; | |
| 2000/1021 | static uchar buttonmap[8] = { 0, 1, 2, 3, 4, 5, 6, 7, }; | |
| 2001/1117/sys/src/9/bitsy/devpenmouse.c:325,330 – 2001/1121/sys/src/9/bitsy/devpenmouse.c:337,344 | ||
| 2000/1021 | { char *p; Point pt; | |
| 2001/1121 | Cmdbuf *cb; Cmdtab *ct; | |
| 2000/1024 | char buf[64], *field[5]; | |
| 2000/1021 | int nf, b; | |
| 2001/1117/sys/src/9/bitsy/devpenmouse.c:334,361 – 2001/1121/sys/src/9/bitsy/devpenmouse.c:348,374 | ||
| 2000/1021 | error(Eisdir); case Qmousectl: | |
| 2001/1117 |
| |
| 2000/1021 |
| |
| 2001/1121 | cb = parsecmd(va, n); if(waserror()){ free(cb); nexterror(); } ct = lookupcmd(cb, penmousecmd, nelem(penmousecmd)); switch(ct->index){ case CMswap: | |
| 2000/1021 | if(mouseswap) setbuttonmap("123"); else setbuttonmap("321"); mouseswap ^= 1; | |
| 2001/1121 | break; case CMcalibrate: if (cb->nf == 1) { | |
| 2000/1101 | calibration.scalex = 1<<16; calibration.scaley = 1<<16; | |
| 2000/1021 | calibration.transx = 0; calibration.transy = 0; | |
| 2001/1121 | } else if (cb->nf == 5) { | |
| 2000/1215 | if ((!isdigit(*field[1]) && *field[1] != '-') || (!isdigit(*field[2]) && *field[2] != '-') || (!isdigit(*field[3]) && *field[3] != '-') | |
| 2001/1117/sys/src/9/bitsy/devpenmouse.c:366,373 – 2001/1121/sys/src/9/bitsy/devpenmouse.c:379,389 | ||
| 2000/1021 | calibration.transx = strtol(field[3], nil, 0); calibration.transy = strtol(field[4], nil, 0); | |
| 2000/1024 | } else | |
| 2001/1121 | cmderror(cb, Ecmdargs); break; | |
| 2000/1021 | } | |
| 2001/1121 | free(cb); poperror(); | |
| 2000/1021 | return n; case Qmousein: | |
| 2001/1121/sys/src/9/bitsy/devpenmouse.c:123,128 – 2001/1130/sys/src/9/bitsy/devpenmouse.c:123,129 (short | long) | ||
| 2000/1021 | void pentrackxy(int x, int y) { | |
| 2001/1130 | ||
| 2000/1021 | if (x == -1) { | |
| 2000/1207 | /* pen up. associate with button 1 through 5 up */ mouse.buttons &= ~0x1f; | |
| 2001/1121/sys/src/9/bitsy/devpenmouse.c:339,346 – 2001/1130/sys/src/9/bitsy/devpenmouse.c:340,347 | ||
| 2000/1021 | Point pt; | |
| 2001/1121 | Cmdbuf *cb; Cmdtab *ct; | |
| 2000/1024 |
| |
| 2000/1021 |
| |
| 2001/1130 | char buf[64]; int b; | |
| 2000/1021 | p = va; | |
| 2001/0529 | switch((ulong)c->qid.path){ | |
| 2001/1121/sys/src/9/bitsy/devpenmouse.c:369,383 – 2001/1130/sys/src/9/bitsy/devpenmouse.c:370,384 | ||
| 2000/1021 | calibration.transx = 0; calibration.transy = 0; | |
| 2001/1121 | } else if (cb->nf == 5) { | |
| 2000/1215 |
| |
| 2001/1130 | if ((!isdigit(*cb->f[1]) && *cb->f[1] != '-') || (!isdigit(*cb->f[2]) && *cb->f[2] != '-') || (!isdigit(*cb->f[3]) && *cb->f[3] != '-') || (!isdigit(*cb->f[4]) && *cb->f[4] != '-')) | |
| 2001/0115 | error("bad syntax in control file message"); | |
| 2000/1021 |
| |
| 2001/1130 | calibration.scalex = strtol(cb->f[1], nil, 0); calibration.scaley = strtol(cb->f[2], nil, 0); calibration.transx = strtol(cb->f[3], nil, 0); calibration.transy = strtol(cb->f[4], nil, 0); | |
| 2000/1024 | } else | |
| 2001/1121 | cmderror(cb, Ecmdargs); break; | |
| 2001/1130/sys/src/9/bitsy/devpenmouse.c:430,435 – 2002/0109/sys/src/9/bitsy/devpenmouse.c:430,436 (short | long) | ||
| 2000/1021 | penmousereset, penmouseinit, | |
| 2002/0109 | devshutdown, | |
| 2000/1021 | penmouseattach, penmousewalk, penmousestat, | |
| 2002/0109/sys/src/9/bitsy/devpenmouse.c:474,479 – 2002/1112/sys/src/9/bitsy/devpenmouse.c:474,480 (short | long) | ||
| 2000/1021 | } wakeup(&mouse.r); | |
| 2000/1130 | drawactive(1); | |
| 2002/1112 | resetsuspendtimer(); | |
| 2000/1021 | } int | |