blob: 4641b86dc43a0183081012036e9f13b477b5b202 [file] [log] [blame]
.TH KEYBOARD 3
.SH NAME
initkeyboard, ctlkeyboard, closekeyboard \- keyboard control
.SH SYNOPSIS
.nf
.B
#include <u.h>
.B
#include <libc.h>
.B
#include <thread.h>
.B
#include <keyboard.h>
.PP
.B
Keyboardctl *initkeyboard(char *file)
.PP
.B
int ctlkeyboard(Keyboardctl *kc, char *msg)
.PP
.B
void closekeyboard(Keyboard *kc)
.SH DESCRIPTION
These functions access and control a keyboard interface
for character-at-a-time I/O in a multi-threaded environment, usually in combination with
.IR mouse (3).
They use the message-passing
.B Channel
interface in the threads library
(see
.IR thread (3));
programs that wish a more event-driven, single-threaded approach should use
.IR event (3).
.PP
.I Initkeyboard
opens a connection to the keyboard and returns a
.B Keyboardctl
structure:
.IP
.EX
.ta 6n +\w'Channel 'u +\w'consfd; 'u
typedef struct Keyboardct Keyboardctl;
struct Keyboardctl
{
Channel *c; /* chan(Rune[20]) */
char *file;
int consfd; /* to cons file */
int ctlfd; /* to ctl file */
int pid; /* of slave proc */
};
.EE
.PP
The argument to
.I initkeyboard
is ignored
(on Plan 9, it is the name of the keyboard device).
.PP
Once the
.B Keyboardctl
is set up a
message containing a
.BR Rune
will be sent on the
.B Channel
.B Keyboardctl.c
to report each character read from the device.
.PP
.I Ctlkeyboard
is used to set the state of the interface, typically to turn raw mode on and off.
.\" (see
.\" .IR cons (3)).
It writes the string
.I msg
to the control file associated with the device, which is assumed to be the regular device file name
with the string
.B ctl
appended.
.PP
.I Closekeyboard
closes the file descriptors associated with the keyboard, kills the slave processes,
and frees the
.B Keyboardctl
structure.
.PP
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
.IR graphics (3),
.IR draw (3),
.IR event (3),
.IR thread (3).
.SH BUGS
Because the interface delivers complete runes,
there is no way to report lesser actions such as
shift keys or even individual bytes.