Keyboard raw codes

From F256 Foenix
Jump to navigationJump to search

Keyboard raw codes

These hex codes are part of the events that can be fetched by the MicroKernel in the event.key.raw data from event.key.PRESSED or event.key.RELEASED events (for more information, see here: MicroKernel docs)

Layout for F256K and F256K2 keyboards

The images on the right side were prepared with this website: https://www.keyboard-layout-editor.com/#/

Here are the definition JSON files that can be used in its Raw Data / Upload JSON functionality (use this if you ever need to modify these files as a starting point to your needs)

https://github.com/Mu0n/F256MiscGoodies/tree/main/keycodes


Just the keycaps
With Raw keycodes in hex

Example Usage in C

(the following is made using the llvm-mos package found here: llvm-mos

The first step is to fetch the next event in the kernel event queue:

kernelNextEvent();

Next, verify the pending event with either a switch-case block, or a if:

these two events are relevant to keyboard strokes:

kernelEventData.type == kernelEvent(key.PRESSED)
kernelEventData.type == kernelEvent(key.RELEASED)

Lastly, this is what must be checked against the raw keycodes listed above:

kernelEventData.key.raw

ie, this is a proper detection for a 'spacebar' hit:

kernelNextEvent();
if(kernelEventData.type == kernelEvent(key.PRESSED))
{
if(kernelEventData.key.raw == 0x20) printf("Spacebar was hit!");
}