7 * Convert AccuPoint buttons 4 and 5 to a simulation of button 2.
8 * The buttons generate down events, repeat, and have no up events,
9 * so it's a struggle. This program turns the left button into a near-as-
10 * possible simulation of a regular button 2, but it can only sense up
11 * events by timeout, so it's sluggish. Thus it also turns the right button
12 * into a click on button 2, useful for acme and chords.
32 n = read(0, buf, sizeof buf);
38 m->xy.x = atoi(buf+1+0*12);
39 m->xy.y = atoi(buf+1+1*12);
40 m->buttons = atoi(buf+1+2*12);
41 m->msec = atoi(buf+1+3*12);
48 print("%c%11d %11d %11d %11ld ",
57 notifyf(void*, char *s)
59 if(strcmp(s, "alarm") == 0)
71 memset(&m, 0, sizeof m);
75 /* first click waits 500ms before repeating; after that they're 150, but that's ok */
82 /* timed out; clear button 2 */
90 /* avoid bounce caused by button 5 click */
91 if((om.buttons&16) && (m.buttons&16)){
98 /* only check 4 and 5 if 2 isn't down of its own accord */
100 /* generate quick button 2 click */
105 /* fall through to generate up event */
106 }else if(m.buttons & 8){
107 /* press and hold button 2 */
113 if(m.byte!=om.byte || m.buttons!=om.buttons || !eqpt(m.xy, om.xy))