1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
.TH "Reading key presses" 3 "Sat Oct 25 2014" "Version 1.0" "BrlAPI" \" -*- nroff -*-
.ad l
.nh
.SH NAME
Reading key presses \-
.PP
How to read key presses from the braille terminal\&.
.SS "Data Structures"
.in +1c
.ti -1c
.RI "struct \fBbrlapi_expandedKeyCode_t\fP"
.br
.ti -1c
.RI "struct \fBbrlapi_describedKeyCode_t\fP"
.br
.ti -1c
.RI "struct \fBbrlapi_range_t\fP"
.br
.in -1c
.SS "Macros"
.in +1c
.ti -1c
.RI "#define \fBbrlapi_ignoreAllKeys\fP() \fBbrlapi_ignoreKeys\fP(\fBbrlapi_rangeType_all\fP, NULL, 0)"
.br
.ti -1c
.RI "#define \fBbrlapi_acceptAllKeys\fP() \fBbrlapi_acceptKeys\fP(\fBbrlapi_rangeType_all\fP, NULL, 0)"
.br
.ti -1c
.RI "#define \fBBRLAPI_UC_ROW\fP 0x2800UL"
.br
.ti -1c
.RI "#define \fBbrlapi__ignoreAllKeys\fP(handle) \fBbrlapi__ignoreKeys\fP(handle, \fBbrlapi_rangeType_all\fP, NULL, 0)"
.br
.ti -1c
.RI "#define \fBbrlapi__acceptAllKeys\fP(handle) \fBbrlapi__acceptKeys\fP(handle, \fBbrlapi_rangeType_all\fP, NULL, 0)"
.br
.in -1c
.SS "Enumerations"
.in +1c
.ti -1c
.RI "enum \fBbrlapi_rangeType_t\fP { \fBbrlapi_rangeType_all\fP, \fBbrlapi_rangeType_type\fP, \fBbrlapi_rangeType_command\fP, \fBbrlapi_rangeType_key\fP, \fBbrlapi_rangeType_code\fP }"
.br
.in -1c
.SS "Functions"
.in +1c
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_expandKeyCode\fP (\fBbrlapi_keyCode_t\fP code, \fBbrlapi_expandedKeyCode_t\fP *expansion)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_describeKeyCode\fP (\fBbrlapi_keyCode_t\fP code, \fBbrlapi_describedKeyCode_t\fP *description)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_readKey\fP (int wait, \fBbrlapi_keyCode_t\fP *code)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__readKey\fP (\fBbrlapi_handle_t\fP *handle, int wait, \fBbrlapi_keyCode_t\fP *code)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_ignoreKeys\fP (\fBbrlapi_rangeType_t\fP type, const \fBbrlapi_keyCode_t\fP keys[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__ignoreKeys\fP (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_rangeType_t\fP type, const \fBbrlapi_keyCode_t\fP keys[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_acceptKeys\fP (\fBbrlapi_rangeType_t\fP type, const \fBbrlapi_keyCode_t\fP keys[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__acceptKeys\fP (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_rangeType_t\fP type, const \fBbrlapi_keyCode_t\fP keys[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__ignoreAllKeys\fP (\fBbrlapi_handle_t\fP *handle)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__acceptAllKeys\fP (\fBbrlapi_handle_t\fP *handle)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_ignoreKeyRanges\fP (\fBbrlapi_range_t\fP ranges[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__ignoreKeyRanges\fP (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_range_t\fP ranges[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi_acceptKeyRanges\fP (\fBbrlapi_range_t\fP ranges[], unsigned int count)"
.br
.ti -1c
.RI "int \fBBRLAPI_STDCALL\fP \fBbrlapi__acceptKeyRanges\fP (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_range_t\fP ranges[], unsigned int count)"
.br
.in -1c
.SH "Detailed Description"
.PP
Once \fBbrlapi_enterTtyMode()\fP has been called, the application can call \fBbrlapi_readKey()\fP to read key presses\&. Either key codes (see \fBTypes and Defines fore BrlAPI Key Codes\fP) or commands will be returned, depending on parameters given to \fBbrlapi_enterTtyMode()\fP\&.
.PP
Key presses are buffered, so that calling \fBbrlapi_readKey()\fP in non-blocking mode from time to time should suffice\&.
.SH "Macro Definition Documentation"
.PP
.SS "#define brlapi__acceptAllKeys(handle) \fBbrlapi__acceptKeys\fP(handle, \fBbrlapi_rangeType_all\fP, NULL, 0)"
.SS "#define brlapi__ignoreAllKeys(handle) \fBbrlapi__ignoreKeys\fP(handle, \fBbrlapi_rangeType_all\fP, NULL, 0)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi_acceptAllKeys(void) \fBbrlapi_acceptKeys\fP(\fBbrlapi_rangeType_all\fP, NULL, 0)"
Accept all key presses from the braille keyboard
.PP
This function asks the server to give all keys to the application, and not give them to \fIbrltty\fP\&.
.PP
Warning: after calling this function, make sure to call \fBbrlapi_ignoreKeys()\fP for ignoring important keys like BRL_CMD_SWITCHVT_PREV/NEXT and such\&.
.SS "int \fBBRLAPI_STDCALL\fP brlapi_ignoreAllKeys(void) \fBbrlapi_ignoreKeys\fP(\fBbrlapi_rangeType_all\fP, NULL, 0)"
Ignore all key presses from the braille keyboard
.PP
This function asks the server to give all keys to \fIbrltty\fP, rather than returning them to the application via \fBbrlapi_readKey()\fP\&.
.SS "#define BRLAPI_UC_ROW 0x2800UL"
Unicode braille row
.SH "Enumeration Type Documentation"
.PP
.SS "enum \fBbrlapi_rangeType_t\fP"
types of key ranges
.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIbrlapi_rangeType_all \fP\fP
all keys, code must be 0
.TP
\fB\fIbrlapi_rangeType_type \fP\fP
all keys of a given type
.TP
\fB\fIbrlapi_rangeType_command \fP\fP
all keys of a given command block, i\&.e\&. matching the key type and command parts
.TP
\fB\fIbrlapi_rangeType_key \fP\fP
a given key with any flags
.TP
\fB\fIbrlapi_rangeType_code \fP\fP
a given key code
.SH "Function Documentation"
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi__acceptAllKeys (\fBbrlapi_handle_t\fP *handle)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__acceptKeyRanges (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_range_t\fPranges[], unsigned intcount)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__acceptKeys (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_rangeType_t\fPtype, const \fBbrlapi_keyCode_t\fPkeys[], unsigned intcount)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__ignoreAllKeys (\fBbrlapi_handle_t\fP *handle)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__ignoreKeyRanges (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_range_t\fPranges[], unsigned intcount)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__ignoreKeys (\fBbrlapi_handle_t\fP *handle, \fBbrlapi_rangeType_t\fPtype, const \fBbrlapi_keyCode_t\fPkeys[], unsigned intcount)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi__readKey (\fBbrlapi_handle_t\fP *handle, intwait, \fBbrlapi_keyCode_t\fP *code)"
.SS "int \fBBRLAPI_STDCALL\fP brlapi_acceptKeyRanges (\fBbrlapi_range_t\fPranges[], unsigned intcount)"
Accept some key presses from the braille keyboard
.PP
This function asks the server to return the provided key ranges (inclusive) to the application, and not give them to \fIbrltty\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fIranges\fP key ranges, which are inclusive
.br
\fIcount\fP number of ranges
.RE
.PP
\fBNote:\fP
.RS 4
The given codes should be raw keycodes (i\&.e\&. some driver name was given to \fBbrlapi_enterTtyMode()\fP)
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_acceptKeys (\fBbrlapi_rangeType_t\fPtype, const \fBbrlapi_keyCode_t\fPkeys[], unsigned intcount)"
Accept some key presses from the braille keyboard
.PP
This function asks the server to give the provided keys to the application, and not give them to \fIbrltty\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fItype\fP type of keys to be ignored
.br
\fIkeys\fP array of keys to be ignored
.br
\fIcount\fP number of keys
.RE
.PP
\fBNote:\fP
.RS 4
The given codes should be \fIbrltty\fP commands (NULL or '' was given to \fBbrlapi_enterTtyMode()\fP)
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_describeKeyCode (\fBbrlapi_keyCode_t\fPcode, \fBbrlapi_describedKeyCode_t\fP *description)"
Describe the components of a key code\&.
.PP
\fBParameters:\fP
.RS 4
\fIcode\fP the keycode to be described
.br
\fIdescription\fP pointer to the structure that receives the description
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on error
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_expandKeyCode (\fBbrlapi_keyCode_t\fPcode, \fBbrlapi_expandedKeyCode_t\fP *expansion)"
Expand the components of a key code
.PP
\fBParameters:\fP
.RS 4
\fIcode\fP the key code to be expanded
.br
\fIexpansion\fP pointer to the structure that receives the components
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on error
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_ignoreKeyRanges (\fBbrlapi_range_t\fPranges[], unsigned intcount)"
Ignore some key presses from the braille keyboard
.PP
This function asks the server to give the provided key ranges to \fIbrltty\fP, rather than returning them to the application via \fBbrlapi_readKey()\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fIranges\fP key ranges, which are inclusive
.br
\fIcount\fP number of ranges
.RE
.PP
\fBNote:\fP
.RS 4
The given codes should be raw keycodes (i\&.e\&. some driver name was given to \fBbrlapi_enterTtyMode()\fP)
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_ignoreKeys (\fBbrlapi_rangeType_t\fPtype, const \fBbrlapi_keyCode_t\fPkeys[], unsigned intcount)"
Ignore some key presses from the braille keyboard
.PP
This function asks the server to give the provided keys to \fIbrltty\fP, rather than returning them to the application via \fBbrlapi_readKey()\fP\&.
.PP
\fBParameters:\fP
.RS 4
\fItype\fP type of keys to be ignored
.br
\fIkeys\fP array of keys to be ignored
.br
\fIcount\fP number of keys
.RE
.PP
\fBNote:\fP
.RS 4
The given codes should be \fIbrltty\fP commands (NULL or '' was given to \fBbrlapi_enterTtyMode()\fP)
.RE
.PP
.SS "int \fBBRLAPI_STDCALL\fP brlapi_readKey (intwait, \fBbrlapi_keyCode_t\fP *code)"
Read a key from the braille keyboard
.PP
This function returns one key press's code\&.
.PP
If NULL or '' was given to \fBbrlapi_enterTtyMode()\fP, a \fIbrltty\fP command is returned, as described in the documentation for \fBbrlapi_keyCode_t\fP \&. It is hence pretty driver-independent, and should be used by default when no other option is possible\&.
.PP
By default, all commands but those which restart drivers and switch virtual terminals are returned to the application and not to brltty\&. If the application doesn't want to see some command events, it should call \fBbrlapi_ignoreKeys()\fP
.PP
If some driver name was given to \fBbrlapi_enterTtyMode()\fP, a raw keycode is returned, as specified by the terminal driver, usually in <brltty/brldefs-xy> where xy is the driver's code\&. It generally corresponds to the very code that the terminal tells to the driver\&. This should only be used by applications which are dedicated to a particular braille terminal\&. Hence, checking the terminal type thanks to a call to \fBbrlapi_getDriverName()\fP before getting tty control is a pretty good idea\&.
.PP
By default, all the keypresses will be passed to the client, none will go through brltty, so the application will have to handle console switching itself for instance\&.
.PP
\fBParameters:\fP
.RS 4
\fIwait\fP tells whether the call should block until a key is pressed (1) or should only probe key presses (0);
.br
\fIcode\fP holds the key code if a key press is indeed read\&.
.RE
.PP
\fBReturns:\fP
.RS 4
-1 on error or signal interrupt and *code is then undefined, 0 if block was 0 and no key was pressed so far, or 1 and *code holds the key code\&.
.RE
.PP
Programming hints:
.PP
If your application is only driven by braille command keypresses, you can just call brlapi_readKey(1, &code) so that it keeps blocking, waiting for keypresses\&.
.PP
Else, you'll probably want to use the file descriptor returned by \fBbrlapi_openConnection()\fP in your 'big polling loop'\&. For instance:
.PP
.IP "\(bu" 2
in a \fCselect()\fP loop, just add it to the \fCreadfds\fP and \fCexceptfds\fP file descriptor sets;
.IP "\(bu" 2
in a gtk or atspi application, use \fCg_io_add_watch\fP(fileDescriptor, \fCG_IO_IN|G_IO_ERR|G_IO_HUP\fP, \fCf\fP, \fCdata\fP) for adding a callback called \fCf\fP;
.IP "\(bu" 2
in an Xt/Xaw/motif-based application, use \fCXtAppAddInput\fP(app_context, \fCfileDescriptor\fP, \fCXtInputReadMask|XtInputExceptMask\fP, \fCf\fP, \fCdata\fP)
.IP "\(bu" 2
etc\&.
.PP
.PP
and then, when you detect inbound trafic on the file descriptor, do something like this:
.PP
while (brlapi_readKey(0, &code) { // process keycode code // \&.\&.\&. }
.PP
The \fCwhile\fP loop is needed for processing \fIall\fP pending key presses, else some of them may be left in libbrlapi's internal key buffer and you wouldn't get them immediately\&.
.PP
\fBNote:\fP
.RS 4
If the read is interrupted by a signal, \fBbrlapi_readKey()\fP will return -1, brlapi_errno will be BRLAPI_ERROR_LIBCERR and errno will be EINTR\&.
.RE
.PP
.SH "Author"
.PP
Generated automatically by Doxygen for BrlAPI from the source code\&.
|