Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all 10bit HID Consumer code. #242

Merged
merged 7 commits into from
Nov 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/kaleidoscope/hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ void initializeConsumerControl() {
}

void pressConsumerControl(Key mappedKey) {
ConsumerControl.press(mappedKey.keyCode);
ConsumerControl.press(CONSUMER(mappedKey));
}

void releaseConsumerControl(Key mappedKey) {
ConsumerControl.release(mappedKey.keyCode);
ConsumerControl.release(CONSUMER(mappedKey));
}


Expand Down
13 changes: 11 additions & 2 deletions src/key_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ typedef union Key_ {

// we assert that synthetic keys can never have keys held, so we reuse the _HELD bits
#define IS_SYSCTL B00000001
#define IS_CONSUMER B00000010
#define IS_INTERNAL B00000010
#define SWITCH_TO_KEYMAP B00000100
#define IS_INTERNAL B00001000
#define IS_CONSUMER B00001000

/* HID types we need to encode in the key flags for system and consumer control hid controls
Each key can only have one, so we don't need to use a bit vector.
Expand Down Expand Up @@ -121,3 +121,12 @@ typedef union Key_ {
#define Key_RFN2 (Key) { KEY_RIGHT_FN2, KEY_FLAGS }
#define KEY_LEFT_FN2 0xff
#define Key_LFN2 (Key) { KEY_LEFT_FN2, KEY_FLAGS }


/* Most Consumer keys are more then 8bit, the highest Consumer hid code
uses 10bit. By using the 11bit as flag to indicate a consumer keys was activate we can
use the 10 lsb as the HID Consumer code. If you need to get the keycode of a Consumer key
use the CONSUMER(key) macro this will return the 10bit keycode.
*/
#define CONSUMER(key) (key.raw & 0x03FF)
#define CONSUMER_KEY(code, flags) (Key) { .raw = (code) | ((flags | SYNTHETIC|IS_CONSUMER) << 8) }