brlapi_keys(3)
π brlapi_keys(3) β reading key presses π
okay bestie, welcome to brlapi_keys(3) from the Library Functions Manual. This page is literally about reading key presses from the braille terminal. It's giving main character energy for your app. No cap.
β¨ NAME β¨
brlapi_keys β Reading key presses
- How to read key presses from the braille terminal.
π¦ SYNOPSIS π¦
π¦ Data Structures π¦
struct brlapi_expandedKeyCode_tstruct brlapi_describedKeyCode_tstruct brlapi_range_t
π Macros π
#define brlapi_ignoreAllKeys()#define brlapi_acceptAllKeys()#define BRLAPI_UC_ROW 0x2800UL#define brlapi__ignoreAllKeys(handle)#define brlapi__acceptAllKeys(handle)
π Enumerations π
enum brlapi_rangeType_t { brlapi_rangeType_all, brlapi_rangeType_type,
brlapi_rangeType_command, brlapi_rangeType_key,
brlapi_rangeType_code }
π₯ Functions π₯
int BRLAPI_STDCALL brlapi_expandKeyCode (brlapi_keyCode_t code,
brlapi_expandedKeyCode_t *expansion)
int BRLAPI_STDCALL brlapi_describeKeyCode (brlapi_keyCode_t code,
brlapi_describedKeyCode_t *description)
int BRLAPI_STDCALL brlapi_readKey (int wait, brlapi_keyCode_t *code)
int BRLAPI_STDCALL brlapi__readKey (brlapi_handle_t *handle, int wait,
brlapi_keyCode_t *code)
int BRLAPI_STDCALL brlapi_readKeyWithTimeout (int timeout_ms,
brlapi_keyCode_t *code)
int BRLAPI_STDCALL brlapi__readKeyWithTimeout (brlapi_handle_t *handle,
int timeout_ms, brlapi_keyCode_t *code)
int BRLAPI_STDCALL brlapi_ignoreKeys (brlapi_rangeType_t type, const
brlapi_keyCode_t keys[], unsigned int count)
int BRLAPI_STDCALL brlapi__ignoreKeys (brlapi_handle_t *handle,
brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int
count)
int BRLAPI_STDCALL brlapi_acceptKeys (brlapi_rangeType_t type, const
brlapi_keyCode_t keys[], unsigned int count)
int BRLAPI_STDCALL brlapi__acceptKeys (brlapi_handle_t *handle,
brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int
count)
int BRLAPI_STDCALL brlapi__ignoreAllKeys (brlapi_handle_t *handle)
int BRLAPI_STDCALL brlapi__acceptAllKeys (brlapi_handle_t *handle)
int BRLAPI_STDCALL brlapi_ignoreKeyRanges (const brlapi_range_t
ranges[], unsigned int count)
int BRLAPI_STDCALL brlapi__ignoreKeyRanges (brlapi_handle_t *handle,
const brlapi_range_t ranges[], unsigned int count)
int BRLAPI_STDCALL brlapi_acceptKeyRanges (const brlapi_range_t
ranges[], unsigned int count)
int BRLAPI_STDCALL brlapi__acceptKeyRanges (brlapi_handle_t *handle,
const brlapi_range_t ranges[], unsigned int count)
π Detailed Description π
okay so bestie, once brlapi_enterTtyMode() has been called, the application can call brlapi_readKey() to read key presses. Either key codes (see Types and Defines for BrlAPI Key Codes) or commands will be returned, depending on parameters given to brlapi_enterTtyMode(). It's giving choose-your-own-adventure, fr fr.
Key presses are buffered, so that calling brlapi_readKey() in non-blocking mode from time to time should suffice. Lowkey perfect for a vibe check every now and then. π
πΈ Macro Definition Documentation πΈ
π #define brlapi__acceptAllKeys( handle)
Value:
brlapi__acceptKeys(handle, brlapi_rangeType_all, NULL, 0)
π #define brlapi__ignoreAllKeys( handle)
Value:
brlapi__ignoreKeys(handle, brlapi_rangeType_all, NULL, 0)
π int BRLAPI_STDCALL brlapi_acceptAllKeys( void)
Value:
brlapi_acceptKeys(brlapi_rangeType_all, NULL, 0)
Accept all key presses from the braille keyboard β periodt, they're yours now.
This function asks the server to give all keys to the application, and not give them to brltty. It's giving main character energy for your app.
Warning: after calling this function, make sure to callbrlapi_ignoreKeys()for ignoring important keys likeBRL_CMD_SWITCHVT_PREV/NEXTand such. Not me forgetting and locking myself out π
The sets of such keys are reset on brlapi_enterTtyMode call.
π int BRLAPI_STDCALL brlapi_ignoreAllKeys( void)
Value:
brlapi_ignoreKeys(brlapi_rangeType_all, NULL, 0)
Ignore all key presses from the braille keyboard β brltty can have this one, bestie.
This function asks the server to give all keys to brltty, rather than returning them to the application via brlapi_readKey(). It's giving "you handle it, I trust you" energy.
The sets of such keys are reset on brlapi_enterTtyMode call.
β¨ #define BRLAPI_UC_ROW 0x2800UL
Unicode braille row. Iconic. Slay. π
π¦ Enumeration Type Documentation π¦
enum brlapi_rangeType_t
types of key ranges β the vibe check for which keys we're talking about.
Enumerator
brlapi_rangeType_allβ all keys, code must be 0 πbrlapi_rangeType_typeβ all keys of a given type β¨brlapi_rangeType_commandβ all keys of a given command block, i.e. matching the key type and command parts πbrlapi_rangeType_keyβ a given key with any flags π¦brlapi_rangeType_codeβ a given key code πΈ
β¨ to be continued in part 2, bestie β¨
β¨ FUNCTION DOCUMENTATION β¨
Hiii bestie, welcome back π this is where it gets juicy β every single function, no skips, no cap.
π«Ά The brlapi__ double-underscore crew
okay so these are the ones with the cute lil double underscore prefix, and they all just say the same thing at the bottom: they reference BRLAPI_STDCALL. That's it. That's the whole tea. π΅
int BRLAPI_STDCALL brlapi__acceptAllKeys (brlapi_handle_t * handle)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__acceptKeyRanges (brlapi_handle_t * handle, const brlapi_range_t ranges[], unsigned int count)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__acceptKeys (brlapi_handle_t * handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__ignoreAllKeys (brlapi_handle_t * handle)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__ignoreKeyRanges (brlapi_handle_t * handle, const brlapi_range_t ranges[], unsigned int count)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__ignoreKeys (brlapi_handle_t * handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__readKey (brlapi_handle_t * handle, int wait, brlapi_keyCode_t * code)
References BRLAPI_STDCALL.
int BRLAPI_STDCALL brlapi__readKeyWithTimeout (brlapi_handle_t * handle, int timeout_ms, brlapi_keyCode_t * code)
References BRLAPI_STDCALL.
π brlapi_acceptKeyRanges
int BRLAPI_STDCALL brlapi_acceptKeyRanges (const brlapi_range_t ranges[], unsigned int count)
Accept some key presses from the braille keyboard πΉβ¨
So what this does is ask the server to hand the key ranges you give it (and yes, inclusive, meaning both ends count π) over to your application, and not let brltty have them. brltty stays in its lane, your app gets the keys.
heads up bestie: the sets of these keys get reset whenever brlapi_enterTtyMode is called. so don't be shocked when your settings ghost you after that. π»
Parameters
rangesβ the key ranges, which are inclusive, see Types and Defines for BrlAPI Key Codes about key rangescountβ number of ranges
References BRLAPI_STDCALL.
πΈ brlapi_acceptKeys
int BRLAPI_STDCALL brlapi_acceptKeys (brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count)
Accept some key presses from the braille keyboard π
This one asks the server to give the keys you listed straight to the application, and not to brltty. periodt.
same vibe check as before: the sets of such keys are reset on brlapi_enterTtyMode call. β¨
Parameters
typeβ type of keys to be ignoredkeysβ array of keys to be ignoredcountβ number of keys
References BRLAPI_STDCALL.
π¦ brlapi_describeKeyCode
int BRLAPI_STDCALL brlapi_describeKeyCode (brlapi_keyCode_t code, brlapi_describedKeyCode_t * description)
Describe the components of a key code. π it's giving detective energy, honestly.
Parameters
codeβ the keycode to be describeddescriptionβ pointer to the structure that receives the description
Returns
0on success,-1on error
References BRLAPI_STDCALL.
π brlapi_expandKeyCode
int BRLAPI_STDCALL brlapi_expandKeyCode (brlapi_keyCode_t code, brlapi_expandedKeyCode_t * expansion)
Expand the components of a key code π₯ take that lil code and unpack it, main character style.
Parameters
codeβ the key code to be expandedexpansionβ pointer to the structure that receives the components
Returns
0on success,-1on error
References BRLAPI_STDCALL.
π brlapi_ignoreKeyRanges
int BRLAPI_STDCALL brlapi_ignoreKeyRanges (const brlapi_range_t ranges[], unsigned int count)
Ignore some key presses from the braille keyboard π yes bestie, ignoring is a valid self-care strategy.
This function asks the server to give the provided key ranges to brltty, rather than returning them to the application via brlapi_readKey().
the sets of such keys are reset on brlapi_enterTtyMode call. every single time. π«
Parameters
rangesβ key ranges, which are inclusive, see Types and Defines for BrlAPI Key Codes about key rangescountβ number of ranges
References BRLAPI_STDCALL.
π§ brlapi_ignoreKeys
int BRLAPI_STDCALL brlapi_ignoreKeys (brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count)
Ignore some key presses from the braille keyboard π
This one asks the server to give the provided keys to brltty, rather than returning them to the application via brlapi_readKey().
and you already know: the sets of such keys are reset on brlapi_enterTtyMode call. π
Parameters
typeβ type of keys to be ignoredkeysβ array of keys to be ignoredcountβ number of keys
References BRLAPI_STDCALL.
π brlapi_readKey
int BRLAPI_STDCALL brlapi_readKey (int wait, brlapi_keyCode_t * code)
Read a key from the braille keyboard β¨οΈβ¨ the icon, the moment, the legend.
This function returns one key press's code.
If NULL or "" was given to brlapi_enterTtyMode(), a brltty command is returned, as described in the documentation for brlapi_keyCode_t. It is hence pretty driver-independent, and should be used by default when no other option is possible.
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 brlapi_ignoreKeys()
If a driver name was given to brlapi_enterTtyMode(), a driver-specific keycode is returned, as specified by the braille 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 brlapi_getDriverName() before getting tty control is a pretty good idea. π
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. no biggie, just so you know π
Parameters
waitβ tells whether the call should block until a key is pressed (1) or should only probe key presses (0);codeβ holds the key code if a key press is indeed read.
Returns
-1on error or signal interrupt and*codeis then undefined,0ifblockwas0and no key was pressed so far, or1and*codeholds the key code.
Programming hints: π«Ά
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.
Else, you'll probably want to use the file descriptor returned by brlapi_openConnection() or brlapi_getFileDescriptor() in your "big polling loop". For instance:
- in a
select()loop, just add it to thereadfdsandexceptfdsfile descriptor sets; - in a gtk or atspi application, use
g_io_add_watch(fileDescriptor, G_IO_IN|G_IO_ERR|G_IO_HUP, f, data)for adding a callback calledf; - in an Xt/Xaw/motif-based application, use
XtAppAddInput(app_context, fileDescriptor, XtInputReadMask|XtInputExceptMask, f, data) - etc.
and then, when you detect inbound trafic on the file descriptor, do something like this:
while (brlapi_readKey(0, &code) { // process keycode code // ... }
The while loop is needed for processing all pending key presses, else some of them may be left in libbrlapi's internal key buffer and you wouldn't get them immediately. π₯
Note π if the read is interrupted by a signal or by a parameter change notification,brlapi_readKey()will return-1,brlapi_errnowill beBRLAPI_ERROR_LIBCERRanderrnowill beEINTR.
References BRLAPI_STDCALL.
π brlapi_readKeyWithTimeout
int BRLAPI_STDCALL brlapi_readKeyWithTimeout (int timeout_ms, brlapi_keyCode_t * code)
Read a key from the braille keyboard, unless a timeout expires β³ impatient king behavior, love that for you.
This function works like brlapi_readKey, except that parameter wait is replaced by a timeout_ms parameter
Parameters
timeout_msβ specifies how long the function should wait for a keypress.codeβ holds the key code if a key press is indeed read.
Returns
-1on error, signal interrupt or parameter change notification and*codeis then undefined,0if the timeout expired and no key was pressed, or1and*codeholds the key code.
If the timeout expires without any key being pressed, 0 is returned.
If timeout_ms is set to 0, this function looks for key events that have been already received, but does not wait at all if no event was received.
If timeout_ms is set to a negative value, this function behaves like brlapi_readKey, i.e. it uses an infinite timeout.
References BRLAPI_STDCALL.
π AUTHOR π
Generated automatically by Doxygen for BrlAPI from the source code.
and that's a wrap on the whole page, bestie!! πβ¨ this was Version 0.8 of the BrlAPI manual, page brlapi_keys(3), and it lives over at the BrlAPI project. go forth and read those keys, you absolute legend ππ¦ you ate, no crumbs. bye pookie π«Άπ
π¦ where this page comes from
- fedora 43: brlapi-devel 0.8.7-4.fc43 Β· LGPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-2.0-or-later
- fedora 43: brlapi-devel 0.8.7-4.fc43 Β· LGPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-2.0-or-later
- fedora 44: brlapi-devel 0.8.7-8.fc44 Β· LGPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-2.0-or-later
- fedora 44: brlapi-devel 0.8.7-8.fc44 Β· LGPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-2.0-or-later
- opensuse-leap 16.0: brlapi-devel 6.8-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: brlapi-devel 6.8-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: brlapi-devel 6.8-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: brlapi-devel 6.8-160000.2.2 Β· LGPL-2.1-or-later
- ubuntu resolute: libbrlapi-dev 6.7-1ubuntu6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms