vtterm.keyboards

Keyboards on the USB host port and over BLE, read from a timer.

Each source has poll(), which never waits and returns a list of events.Key records (possibly empty), status, a line saying what it’s connected to, and close(). Sources look for a keyboard on their own and find it again after it’s unplugged or switched off.

vtterm.keyboards.LOOK_MS = 1000

How often a source with no keyboard looks for one, in ms.

class vtterm.keyboards.UsbKeyboard[source]

Bases: object

A keyboard on the board’s USB host port, in boot protocol.

Starting the host takes the port: a board whose REPL is on its native USB loses that until close.

class vtterm.keyboards.BleKeyboard(timeout_ms=8000)[source]

Bases: object

The first BLE keyboard advertising the HID service, as a host.

bledev runs on asyncio, and the REPL runs no event loop, so poll runs the loop’s ready tasks for one pass each time it’s called.

vtterm.keyboards.start_all()[source]

Start every keyboard source this board can have.

Returns:

tuple – (sources, missing): the sources that started, and a line for each that couldn’t, saying why.