|
|
@ -1,5 +1,6 @@
|
|
|
|
#include "Kaleidoscope.h"
|
|
|
|
#include "Kaleidoscope.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) {
|
|
|
|
static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) {
|
|
|
|
if (mappedKey.flags & RESERVED)
|
|
|
|
if (mappedKey.flags & RESERVED)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -10,15 +11,17 @@ static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) {
|
|
|
|
if (mappedKey.flags & IS_INTERNAL) {
|
|
|
|
if (mappedKey.flags & IS_INTERNAL) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else if (mappedKey.flags & IS_CONSUMER) {
|
|
|
|
} else if (mappedKey.flags & IS_CONSUMER) {
|
|
|
|
if (keyIsPressed(keyState))
|
|
|
|
if (keyIsPressed(keyState)) {
|
|
|
|
ConsumerControl.press(mappedKey.keyCode);
|
|
|
|
pressConsumer(mappedKey);
|
|
|
|
else if (keyWasPressed(keyState))
|
|
|
|
} else if (keyWasPressed(keyState)) {
|
|
|
|
ConsumerControl.release(mappedKey.keyCode);
|
|
|
|
releaseConsumer(mappedKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
} else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
if (keyIsPressed(keyState))
|
|
|
|
if (keyIsPressed(keyState)) {
|
|
|
|
SystemControl.press(mappedKey.keyCode);
|
|
|
|
pressSystem(mappedKey);
|
|
|
|
else if (keyWasPressed(keyState))
|
|
|
|
} else if (keyWasPressed(keyState)) {
|
|
|
|
SystemControl.release();
|
|
|
|
releaseSystem(mappedKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (mappedKey.flags & SWITCH_TO_KEYMAP) {
|
|
|
|
} else if (mappedKey.flags & SWITCH_TO_KEYMAP) {
|
|
|
|
// Should not happen, handled elsewhere.
|
|
|
|
// Should not happen, handled elsewhere.
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,57 +43,137 @@ static bool handleKeyswitchEventDefault(Key mappedKey, byte row, byte col, uint8
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
|
|
|
if (!(keyState & INJECTED)) {
|
|
|
|
|
|
|
|
mappedKey = Layer.lookup(row, col);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (byte i = 0; Kaleidoscope.eventHandlers[i] != NULL && i < HOOK_MAX; i++) {
|
|
|
|
|
|
|
|
Kaleidoscope_::eventHandlerHook handler = Kaleidoscope.eventHandlers[i];
|
|
|
|
|
|
|
|
mappedKey = (*handler)(mappedKey, row, col, keyState);
|
|
|
|
|
|
|
|
if (mappedKey.raw == Key_NoKey.raw)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mappedKey = Layer.eventHandler(mappedKey, row, col, keyState);
|
|
|
|
|
|
|
|
if (mappedKey.raw == Key_NoKey.raw)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
handleKeyswitchEventDefault(mappedKey, row, col, keyState);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pressKeyRaw(Key mappedKey) {
|
|
|
|
|
|
|
|
Keyboard.press(mappedKey.keyCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void pressKey(Key mappedKey) {
|
|
|
|
void pressKey(Key mappedKey) {
|
|
|
|
if (mappedKey.flags & SHIFT_HELD) {
|
|
|
|
if (mappedKey.flags & SHIFT_HELD) {
|
|
|
|
Keyboard.press(Key_LeftShift.keyCode);
|
|
|
|
pressKeyRaw(Key_LeftShift);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & CTRL_HELD) {
|
|
|
|
if (mappedKey.flags & CTRL_HELD) {
|
|
|
|
Keyboard.press(Key_LeftControl.keyCode);
|
|
|
|
pressKeyRaw(Key_LeftControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & LALT_HELD) {
|
|
|
|
if (mappedKey.flags & LALT_HELD) {
|
|
|
|
Keyboard.press(Key_LeftAlt.keyCode);
|
|
|
|
pressKeyRaw(Key_LeftAlt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & RALT_HELD) {
|
|
|
|
if (mappedKey.flags & RALT_HELD) {
|
|
|
|
Keyboard.press(Key_RightAlt.keyCode);
|
|
|
|
pressKeyRaw(Key_RightAlt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & GUI_HELD) {
|
|
|
|
if (mappedKey.flags & GUI_HELD) {
|
|
|
|
Keyboard.press(Key_LeftGui.keyCode);
|
|
|
|
pressKeyRaw(Key_LeftGui);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Keyboard.press(mappedKey.keyCode);
|
|
|
|
|
|
|
|
|
|
|
|
pressKeyRaw(mappedKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void releaseKeyRaw(Key mappedKey) {
|
|
|
|
|
|
|
|
Keyboard.release(mappedKey.keyCode);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void releaseAllKeys() {
|
|
|
|
|
|
|
|
Keyboard.releaseAll();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void releaseKey(Key mappedKey) {
|
|
|
|
void releaseKey(Key mappedKey) {
|
|
|
|
if (mappedKey.flags & SHIFT_HELD) {
|
|
|
|
if (mappedKey.flags & SHIFT_HELD) {
|
|
|
|
Keyboard.release(Key_LeftShift.keyCode);
|
|
|
|
releaseKeyRaw(Key_LeftShift);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & CTRL_HELD) {
|
|
|
|
if (mappedKey.flags & CTRL_HELD) {
|
|
|
|
Keyboard.release(Key_LeftControl.keyCode);
|
|
|
|
releaseKeyRaw(Key_LeftControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & LALT_HELD) {
|
|
|
|
if (mappedKey.flags & LALT_HELD) {
|
|
|
|
Keyboard.release(Key_LeftAlt.keyCode);
|
|
|
|
releaseKeyRaw(Key_LeftAlt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & RALT_HELD) {
|
|
|
|
if (mappedKey.flags & RALT_HELD) {
|
|
|
|
Keyboard.release(Key_RightAlt.keyCode);
|
|
|
|
releaseKeyRaw(Key_RightAlt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.flags & GUI_HELD) {
|
|
|
|
if (mappedKey.flags & GUI_HELD) {
|
|
|
|
Keyboard.release(Key_LeftGui.keyCode);
|
|
|
|
releaseKeyRaw(Key_LeftGui);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Keyboard.release(mappedKey.keyCode);
|
|
|
|
releaseKeyRaw(mappedKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
|
|
|
if (!(keyState & INJECTED)) {
|
|
|
|
|
|
|
|
mappedKey = Layer.lookup(row, col);
|
|
|
|
|
|
|
|
}
|
|
|
|
void sendKeyboardReport() {
|
|
|
|
for (byte i = 0; Kaleidoscope.eventHandlers[i] != NULL && i < HOOK_MAX; i++) {
|
|
|
|
Keyboard.sendReport();
|
|
|
|
Kaleidoscope_::eventHandlerHook handler = Kaleidoscope.eventHandlers[i];
|
|
|
|
}
|
|
|
|
mappedKey = (*handler)(mappedKey, row, col, keyState);
|
|
|
|
|
|
|
|
if (mappedKey.raw == Key_NoKey.raw)
|
|
|
|
void pressConsumer(Key mappedKey) {
|
|
|
|
return;
|
|
|
|
ConsumerControl.press(mappedKey.keyCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mappedKey = Layer.eventHandler(mappedKey, row, col, keyState);
|
|
|
|
|
|
|
|
if (mappedKey.raw == Key_NoKey.raw)
|
|
|
|
void releaseConsumer(Key mappedKey) {
|
|
|
|
return;
|
|
|
|
ConsumerControl.release(mappedKey.keyCode);
|
|
|
|
handleKeyswitchEventDefault(mappedKey, row, col, keyState);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pressSystem(Key mappedKey) {
|
|
|
|
|
|
|
|
SystemControl.press(mappedKey.keyCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void releaseSystem(Key mappedKey) {
|
|
|
|
|
|
|
|
SystemControl.release();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Mouse events
|
|
|
|
|
|
|
|
* See above for commentary on connectionMask. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void moveMouse(signed char x, signed char y, signed char wheel) {
|
|
|
|
|
|
|
|
Mouse.move(x, y, wheel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clickMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
Mouse.click(buttons);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pressMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
Mouse.press(buttons);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void releaseMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
Mouse.release(buttons);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Absolute mouse (grapahics tablet) events
|
|
|
|
|
|
|
|
* See above for commentary on connectionMask. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void moveAbsoluteMouse(signed char x, signed char y, signed char wheel) {
|
|
|
|
|
|
|
|
AbsoluteMouse.move(x, y, wheel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void moveAbsoluteMouseTo(uint16_t x, uint16_t y, signed char wheel) {
|
|
|
|
|
|
|
|
AbsoluteMouse.moveTo(x, y, wheel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clickAbsoluteMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
AbsoluteMouse.click(buttons);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pressAbsoluteMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
AbsoluteMouse.press(buttons);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void releaseAbsoluteMouseButtons(uint8_t buttons) {
|
|
|
|
|
|
|
|
AbsoluteMouse.release(buttons);
|
|
|
|
}
|
|
|
|
}
|
|
|
|