rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 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 |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 26 | .IR mouse (3). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 27 | They use the message-passing |
| 28 | .B Channel |
| 29 | interface in the threads library |
| 30 | (see |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 31 | .IR thread (3)); |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 32 | programs that wish a more event-driven, single-threaded approach should use |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 33 | .IR event (3). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 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 |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 56 | is ignored |
| 57 | (on Plan 9, it is the name of the keyboard device). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 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 |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 70 | is used to set the state of the interface, typically to turn raw mode on and off. |
| 71 | .\" (see |
| 72 | .\" .IR cons (3)). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 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 |
rsc | c3674de | 2005-01-11 17:37:33 +0000 | [diff] [blame] | 87 | .B \*9/src/libdraw |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 88 | .SH SEE ALSO |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 89 | .IR graphics (3), |
| 90 | .IR draw (3), |
| 91 | .IR event (3), |
| 92 | .IR thread (3). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 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. |