CONSUMER(key) macro to his the magic constant

The CONSUMER(key) macro will extra the consumer keycode from the
Key. this will return a 16bit keycode as some consumer key are 10bit.
pull/242/head
SjB 7 years ago
parent 8ab23033e7
commit 49dfa476ed

@ -106,11 +106,11 @@ void initializeConsumerControl() {
} }
void pressConsumerControl(Key mappedKey) { void pressConsumerControl(Key mappedKey) {
ConsumerControl.press(mappedKey.raw & 0x03FF); ConsumerControl.press(CONSUMER(mappedKey));
} }
void releaseConsumerControl(Key mappedKey) { void releaseConsumerControl(Key mappedKey) {
ConsumerControl.release(mappedKey.raw & 0x03FF); ConsumerControl.release(CONSUMER(mappedKey));
} }

@ -123,4 +123,10 @@ typedef union Key_ {
#define Key_LFN2 (Key) { KEY_LEFT_FN2, KEY_FLAGS } #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) } #define CONSUMER_KEY(code, flags) (Key) { .raw = (code) | ((flags | SYNTHETIC|IS_CONSUMER) << 8) }

Loading…
Cancel
Save