My personal fork of qmk_firmware
with some additional features.
master
is kept updated usingwei/pull
.
Most of the features here are used with
garyng/ahk-utilities
and Hasu USB-USB Converter.
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!
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).
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>
.
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
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
.
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).
#define MAX_WK
inconfig.h
for the maximum number of wrapping keys used (example)- Optionally create an
enum
to name each wrapping key index (wki
) (example) - Populate
wki_to_wk
(maps index to the wrapping key) andwki_to_kc
(maps wrapping key to the original key code) (example) - Wrap your
wki
withWK
macro inside your layout (example). - Call
process_wk_user
insideprocess_record_user
(example).
#define WK_TIMEOUT
inconfig.h
to specify the timeout (in milliseconds) (example)- Initialize
default_wki
insidekeymap.c
with the defaultwk
index (example)
The default mod stack is:
Taps | Mod |
---|---|
2 | Ctrl |
3 | Alt |
#define MAX_TAM_TAPS
inconfig.h
for the maximum number of taps (example)- You might need to change
TAPPING_TERM
as well if the default is too short
- You might need to change
- Define your own mod stack by populating
tam_mod_maps[MAX_TAM_TAPS + 1]
(example) - Call
matrix_scan_tam_user()
insidematrix_scan_user
(example)
Currently, wrapping key and tap auto mod are tightly coupled to each other.