Crate smart_keymap

Source
Expand description

Smart Keymap library.

A “smart keyboard” is a keyboard where the keys can perform multiple actions, depending on the context. Features such as layering, tap-hold, and tap-dance are examples of smart keyboard functionality.

The smart keymap library provides an interface for the “smart keymap” part of smart keyboard firmware. i.e. the part that takes key presses and releases as input, and outputs HID keyboard reports (or other smart keyboard outputs).

This crate can be used directly with Rust, or built as a C library.

§Usage as a C library

§Custom Keymap

When used as a C library, the library should be built by setting the environment variable SMART_KEYMAP_CUSTOM_KEYMAP to the path of a custom keymap file.

SMART_KEYMAP_CUSTOM_KEYMAP can be set either to a .ncl file, or to a .rs file (generated using the scripts under ncl/).

§Keyboard Firmware Implementation

When used as a C library, the firmware should call to keymap_init, keymap_register_input_keypress, keymap_register_input_keyrelease, and keymap_tick functions. The keymap_tick function should be called every ms, and should copy the HID keyboard report to the given buffer.

§Implementation Overview

The heart of the library is the key module, and its key::Key, key::Context, key::PressedKey traits.

These provide the interface with which ‘smart keys’ are implemented.

Modules§

  • Types and initial data used for constructing a keymap::Keymap. cbindgen:ignore
  • Structs for input to the keymap.
  • Smart key interface and implementations.
  • Keymap implementation.
  • Keys1, Keys2, etc. tuple structs for defining keymaps.