blob: 4641b86dc43a0183081012036e9f13b477b5b202 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH KEYBOARD 3
2.SH NAME
3initkeyboard, 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
16Keyboardctl *initkeyboard(char *file)
17.PP
18.B
19int ctlkeyboard(Keyboardctl *kc, char *msg)
20.PP
21.B
22void closekeyboard(Keyboard *kc)
23.SH DESCRIPTION
24These functions access and control a keyboard interface
25for character-at-a-time I/O in a multi-threaded environment, usually in combination with
rscbf8a59f2004-04-11 03:42:27 +000026.IR mouse (3).
rsccfa37a72004-04-10 18:53:55 +000027They use the message-passing
28.B Channel
29interface in the threads library
30(see
rscbf8a59f2004-04-11 03:42:27 +000031.IR thread (3));
rsccfa37a72004-04-10 18:53:55 +000032programs that wish a more event-driven, single-threaded approach should use
rscbf8a59f2004-04-11 03:42:27 +000033.IR event (3).
rsccfa37a72004-04-10 18:53:55 +000034.PP
35.I Initkeyboard
36opens a connection to the keyboard and returns a
37.B Keyboardctl
38structure:
39.IP
40.EX
41.ta 6n +\w'Channel 'u +\w'consfd; 'u
42typedef struct Keyboardct Keyboardctl;
43struct 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
54The argument to
55.I initkeyboard
rsc058b0112005-01-03 06:40:20 +000056is ignored
57(on Plan 9, it is the name of the keyboard device).
rsccfa37a72004-04-10 18:53:55 +000058.PP
59Once the
60.B Keyboardctl
61is set up a
62message containing a
63.BR Rune
64will be sent on the
65.B Channel
66.B Keyboardctl.c
67to report each character read from the device.
68.PP
69.I Ctlkeyboard
rsc058b0112005-01-03 06:40:20 +000070is used to set the state of the interface, typically to turn raw mode on and off.
71.\" (see
72.\" .IR cons (3)).
rsccfa37a72004-04-10 18:53:55 +000073It writes the string
74.I msg
75to the control file associated with the device, which is assumed to be the regular device file name
76with the string
77.B ctl
78appended.
79.PP
80.I Closekeyboard
81closes the file descriptors associated with the keyboard, kills the slave processes,
82and frees the
83.B Keyboardctl
84structure.
85.PP
86.SH SOURCE
rscc3674de2005-01-11 17:37:33 +000087.B \*9/src/libdraw
rsccfa37a72004-04-10 18:53:55 +000088.SH SEE ALSO
rscbf8a59f2004-04-11 03:42:27 +000089.IR graphics (3),
90.IR draw (3),
91.IR event (3),
92.IR thread (3).
rsccfa37a72004-04-10 18:53:55 +000093.SH BUGS
94Because the interface delivers complete runes,
95there is no way to report lesser actions such as
96shift keys or even individual bytes.