Giter Club home page Giter Club logo

keytokey's Introduction

KeyToKey

KeyToKey (K2K) is a Rust libary for building keyboard firmwares.

Basically, a keyboard firmware a) reads key-presses, b) translates them c) and outputs the results to a computer.

KeyToKey's role is in b - it takes a stream of events, such as key presses, releases and timeouts, and translates them using a series of handler trait objects into reports that can easily be converted to the format USB expects.

This is inspired by the QMK mechanical keyboard firmware, which probably is the most feature complete keyboard firmware to date. Alas it's C, and an amazing ball of ifdefs that usually needs more flash than the micros it's targeting offer.

The trait object oriented approach chosen here allows composition of arbitrarily complex keyboard layouts - and unit testing them without hardware.

To get started, maybe check out the reference firmware.

KeyToKey operates on key codes that are u32 representing unicode key points. (The USB keycodes are nested in the first 'private area' of the unicode code set, and the rest of the private area is free to be used by the keyboard implementor.)

A basic keyboard uses two handlers - a handlers::UnicodeKeyboard, which sends the OS-specific magic 'enter-an-arbitrary-unicode-keypoint' for any key code outside of the private areas, and a handlers::USBKeyboard which handles all the usual 'tell the computer which buttons are pressed' functionality including modifiers.

USBKeyboard does not limit the number of simultanious keys, but the downstream translation into USB might restrict to the usual 6 key rollover.

Basic features

  • works as a regular USB keyboard
  • arbirtrary unicode input in linux and windows

Advanced Features working

  • Layers (which can rewrite key codes, conditionally rewrite them based on shift status or send arbitrary strings, again dependeant on shift)
  • RewriteLayers (which can only rewrite key codes, but are much more memory efficient)
  • PressReleaseMacros (callbacks on key press / key release)
  • StickyMacros (Tap once to activate, again to deactivate){
  • OneShots (Press -> activate, deactivates after next any-not-one-shot key press - useful for modifiers or temporarily activated layers)
  • SpaceCadet (Do one thing on press-and-hold, a different thing on tap. For example a shift key that also outputs a '('))
  • Sequences (e.g. t e h -> the which don't intercept the keycodes, but then send a set of backspace presses, and then your action)

Advanced features planned

  • Leader sequences (e.g. hit leader h e a r t to enter a heart emoji, or an arbitrary string)
  • TapDance (count the number of taps on a key, pass the final count to a callback)
  • AutoShift - Short tap: lower case, longer tap: uppercase. Removes key repeat though.

K2K strives to seperate the triggers (when does something happen) from the actual actions. Currently actions may be arbitrary (USB) KeyCodes being registered, &str being send or callbacks (implemented via traits)

Other rust firmwares / keyboard libraries

keytokey's People

Contributors

tyberiusprime avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.