Skip to content

File keyboard.cpp

FileList > keyboard > keyboard.cpp

Go to the source code of this file

Implementation of keyboard functions and keymaps. More...

  • #include "keyboard.hpp"
  • #include "keys.hpp"

Public Attributes

Type Name
bool altLock = false
bool backlightState = true
bool capsLock = false
uint8_t cols = {0, 3, 19, 12, 18, 6, 7}
bool ctrlLock = false
uint8_t currentBrightness = 119
char defaultKeymap = /* multi line expression */
uint8_t emptyData = {0x00, false, false, false, false, false, false}
uint8_t keyInfo = {0x00, false, false, false, false, false, false}
unsigned long keyRepeatStart = 0
KeyState keyStates
uint8_t keymapIndex = 0
bool lastValue
uint8_t rows = {1, 4, 5, 11, 13}
uint8_t sendData = {0x00, false, false, false, false, false, false}
bool sendDataFlag = false
char symbolKeymap1 = /* multi line expression */
char symbolKeymap2 = /* multi line expression */
char symbolKeymap3 = /* multi line expression */
char symbolKeymap4 = /* multi line expression */
char symbolKeymap5 = /* multi line expression */
char symbolKeymap6 = /* multi line expression */
char symbolKeymap7 = /* multi line expression */
char symbolKeymap8 = /* multi line expression */
bool symbolLock = false

Public Functions

Type Name
void autoResetKeymapIndex ()
Handles resetting the keymap index.
bool doesKeyExistInKeymap (int rowIndex, int colIndex, char keymap)
Checks if a key exists in the keymap.
void handleCharacter (int rowIndex, int colIndex)
Handles the character for a specific key.
bool keyHeld (int rowIndex, int colIndex)
Checks if a key is being held.
bool keyNotPressed (int rowIndex, int colIndex)
Checks if a key is not pressed.
bool keyPressed (int rowIndex, int colIndex)
Checks if a key was pressed.
bool keyReleased (int rowIndex, int colIndex)
Checks if a key was released.
void onRequest ()
Handles I2C requests.
void printKeyInfo (uint8_t data)
Prints the key information.
void readKeyMatrix ()
Reads the key matrix and updates the key states.
void sendKeyInfo ()
Sends the key information over I2C.
void setDefaultCharacter (int rowIndex, int colIndex)
Sets the default character for a key.
void setKeyboardBrightness (uint8_t command)
Sets the keyboard backlight brightness.
void setSymbolCharacter (int rowIndex, int colIndex)
Sets the symbol character for a key.

Detailed Description

Author:

hreikin (hreikin@gmail.com) @license MIT

Copyright:

Copyright (c) 2025 hreikin (hreikin@gmail.com)

Date:

2025-03-07

Public Attributes Documentation

variable altLock

bool altLock;

variable backlightState

bool backlightState;

variable capsLock

bool capsLock;

variable cols

uint8_t cols[];

variable ctrlLock

bool ctrlLock;

variable currentBrightness

uint8_t currentBrightness;

variable defaultKeymap

char defaultKeymap[ROW_COUNT][COL_COUNT];

variable emptyData

uint8_t emptyData[KEY_INFO_SIZE];

variable keyInfo

uint8_t keyInfo[KEY_INFO_SIZE];

variable keyRepeatStart

unsigned long keyRepeatStart;

variable keyStates

KeyState keyStates[ROW_COUNT][COL_COUNT];

variable keymapIndex

uint8_t keymapIndex;

variable lastValue

bool lastValue[ROW_COUNT][COL_COUNT];

variable rows

uint8_t rows[];

variable sendData

uint8_t sendData[KEY_INFO_SIZE];

variable sendDataFlag

bool sendDataFlag;

variable symbolKeymap1

char symbolKeymap1[ROW_COUNT][COL_COUNT];

variable symbolKeymap2

char symbolKeymap2[ROW_COUNT][COL_COUNT];

variable symbolKeymap3

char symbolKeymap3[ROW_COUNT][COL_COUNT];

variable symbolKeymap4

char symbolKeymap4[ROW_COUNT][COL_COUNT];

variable symbolKeymap5

char symbolKeymap5[ROW_COUNT][COL_COUNT];

variable symbolKeymap6

char symbolKeymap6[ROW_COUNT][COL_COUNT];

variable symbolKeymap7

char symbolKeymap7[ROW_COUNT][COL_COUNT];

variable symbolKeymap8

char symbolKeymap8[ROW_COUNT][COL_COUNT];

variable symbolLock

bool symbolLock;

Public Functions Documentation

function autoResetKeymapIndex

Handles resetting the keymap index.

void autoResetKeymapIndex () 


function doesKeyExistInKeymap

Checks if a key exists in the keymap.

bool doesKeyExistInKeymap (
    int rowIndex,
    int colIndex,
    char keymap
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.
  • keymap The keymap to check.

Returns:

true if the key exists in the keymap, false otherwise.


function handleCharacter

Handles the character for a specific key.

void handleCharacter (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

function keyHeld

Checks if a key is being held.

bool keyHeld (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key is being held, false otherwise.


function keyNotPressed

Checks if a key is not pressed.

bool keyNotPressed (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key is not pressed, false otherwise.


function keyPressed

Checks if a key was pressed.

bool keyPressed (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key was pressed, false otherwise.


function keyReleased

Checks if a key was released.

bool keyReleased (
    int rowIndex,
    int colIndex
) 

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

Returns:

true if the key was released, false otherwise.


function onRequest

Handles I2C requests.

void onRequest () 

Sends the key data over I2C when requested.


function printKeyInfo

Prints the key information.

void printKeyInfo (
    uint8_t data
) 

Parameters:

  • data The key data array.

function readKeyMatrix

Reads the key matrix and updates the key states.

void readKeyMatrix () 


function sendKeyInfo

Sends the key information over I2C.

void sendKeyInfo () 


function setDefaultCharacter

Sets the default character for a key.

void setDefaultCharacter (
    int rowIndex,
    int colIndex
) 

Sets keyInfo to the correct character for a specific key, from the default keymap only.

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.

function setKeyboardBrightness

Sets the keyboard backlight brightness.

void setKeyboardBrightness (
    uint8_t command
) 

Parameters:

  • command The command to set the brightness (toggle, up, down).

function setSymbolCharacter

Sets the symbol character for a key.

void setSymbolCharacter (
    int rowIndex,
    int colIndex
) 

Sets keyInfo to the correct character for a specific key, from the symbol keymaps only.

Parameters:

  • rowIndex The row index of the key.
  • colIndex The column index of the key.


The documentation for this class was generated from the following file keyboard/keyboard.cpp