summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/psaux.c
blob: e0c5d9f61b27c51ea022c6c27b345683f49b29b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Interface to raw PS/2 aux port.
 * Used by user-level mouse daemon.
 */

#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "io.h"

#define Image	IMAGE
#include <draw.h>
#include <memdraw.h>
#include <cursor.h>
#include "screen.h"

/*
 * BUG: we ignore shift here.
 * we need a more general solution,
 * one that will also work for serial mice.
 */
Queue *psauxq;

static void
psauxputc(int c, int)
{
	uchar uc;

	uc = c;
	qproduce(psauxq, &uc, 1);
}

static long
psauxread(Chan*, void *a, long n, vlong)
{
	return qread(psauxq, a, n);
}

static long
psauxwrite(Chan*, void *a, long n, vlong)
{
	return i8042auxcmds(a, n);
}

void
psauxlink(void)
{
	psauxq = qopen(1024, 0, 0, 0);
	if(psauxq == nil)
		panic("psauxlink");
	qnoblock(psauxq, 1);
	i8042auxenable(psauxputc);
	addarchfile("psaux", DMEXCL|0660, psauxread, psauxwrite);
}