tkeyboard.3 - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tkeyboard.3 (2002B)
       ---
            1 .TH KEYBOARD 3
            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 .MR mouse (3) .
           27 They use the message-passing
           28 .B Channel
           29 interface in the threads library
           30 (see
           31 .MR thread (3) );
           32 programs that wish a more event-driven, single-threaded approach should use
           33 .MR event (3) .
           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 ignored
           57 (on Plan 9, it is the name of the keyboard device).
           58 .PP
           59 Once the
           60 .B Keyboardctl
           61 is set up a
           62 message containing a
           63 .BR Rune
           64 will be sent on the
           65 .B Channel
           66 .B Keyboardctl.c
           67 to report each character read from the device.
           68 .PP
           69 .I Ctlkeyboard
           70 is used to set the state of the interface, typically to turn raw mode on and off.
           71 .\" (see
           72 .\" .IR cons (3)).
           73 It writes the string
           74 .I msg
           75 to the control file associated with the device, which is assumed to be the regular device file name
           76 with the string
           77 .B ctl
           78 appended.
           79 .PP
           80 .I Closekeyboard
           81 closes the file descriptors associated with the keyboard, kills the slave processes,
           82 and frees the
           83 .B Keyboardctl
           84 structure.
           85 .PP
           86 .SH SOURCE
           87 .B \*9/src/libdraw
           88 .SH SEE ALSO
           89 .MR graphics (3) ,
           90 .MR draw (3) ,
           91 .MR event (3) ,
           92 .MR thread (3) .
           93 .SH BUGS
           94 Because the interface delivers complete runes,
           95 there is no way to report lesser actions such as
           96 shift keys or even individual bytes.