Maintain the states of previous key states.

This commit is contained in:
László Monda
2017-11-03 13:43:16 +01:00
parent b18cb651ce
commit 05bbd28877

View File

@@ -139,44 +139,43 @@ void UpdateActiveUsbReports(void)
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) { for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) { for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
key_state_t keyState = KeyStates[slotId][keyId];
if (keyState.current) {
key_action_t action = CurrentKeymap[activeLayer][slotId][keyId];
switch (action.type) {
case KeyActionType_Keystroke:
ActiveUsbBasicKeyboardReport->modifiers |= action.keystroke.modifiers;
if (!KeyStates[slotId][keyId].current) { switch (action.keystroke.keystrokeType) {
continue; case KeystrokeType_Basic:
} if (basicScancodeIndex >= USB_BASIC_KEYBOARD_MAX_KEYS) {
break;
key_action_t action = CurrentKeymap[activeLayer][slotId][keyId]; }
switch (action.type) { ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = action.keystroke.scancode;
case KeyActionType_Keystroke: break;
ActiveUsbBasicKeyboardReport->modifiers |= action.keystroke.modifiers; case KeystrokeType_Media:
if (mediaScancodeIndex >= USB_MEDIA_KEYBOARD_MAX_KEYS) {
switch (action.keystroke.keystrokeType) { break;
case KeystrokeType_Basic: }
if (basicScancodeIndex >= USB_BASIC_KEYBOARD_MAX_KEYS) { ActiveUsbMediaKeyboardReport->scancodes[mediaScancodeIndex++] = action.keystroke.scancode;
break; break;
} case KeystrokeType_System:
ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = action.keystroke.scancode; if (systemScancodeIndex >= USB_SYSTEM_KEYBOARD_MAX_KEYS) {
break; break;
case KeystrokeType_Media: }
if (mediaScancodeIndex >= USB_MEDIA_KEYBOARD_MAX_KEYS) { ActiveUsbSystemKeyboardReport->scancodes[systemScancodeIndex++] = action.keystroke.scancode;
break; break;
} }
ActiveUsbMediaKeyboardReport->scancodes[mediaScancodeIndex++] = action.keystroke.scancode; break;
break; case KeyActionType_Mouse:
case KeystrokeType_System: processMouseAction(action);
if (systemScancodeIndex >= USB_SYSTEM_KEYBOARD_MAX_KEYS) { break;
break; case KeyActionType_SwitchKeymap:
} Keymaps_Switch(action.switchKeymap.keymapId);
ActiveUsbSystemKeyboardReport->scancodes[systemScancodeIndex++] = action.keystroke.scancode; break;
break; }
}
break;
case KeyActionType_Mouse:
processMouseAction(action);
break;
case KeyActionType_SwitchKeymap:
Keymaps_Switch(action.switchKeymap.keymapId);
break;
} }
keyState.previous = keyState.current;
} }
} }