Reading key presses(3)     Library Functions Manual     Reading key presses(3)



NAME
       Reading key presses - How to read key presses from the braille
       terminal.  More...

   Defines
       #define BRL_KEYBUF_SIZE   256
       #define BRL_KEYCODE_MAX   ((brl_keycode_t) (UINT32_MAX))

   Typedefs
       typedef uint32_t brl_keycode_t

   Functions
       int brlapi_readKey (int block, brl_keycode_t *code)
       int brlapi_readCommand (int block, brl_keycode_t *code)
       int brlapi_ignoreKeyRange (brl_keycode_t x, brl_keycode_t y)
       int brlapi_ignoreKeySet (const brl_keycode_t *s, uint32_t n)
       int brlapi_unignoreKeyRange (brl_keycode_t x, brl_keycode_t y)
       int brlapi_unignoreKeySet (const brl_keycode_t *s, uint32_t n)

DETAILED DESCRIPTION
       Once brlapi_getTty() is called, the application can call
       brlapi_readKey() or brlapi_readCommand() to read key presses. Not
       everyone can be called, it depends on parameters given to
       brlapi_getTty().

       key presses are buffered, so that calling brlapi_readKey() in non-
       blocking mode from times to times should suffice.

DEFINE DOCUMENTATION
   #define BRL_KEYBUF_SIZE   256
       buffer size

       key presses won't be lost provided no more than BRL_KEYBUF_SIZE key
       presses are done between two calls to brlapi_read* if a call to another
       function is done in the meanwhile (which needs somewhere to put them
       before being able to get responses from the server)

   #define BRL_KEYCODE_MAX   ((brl_keycode_t) (UINT32_MAX))
       brl_keycode_t's biggest value

       As defined in <inttypes.h>

TYPEDEF DOCUMENTATION
   typedef uint32_t brl_keycode_t
       type for key codes

       Its size is 32 bits, so driver implementors have to restrict themselves
       to a 32 bit space.

FUNCTION DOCUMENTATION
   int brlapi_ignoreKeyRange (brl_keycode_t x, brl_keycode_t y)
       Ignore some key presses from the braille keyboard

       This function asks the server to give keys between x and y to brltty,
       rather than returning them to the application via
       brlapi_read(Key|Command)()

       Note:
           The given codes are either raw keycodes if BRLKEYCODES was given to
           brlapi_getTty(), or brltty commands if BRLCOMMANDS was given.

   int brlapi_ignoreKeySet (const brl_keycode_t * s, uint32_t n)
       Ignore some key presses from the braille keyboard

       This function asks the server to give the n keys in set s to brltty,
       rather than returning them to the application via
       brlapi_read(Key|Command)()

       Note:
           The given codes are either raw keycodes if BRLKEYCODES was given to
           brlapi_getTty(), or brltty commands if BRLCOMMANDS was given.

   int brlapi_readCommand (int block, brl_keycode_t * code)
       Read a command from the braille keyboard

       This function returns brltty commands, as described in
       <brltty/brldefs.h> . These are hence pretty driver-independent, and
       should be used by default when no other option is possible.

       It can be called only if BRLCOMMANDS was given to brlapi_getTty()

       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
       either brlapi_ignoreKeySet() or brlapi_ignoreKeyRange()

       Parameters:

       block  tells whether the call should block until a key is pressed (1)
              or should only probe key presses (0).

       code   holds the command code if a key press is indeed read.

       Returns:
           -1 on error and *code is then undefined, 0 if block was 0 and no
           key was pressed so far, or 1 and *code holds the command code.

   int brlapi_readKey (int block, brl_keycode_t * code)
       Read a key from the braille keyboard

       This function returns raw keycodes, as specified by the terminal
       driver. It generally corresponds to the code the terminal tells to the
       driver.

       This should only be used to application which are dedicated to a
       particular braille terminal. Hence, checking the terminal type thanks
       to a call to brlapi_getDriverId() or even brlapi_getDriverName() before
       getting tty control is a pretty good idea.

       It can be called only if BRLKEYCODES was given to brlapi_getTty()

       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.

       Parameters:

       block  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:
           -1 on error 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.

   int brlapi_unignoreKeyRange (brl_keycode_t x, brl_keycode_t y)
       Unignore some key presses from the braille keyboard

       This function asks the server to return keys between x and y to the
       application, and not give them to brltty.

       Note:
           You shouldn't ask the server to give you key presses which are
           usually used to switch between TTYs, unless you really know what
           you are doing !

       Note:
           The given codes are either raw keycodes if BRLKEYCODES was given to
           brlapi_getTty(), or brltty commands if BRLCOMMANDS was given.

   int brlapi_unignoreKeySet (const brl_keycode_t * s, uint32_t n)
       Unignore some key presses from the braille keyboard

       This function asks the server to return all n keys in set s to the
       application, and not give them to brltty.

       Note:
           You shouldn't ask the server to give you key presses which are
           usually used to switch between TTYs, unless you really know what
           you are doing !

       Note:
           The given codes are either raw keycodes if BRLKEYCODES was given to
           brlapi_getTty(), or brltty commands if BRLCOMMANDS was given.



BrlAPI                            13 Jul 2004           Reading key presses(3)
