Skip to content

Open-source keyboard firmware for Atmel AVR and Arm USB families

License

GPL-2.0, GPL-2.0 licenses found

Licenses found

GPL-2.0
LICENSE
GPL-2.0
license_GPLv2.md
Notifications You must be signed in to change notification settings

garyng/qmk_firmware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

garyng/qmk_firmware

My personal fork of qmk_firmware with some additional features.

master is kept updated using wei/pull.

Additional Features

Most of the features here are used with garyng/ahk-utilities and Hasu USB-USB Converter.

HidGeneric

HidGeneric.cpp HidGenericReportParser.cpp

Extends Hasu USB-USB Converter's firmware to allow user to implement their own HID report parser (guide). This is used for recognizing media keys on keyboards since they are ignored by the original firmware of the converter.

Thanks to @fauxpark on QMK Discord server and hasu@tmk for helping!

Wrapping Key

wrapping_key.c

A key that acts like a layer switching key, but instead of switching layers, it will switch the "wrapping key", wk. A wrapping key is a key that wraps all other keys. For example, if you pressed kc, it will wrap it and send <wk down> <kc> <wk up> instead.

You can also set a timeout so that it would automatically reset back to the default wk (guide).

Tap Auto Mod

tap_auto_mod.c

This is a combination of QMK's Tap Dance and Auto Shift with a much simplified implementation.

Depends on the configuration, it will send different <mod> with the original <kc> based on how many times you tapped the key. For example, tap twice to send Ctrl + <kc> and tap thrice to send Alt + <kc>.


Usage Guides

Implementing a custom HID report parser

Getting HID Report Descriptor with Wireshark

Launch Wireshark to capture USB data:

Unplug and plug your device > Filter by usbhid inside Wireshark:

Note: If you can't see any packets, most likely you are listening on the wrong device.

Right click on the HID Report section > Copy > Copy as Hex Stream:

You can verify whether you copied the correct data with USB Descriptor and Request Parser tool. Paste the hex values into the tool > Click on "USB HID Report Descriptor":

If you are trying to implement a report parser for media keys, look for descriptor that has a Usage of Consumer Control.

Converting HID Report Descriptor into C structs with hidrdd

Run hidrdd.ps1 with the hex stream as argument. The structs will be saved to output.c:

Note: The script uses the dockerized version of the tool at garyng/hidrdd-docker

Implementing the report parser

Take a look at HidGenericReportParser.cpp. With the structs generated, you can easily parse the *buff passed into the Parse function of the parser. The example implementation just translates the flags to the corresponding KC_ values and writes them back to report_keyboard_t.

Mapping the keys

By default unrecognized keys are ignored by the USB-USB converter, you need to add them manually and modify your keymap.c layout file accordingly. See 40b16f7fca07 for an example mapping (the keycode is mapped from the report field in the parser).

Using Wrapping Key

  1. #define MAX_WK in config.h for the maximum number of wrapping keys used (example)
  2. Optionally create an enum to name each wrapping key index (wki) (example)
  3. Populate wki_to_wk (maps index to the wrapping key) and wki_to_kc (maps wrapping key to the original key code) (example)
  4. Wrap your wki with WK macro inside your layout (example).
  5. Call process_wk_user inside process_record_user (example).

Wrapping key timeout

  1. #define WK_TIMEOUT in config.h to specify the timeout (in milliseconds) (example)
  2. Initialize default_wki inside keymap.c with the default wk index (example)

Using Tap Auto Mod

The default mod stack is:

Taps Mod
2 Ctrl
3 Alt
  1. #define MAX_TAM_TAPS in config.h for the maximum number of taps (example)
    • You might need to change TAPPING_TERM as well if the default is too short
  2. Define your own mod stack by populating tam_mod_maps[MAX_TAM_TAPS + 1] (example)
  3. Call matrix_scan_tam_user() inside matrix_scan_user (example)

Notes

Currently, wrapping key and tap auto mod are tightly coupled to each other.

About

Open-source keyboard firmware for Atmel AVR and Arm USB families

Resources

License

GPL-2.0, GPL-2.0 licenses found

Licenses found

GPL-2.0
LICENSE
GPL-2.0
license_GPLv2.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 92.6%
  • C++ 2.8%
  • Python 2.4%
  • Makefile 1.8%
  • Shell 0.3%
  • Assembly 0.1%