---
name: "brlapi_tty"
section: "3"
platform: "linux"
package: "libbrlapi-dev"
version: "6.7-3.1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/brlapi_tty"
---

# brlapi\_tty(3)

Entering & leaving tty mode - How to take control of ttys for direct braille display / read.

## NAME

brlapi\_tty - Entering & leaving tty mode

 \- How to take control of ttys for direct braille display / read.

## SYNOPSIS

### Macros

\#define **BRLAPI\_TTY\_DEFAULT**   -1\

### Functions

int **BRLAPI\_STDCALL** **brlapi\_enterTtyMode** (int tty, const char \*driver)\
 int **BRLAPI\_STDCALL** **brlapi\_\_enterTtyMode** (**brlapi\_handle\_t** \*handle, int tty, const char \*driver)\
 int **BRLAPI\_STDCALL** **brlapi\_enterTtyModeWithPath** (const int \*ttys, int count, const char \*driver)\
 int **BRLAPI\_STDCALL** **brlapi\_\_enterTtyModeWithPath** (**brlapi\_handle\_t** \*handle, const int \*ttys, int count, const char \*driver)\
 int **BRLAPI\_STDCALL** **brlapi\_leaveTtyMode** (void)\
 int **BRLAPI\_STDCALL** **brlapi\_\_leaveTtyMode** (**brlapi\_handle\_t** \*handle)\
 int **BRLAPI\_STDCALL** **brlapi\_setFocus** (int tty)\
 int **BRLAPI\_STDCALL** **brlapi\_\_setFocus** (**brlapi\_handle\_t** \*handle, int tty)\

## Detailed Description

Before being able to write on the braille display, the application must tell the server which tty it will handle.

The application must also specify how braille keys will be delivered to it. Two ways are possible:

- •

  driver-specific keycodes: applications will get values specific to each braille driver, since the keycode, as defined in the driver will be given for each key event (press or release). Using them leads to building highly driver-dependent applications, which can yet sometimes be useful to mimic existing proprietary applications for instance.

- •

  commands: applications will get exactly the same values as *brltty*. This allows driver-independent clients, which will hopefully be nice to use with a lot of different terminals.

**See also**

**brlapi\_readKey()**

## Macro Definition Documentation

### #define BRLAPI\_TTY\_DEFAULT -1

Select the default tty.

The library takes the following steps:

- 1\.

  Try to get the tty number from the `WINDOWID` environment variable (for the `xterm` case).

- 2\.

  Try to get the tty number from the `CONTROLVT` environment variable.

- 3\.

  Read `/proc/self/stat` (on `Linux`).

**See also**

**brlapi\_enterTtyMode()**

## Function Documentation

### int BRLAPI\_STDCALL brlapi\_\_enterTtyMode (brlapi\_handle\_t \* handle, int tty, const char \* driver)

### int BRLAPI\_STDCALL brlapi\_\_enterTtyModeWithPath (brlapi\_handle\_t \* handle, const int \* ttys, int count, const char \* driver)

### int BRLAPI\_STDCALL brlapi\_\_leaveTtyMode (brlapi\_handle\_t \* handle)

### int BRLAPI\_STDCALL brlapi\_\_setFocus (brlapi\_handle\_t \* handle, int tty)

### int BRLAPI\_STDCALL brlapi\_enterTtyMode (int tty, const char \* driver)

Ask for some tty, with some key mechanism

**Parameters**

*tty*

- •

  If tty\>=0 then take control of the specified tty.

- •

  If tty==**BRLAPI\_TTY\_DEFAULT** then take control of the default tty.

*driver* tells how the application wants **brlapi\_readKey()** to return key presses. NULL or '' means BRLTTY commands are required, whereas a driver name means that driver-specific keycodes are expected.

**Returns**

the used tty number on success, -1 on error

WINDOWPATH and WINDOWID should be propagated when running remote applications via ssh, for instance, along with BRLAPI\_HOST and the authorization key (see SendEnv in [ssh\_config(5)](/ssh_config/5.md) and AcceptEnv in [sshd\_config(5)](/sshd_config/5.md))

Once **brlapi\_enterTtyMode()** is called, **brlapi\_leaveTtyMode()** has to be called before calling **brlapi\_enterTtyMode()** again.

TODO: document which functions work in TTY mode only.

**See also**

**brlapi\_leaveTtyMode()** **brlapi\_readKey()**

### int BRLAPI\_STDCALL brlapi\_enterTtyModeWithPath (const int \* ttys, int count, const char \* driver)

Ask for some tty specified by its path in the tty tree, with some key mechanism

**Parameters**

*ttys* points on the array of ttys representing the tty path to be got. Can be NULL if nttys is 0. \
 *count* gives the number of elements in ttys. \
 *driver* has the same meaning as in **brlapi\_enterTtyMode()**

Providing nttys == 0 means to get the root, which is usually what a screen readers wants to use.

The content of WINDOWPATH or XDG\_VTNR will always be prepended to the given `ttys` array, so the application does not need to determine by itself where it is running.

**Returns**

0 on success, -1 on error.

**See also**

**brlapi\_enterTtyMode()**

### int BRLAPI\_STDCALL brlapi\_leaveTtyMode (void)

Stop controlling the tty

**Returns**

0 on success, -1 on error.

**See also**

**brlapi\_enterTtyMode()**

### int BRLAPI\_STDCALL brlapi\_setFocus (int tty)

Tell the current tty to brltty

This is intended for focus tellers, such as brltty, xbrlapi, screen, ... **brlapi\_enterTtyMode()** must have been called beforehand to tell where this focus applies in the tty tree.

**Returns**

0 on success, -1 on error.

**See also**

**brlapi\_enterTtyMode()** **brlapi\_leaveTtyMode()**

## Author

Generated automatically by Doxygen for BrlAPI from the source code.
