Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
.TH KEYBOARD 2
2
.SH NAME
3
initkeyboard, ctlkeyboard, closekeyboard \- keyboard control
4
.SH SYNOPSIS
5
.nf
6
.B
7
#include <u.h>
8
.B
9
#include <libc.h>
10
.B
11
#include <thread.h>
12
.B
13
#include <keyboard.h>
14
.PP
15
.B
16
Keyboardctl	*initkeyboard(char *file)
17
.PP
18
.B
19
int			ctlkeyboard(Keyboardctl *kc, char *msg)
20
.PP
21
.B
22
void			closekeyboard(Keyboard *kc)
23
.SH DESCRIPTION
24
These functions access and control a keyboard interface
25
for character-at-a-time I/O in a multi-threaded environment, usually in combination with
26
.IR mouse (2).
27
They use the message-passing
28
.B Channel
29
interface in the threads library
30
(see
31
.IR thread (2));
32
programs that wish a more event-driven, single-threaded approach should use
33
.IR event (2).
34
.PP
35
.I Initkeyboard
36
opens a connection to the keyboard and returns a
37
.B Keyboardctl
38
structure:
39
.IP
40
.EX
41
.ta 6n +\w'Channel 'u +\w'consfd;   'u
42
typedef struct Keyboardct Keyboardctl;
43
struct Keyboardctl
44
{
45
	Channel	*c;	/* chan(Rune[20]) */
46
 
47
	char	*file;
48
	int	consfd;		/* to cons file */
49
	int	ctlfd;		/* to ctl file */
50
	int	pid;		/* of slave proc */
51
};
52
.EE
53
.PP
54
The argument to
55
.I initkeyboard
56
is a
57
.I file
58
naming the device file from which characters may be read,
59
typically
60
.BR /dev/cons .
61
If
62
.I file
63
is nil,
64
.B /dev/cons
65
is assumed.
66
.PP
67
Once the
68
.B Keyboardctl
69
is set up a
70
message containing a
71
.BR Rune
72
will be sent on the
73
.B Channel
74
.B Keyboardctl.c
75
to report each character read from the device.
76
.PP
77
.I Ctlkeyboard
78
is used to set the state of the interface, typically to turn raw mode on and off
79
(see
80
.IR cons (3)).
81
It writes the string
82
.I msg
83
to the control file associated with the device, which is assumed to be the regular device file name
84
with the string
85
.B ctl
86
appended.
87
.PP
88
.I Closekeyboard
89
closes the file descriptors associated with the keyboard, kills the slave processes,
90
and frees the
91
.B Keyboardctl
92
structure.
93
.PP
94
.SH SOURCE
95
.B /sys/src/libdraw
96
.SH SEE ALSO
97
.IR graphics (2),
98
.IR draw (2),
99
.IR event (2),
100
.IR thread (2).
101
.SH BUGS
102
Because the interface delivers complete runes,
103
there is no way to report lesser actions such as
104
shift keys or even individual bytes.