xref: /plan9/sys/src/9/pc/psaux.c (revision 3ff48bf5ed603850fcd251ddf13025d23d693782)
1 /*
2  * Interface to raw PS/2 aux port.
3  * Used by user-level mouse daemon.
4  */
5 
6 #include "u.h"
7 #include "../port/lib.h"
8 #include "mem.h"
9 #include "dat.h"
10 #include "fns.h"
11 #include "../port/error.h"
12 #include "io.h"
13 
14 #define Image	IMAGE
15 #include <draw.h>
16 #include <memdraw.h>
17 #include <cursor.h>
18 #include "screen.h"
19 
20 /*
21  * BUG: we ignore shift here.
22  * we need a more general solution,
23  * one that will also work for serial mice.
24  */
25 Queue *psauxq;
26 
27 static void
psauxputc(int c,int)28 psauxputc(int c, int)
29 {
30 	uchar uc;
31 
32 	uc = c;
33 	qproduce(psauxq, &uc, 1);
34 }
35 
36 static long
psauxread(Chan *,void * a,long n,vlong)37 psauxread(Chan*, void *a, long n, vlong)
38 {
39 	return qread(psauxq, a, n);
40 }
41 
42 static long
psauxwrite(Chan *,void * a,long n,vlong)43 psauxwrite(Chan*, void *a, long n, vlong)
44 {
45 	return i8042auxcmds(a, n);
46 }
47 
48 void
psauxlink(void)49 psauxlink(void)
50 {
51 	psauxq = qopen(1024, 0, 0, 0);
52 	if(psauxq == nil)
53 		panic("psauxlink");
54 	qnoblock(psauxq, 1);
55 	i8042auxenable(psauxputc);
56 	addarchfile("psaux", DMEXCL|0660, psauxread, psauxwrite);
57 }
58