VT100 Terminal App
Circle VT100 module documentation
Loading...
Searching...
No Matches
CTKeyboard Class Reference

Cooperative task managing keyboard devices and event translation. More...

#include <TKeyboard.h>

Inheritance diagram for CTKeyboard:

Public Types

using TKeyPressedHandler = void(*)(const char *pString)
 
using TKeyStatusHandlerRaw = void(*)(unsigned char ucModifiers, const unsigned char RawKeys[6])
 

Public Member Functions

 CTKeyboard (void)
 Construct the singleton keyboard task; dependencies are hooked via Configure().
 
void Configure (TKeyPressedHandler pKeyPressedHandler, TKeyStatusHandlerRaw pKeyStatusHandlerRaw=nullptr, CUSBHCIDevice *pUSBHost=nullptr, unsigned keyRepeatDelayMs=KeyRepeatDelayDefaultMs, unsigned keyRepeatRateCps=KeyRepeatRateDefaultCps)
 Configure callbacks and optional host controller.
 
 ~CTKeyboard (void)
 Cleanup the keyboard task on shutdown.
 
boolean Initialize (void)
 Initialize keyboard devices and start the task.
 
boolean UpdateKeyboard (boolean bDevicesUpdated)
 Check for and handle keyboard plug and play events.
 
void UpdateLEDs (void)
 Update keyboard LED state (must be called from main loop).
 
boolean IsKeyboardConnected (void) const
 Check if keyboard is connected.
 
void OnConfigUpdated ()
 Notify keyboard that configuration changed.
 
void Update ()
 Periodic update hook called from the scheduler loop.
 
void Run (void) override
 Entry point of the keyboard task.
 
void SetKeyPressedHandler (TKeyPressedHandler handler)
 Replace the key pressed handler.
 
void SetKeyStatusHandlerRaw (TKeyStatusHandlerRaw handler)
 Replace the raw key status handler.
 
TKeyPressedHandler GetKeyPressedHandler () const
 Get current key pressed handler.
 
TKeyStatusHandlerRaw GetKeyStatusHandlerRaw () const
 Get current raw key status handler.
 

Static Public Member Functions

static CTKeyboardGet (void)
 Access the singleton keyboard task instance.
 

Detailed Description

Cooperative task managing keyboard devices and event translation.

The keyboard task detects hot-plug events, surfaces processed key strings via callbacks, and maintains raw status notifications for consumers that need modifier state. It also implements configurable auto-repeat and LED updates to emulate the VT100 hardware experience.

Member Function Documentation

◆ Configure()

void CTKeyboard::Configure ( TKeyPressedHandler  pKeyPressedHandler,
TKeyStatusHandlerRaw  pKeyStatusHandlerRaw = nullptr,
CUSBHCIDevice *  pUSBHost = nullptr,
unsigned  keyRepeatDelayMs = KeyRepeatDelayDefaultMs,
unsigned  keyRepeatRateCps = KeyRepeatRateDefaultCps 
)

Configure callbacks and optional host controller.

Parameters
pKeyPressedHandlerCallback invoked for processed key strings.
pKeyStatusHandlerRawOptional callback receiving raw key status updates.
pUSBHostOptional USB host controller used for plug-and-play updates.
keyRepeatDelayMsAuto-repeat activation delay in milliseconds.
keyRepeatRateCpsAuto-repeat rate in characters per second.

◆ Initialize()

boolean CTKeyboard::Initialize ( void  )

Initialize keyboard devices and start the task.

Returns
TRUE if initialization succeeded, FALSE otherwise.

◆ IsKeyboardConnected()

boolean CTKeyboard::IsKeyboardConnected ( void  ) const

Check if keyboard is connected.

Returns
TRUE if a keyboard device is available.

◆ UpdateKeyboard()

bool CTKeyboard::UpdateKeyboard ( boolean  bDevicesUpdated)

Check for and handle keyboard plug and play events.

Parameters
bDevicesUpdatedTRUE if USB devices were updated.
Returns
TRUE if a keyboard is connected after processing.

The documentation for this class was generated from the following files: