FabGL
ESP32 Display Controller and Graphics Library
|
The PS2 Keyboard controller class. More...
#include <keyboard.h>
Public Member Functions | |
void | begin (gpio_num_t clkGPIO, gpio_num_t dataGPIO, bool generateVirtualKeys=true, bool createVKQueue=true) |
Initializes Keyboard specifying CLOCK and DATA GPIOs. More... | |
void | begin (bool generateVirtualKeys, bool createVKQueue, int PS2Port) |
Initializes Keyboard without initializing the PS/2 controller. More... | |
void | emptyVirtualKeyQueue () |
Empties the virtual keys queue. More... | |
KeyboardLayout const * | getLayout () |
Gets current keyboard layout. More... | |
void | getLEDs (bool *numLock, bool *capsLock, bool *scrollLock) |
Gets keyboard LEDs status. More... | |
int | getNextScancode (int timeOutMS=-1, bool requestResendOnTimeOut=false) |
Gets a scancode from the queue. More... | |
VirtualKey | getNextVirtualKey (bool *keyDown=nullptr, int timeOutMS=-1) |
Gets a virtual key from the queue. More... | |
PS2DeviceType | identify () |
Identifies the device attached to the PS2 port. More... | |
void | injectVirtualKey (VirtualKey virtualKey, bool keyDown, bool insert=false) |
Adds or inserts a virtual key into the virtual keys queue. More... | |
bool | isKeyboardAvailable () |
Checks if keyboard has been detected and correctly initialized. More... | |
bool | isVKDown (VirtualKey virtualKey) |
Gets the virtual keys status. More... | |
bool | lock (int timeOutMS) |
Gets exclusive access to the device. More... | |
bool | reset () |
Sends a Reset command to the keyboard. More... | |
int | scancodeAvailable () |
Gets the number of scancodes available in the queue. More... | |
void | setLayout (KeyboardLayout const *layout) |
Sets keyboard layout. More... | |
bool | setLEDs (bool numLock, bool capsLock, bool scrollLock) |
Sets keyboard LEDs status. More... | |
bool | setTypematicRateAndDelay (int repeatRateMS, int repeatDelayMS) |
Sets typematic rate and delay. More... | |
void | setUIApp (uiApp *app) |
Sets current UI app. More... | |
void | suspendVirtualKeyGeneration (bool value) |
Suspends or resume the virtual key generation task. More... | |
void | unlock () |
Releases device from exclusive access. More... | |
int | virtualKeyAvailable () |
Gets the number of virtual keys available in the queue. More... | |
int | virtualKeyToASCII (VirtualKey virtualKey) |
Converts virtual key to ASCII. More... | |
Public Attributes | |
Delegate< VirtualKey *, bool > | onVirtualKey |
Delegate called whenever a new virtual key is decoded from scancodes. More... | |
Static Public Attributes | |
static int | scancodeToVirtualKeyTaskStackSize = FABGLIB_DEFAULT_SCODETOVK_TASK_STACK_SIZE |
Stack size of the task that converts scancodes to Virtual Keys Keyboard. More... | |
The PS2 Keyboard controller class.
Keyboard connects to one port of the PS2 Controller class (fabgl::PS2Controller) and provides the logic that converts scancodes to virtual keys or ASCII (and ANSI) codes.
It optionally creates a task that waits for scan codes from the PS2 device and puts virtual keys in a queue.
The PS2 controller uses ULP coprocessor and RTC slow memory to communicate with the PS2 device.
It is possible to specify an international keyboard layout. The default is US-layout.
There are three predefined kayboard layouts: US (USA), UK (United Kingdom), DE (German), IT (Italian) and ES (Spanish). Other layout can be added inheriting from US or from any other layout.
Applications do not need to create an instance of Keyboard because an instance named Keyboard is created automatically.
Example:
fabgl::Keyboard Keyboard; // Setup pins GPIO33 for CLK and GPIO32 for DATA Keyboard.begin(GPIO_NUM_33, GPIO_NUM_32); // clk, dat // Prints name of received virtual keys while (true) Serial.printf("VirtualKey = %s\n", Keyboard.virtualKeyToString(Keyboard.getNextVirtualKey()));
Definition at line 166 of file keyboard.h.