Rename a couple of key action related type names and enum values.
This commit is contained in:
+23
-23
@@ -8,20 +8,20 @@ static uint8_t keyMasks[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
|
||||
static uint8_t ActiveLayer = LAYER_ID_BASE;
|
||||
uint8_t prevKeyStates[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
|
||||
|
||||
static inline __attribute__((always_inline)) uhk_key_t getKeycode(uint8_t slotId, uint8_t keyId)
|
||||
static inline __attribute__((always_inline)) key_action_t getKeycode(uint8_t slotId, uint8_t keyId)
|
||||
{
|
||||
if (keyId < MAX_KEY_COUNT_PER_MODULE) {
|
||||
if (keyMasks[slotId][keyId]!=0 && keyMasks[slotId][keyId]!=ActiveLayer) {
|
||||
// Mask out key presses after releasing modifier keys
|
||||
return (uhk_key_t){.type = UHK_KEY_NONE};
|
||||
return (key_action_t){.type = KEY_ACTION_NONE};
|
||||
}
|
||||
|
||||
uhk_key_t key = CurrentKeymap[ActiveLayer][slotId][keyId];
|
||||
key_action_t key = CurrentKeymap[ActiveLayer][slotId][keyId];
|
||||
keyMasks[slotId][keyId] = ActiveLayer;
|
||||
|
||||
return key;
|
||||
} else {
|
||||
return (uhk_key_t){.type = UHK_KEY_NONE};
|
||||
return (key_action_t){.type = KEY_ACTION_NONE};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ static void clearKeymasks(const uint8_t *leftKeyStates, const uint8_t *rightKeyS
|
||||
}
|
||||
}
|
||||
|
||||
static bool pressKey(uhk_key_t key, int scancodeIdx, usb_keyboard_report_t *report) {
|
||||
if (key.type != UHK_KEY_SIMPLE) {
|
||||
static bool pressKey(key_action_t key, int scancodeIdx, usb_keyboard_report_t *report) {
|
||||
if (key.type != KEY_ACTION_KEYSTROKE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ static bool hasKeyReleased(const uint8_t *prevKeyStates, const uint8_t *currKeyS
|
||||
return (!currKeyStates[keyId]) && prevKeyStates[keyId];
|
||||
}
|
||||
|
||||
static bool handleKey(uhk_key_t key, int scancodeIdx, usb_keyboard_report_t *report, const uint8_t *prevKeyStates, const uint8_t *currKeyStates, uint8_t keyId) {
|
||||
static bool handleKey(key_action_t key, int scancodeIdx, usb_keyboard_report_t *report, const uint8_t *prevKeyStates, const uint8_t *currKeyStates, uint8_t keyId) {
|
||||
switch (key.type) {
|
||||
case UHK_KEY_SIMPLE:
|
||||
case KEY_ACTION_KEYSTROKE:
|
||||
if (isKeyPressed(prevKeyStates, currKeyStates, keyId)) {
|
||||
return pressKey(key, scancodeIdx, report);
|
||||
}
|
||||
break;
|
||||
case UHK_KEY_LAYER:
|
||||
case KEY_ACTION_SWITCH_LAYER:
|
||||
if (hasKeyPressed(prevKeyStates, currKeyStates, keyId)) {
|
||||
ActiveLayer = key.layer.target;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static uint8_t mouseSpeedAccelDivisorCounter = 0;
|
||||
static uint8_t mouseSpeed = 3;
|
||||
static bool wasPreviousMouseActionWheelAction = false;
|
||||
|
||||
static void handleMouseKey(usb_mouse_report_t *report, uhk_key_t key, const uint8_t *prevKeyStates, const uint8_t *currKeyStates, uint8_t keyId)
|
||||
static void handleMouseKey(usb_mouse_report_t *report, key_action_t key, const uint8_t *prevKeyStates, const uint8_t *currKeyStates, uint8_t keyId)
|
||||
{
|
||||
if (!isKeyPressed(prevKeyStates, currKeyStates, keyId)) {
|
||||
return;
|
||||
@@ -112,43 +112,43 @@ static void handleMouseKey(usb_mouse_report_t *report, uhk_key_t key, const uint
|
||||
if (key.mouse.scrollActions) {
|
||||
if (mouseWheelDivisorCounter == MOUSE_WHEEL_DIVISOR) {
|
||||
mouseWheelDivisorCounter = 0;
|
||||
if (key.mouse.scrollActions & UHK_MOUSE_SCROLL_UP) {
|
||||
if (key.mouse.scrollActions & MOUSE_SCROLL_UP) {
|
||||
report->wheelX = 1;
|
||||
}
|
||||
if (key.mouse.scrollActions & UHK_MOUSE_SCROLL_DOWN) {
|
||||
if (key.mouse.scrollActions & MOUSE_SCROLL_DOWN) {
|
||||
report->wheelX = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key.mouse.moveActions & UHK_MOUSE_ACCELERATE || key.mouse.moveActions & UHK_MOUSE_DECELERATE) {
|
||||
if (key.mouse.moveActions & MOUSE_ACCELERATE || key.mouse.moveActions & MOUSE_DECELERATE) {
|
||||
mouseSpeedAccelDivisorCounter++;
|
||||
|
||||
if (mouseSpeedAccelDivisorCounter == MOUSE_SPEED_ACCEL_DIVISOR) {
|
||||
mouseSpeedAccelDivisorCounter = 0;
|
||||
|
||||
if (key.mouse.moveActions & UHK_MOUSE_ACCELERATE) {
|
||||
if (key.mouse.moveActions & MOUSE_ACCELERATE) {
|
||||
if (mouseSpeed < MOUSE_MAX_SPEED) {
|
||||
mouseSpeed++;
|
||||
}
|
||||
}
|
||||
if (key.mouse.moveActions & UHK_MOUSE_DECELERATE) {
|
||||
if (key.mouse.moveActions & MOUSE_DECELERATE) {
|
||||
if (mouseSpeed > 1) {
|
||||
mouseSpeed--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (key.mouse.moveActions) {
|
||||
if (key.mouse.moveActions & UHK_MOUSE_MOVE_LEFT) {
|
||||
if (key.mouse.moveActions & MOUSE_MOVE_LEFT) {
|
||||
report->x = -mouseSpeed;
|
||||
}
|
||||
if (key.mouse.moveActions & UHK_MOUSE_MOVE_RIGHT) {
|
||||
if (key.mouse.moveActions & MOUSE_MOVE_RIGHT) {
|
||||
report->x = mouseSpeed;
|
||||
}
|
||||
if (key.mouse.moveActions & UHK_MOUSE_MOVE_UP) {
|
||||
if (key.mouse.moveActions & MOUSE_MOVE_UP) {
|
||||
report->y = -mouseSpeed;
|
||||
}
|
||||
if (key.mouse.moveActions & UHK_MOUSE_MOVE_DOWN) {
|
||||
if (key.mouse.moveActions & MOUSE_MOVE_DOWN) {
|
||||
report->y = mouseSpeed;
|
||||
}
|
||||
}
|
||||
@@ -168,9 +168,9 @@ void HandleKeyboardEvents(usb_keyboard_report_t *keyboardReport, usb_mouse_repor
|
||||
break;
|
||||
}
|
||||
|
||||
uhk_key_t code = getKeycode(SLOT_ID_RIGHT_KEYBOARD_HALF, keyId);
|
||||
key_action_t code = getKeycode(SLOT_ID_RIGHT_KEYBOARD_HALF, keyId);
|
||||
|
||||
if (code.type == UHK_KEY_MOUSE) {
|
||||
if (code.type == KEY_ACTION_MOUSE) {
|
||||
handleMouseKey(mouseReport, code, prevKeyStates[SLOT_ID_RIGHT_KEYBOARD_HALF], rightKeyStates, keyId);
|
||||
} else {
|
||||
if (handleKey(code, scancodeIdx, keyboardReport, prevKeyStates[SLOT_ID_RIGHT_KEYBOARD_HALF], rightKeyStates, keyId)) {
|
||||
@@ -184,9 +184,9 @@ void HandleKeyboardEvents(usb_keyboard_report_t *keyboardReport, usb_mouse_repor
|
||||
break;
|
||||
}
|
||||
|
||||
uhk_key_t code = getKeycode(SLOT_ID_LEFT_KEYBOARD_HALF, keyId);
|
||||
key_action_t code = getKeycode(SLOT_ID_LEFT_KEYBOARD_HALF, keyId);
|
||||
|
||||
if (code.type == UHK_KEY_MOUSE) {
|
||||
if (code.type == KEY_ACTION_MOUSE) {
|
||||
handleMouseKey(mouseReport, code, prevKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], leftKeyStates, keyId);
|
||||
} else {
|
||||
if (handleKey(code, scancodeIdx, keyboardReport, prevKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], leftKeyStates, keyId)) {
|
||||
|
||||
Reference in New Issue
Block a user