Merge branch 'master' into dev

# Conflicts:
#	right/src/timer.c
#	right/src/timer.h
#	right/src/usb_report_updater.c
This commit is contained in:
Kristian Sloth Lauszus
2018-06-30 22:27:52 +02:00
15 changed files with 311 additions and 115 deletions

View File

@@ -21,7 +21,7 @@ void RunWatchdog(void)
cntr++; cntr++;
if (cntr==100) { /* we get called from KEY_SCANNER_HANDLER() which runs at 1ms, thus scaling down by 100 here to get 100 ms period */ if (cntr==100) { /* we get called from KEY_SCANNER_HANDLER() which runs at 1ms, thus scaling down by 100 here to get 100 ms period */
cntr=0; cntr=0;
TEST_LED_TOGGLE(); TestLed_Toggle();
I2cWatchdog_WatchCounter++; I2cWatchdog_WatchCounter++;
if (I2cWatchdog_WatchCounter>10) { /* do not check within the first 1000 ms, as I2C might not be running yet */ if (I2cWatchdog_WatchCounter>10) { /* do not check within the first 1000 ms, as I2C might not be running yet */

View File

@@ -84,7 +84,7 @@ void InitPeripherals(void)
{ {
initInterruptPriorities(); initInterruptPriorities();
InitLedDriver(); InitLedDriver();
InitTestLed(); TestLed_Init();
LedPwm_Init(); LedPwm_Init();
DebugOverSpi_Init(); DebugOverSpi_Init();
initI2c(); initI2c();

View File

@@ -42,7 +42,7 @@ void SlaveRxHandler(void)
case SlaveCommand_SetTestLed: case SlaveCommand_SetTestLed:
TxMessage.length = 0; TxMessage.length = 0;
bool isLedOn = RxMessage.data[1]; bool isLedOn = RxMessage.data[1];
TEST_LED_SET(isLedOn); TestLed_Set(isLedOn);
break; break;
case SlaveCommand_SetLedPwmBrightness: case SlaveCommand_SetLedPwmBrightness:
TxMessage.length = 0; TxMessage.length = 0;

View File

@@ -1,10 +1,10 @@
#include "test_led.h" #include "test_led.h"
#include "fsl_port.h" #include "fsl_port.h"
extern void InitTestLed(void) extern void TestLed_Init(void)
{ {
CLOCK_EnableClock(TEST_LED_CLOCK); CLOCK_EnableClock(TEST_LED_CLOCK);
PORT_SetPinMux(TEST_LED_PORT, TEST_LED_PIN, kPORT_MuxAsGpio); PORT_SetPinMux(TEST_LED_PORT, TEST_LED_PIN, kPORT_MuxAsGpio);
GPIO_PinInit(TEST_LED_GPIO, TEST_LED_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0}); GPIO_PinInit(TEST_LED_GPIO, TEST_LED_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0});
TEST_LED_ON(); TestLed_On();
} }

View File

@@ -15,13 +15,28 @@
#define TEST_LED_CLOCK kCLOCK_PortB #define TEST_LED_CLOCK kCLOCK_PortB
#define TEST_LED_PIN 13 #define TEST_LED_PIN 13
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN) static inline void TestLed_On(void)
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN) {
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, (state)) GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN) }
static inline void TestLed_Off(void)
{
GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
}
static inline void TestLed_Set(bool state)
{
GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, state);
}
static inline void TestLed_Toggle(void)
{
GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
}
// Functions: // Functions:
void InitTestLed(void); void TestLed_Init(void);
#endif #endif

View File

@@ -60,7 +60,7 @@ parser_error_t parseScrollMouseMacroAction(config_buffer_t *buffer, macro_action
parser_error_t parseDelayMacroAction(config_buffer_t *buffer, macro_action_t *macroAction) parser_error_t parseDelayMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
{ {
int16_t delay = ReadInt16(buffer); uint16_t delay = ReadUInt16(buffer);
macroAction->type = MacroActionType_Delay; macroAction->type = MacroActionType_Delay;
macroAction->delay.delay = delay; macroAction->delay.delay = delay;

View File

@@ -157,7 +157,7 @@ void InitPeripherals(void)
InitMergeSensor(); InitMergeSensor();
ADC_Init(); ADC_Init();
initI2c(); initI2c();
InitTestLed(); TestLed_Init();
LedPwm_Init(); LedPwm_Init();
InitI2cWatchdog(); InitI2cWatchdog();
InitKeyDebouncer(); InitKeyDebouncer();

View File

@@ -7,7 +7,7 @@
void PIT_KEY_DEBOUNCER_HANDLER(void) void PIT_KEY_DEBOUNCER_HANDLER(void)
{ {
TEST_LED_TOGGLE(); TestLed_Toggle();
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++) {
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter; uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;

View File

@@ -1,6 +1,7 @@
#include "macros.h" #include "macros.h"
#include "config_parser/parse_macro.h" #include "config_parser/parse_macro.h"
#include "config_parser/config_globals.h" #include "config_parser/config_globals.h"
#include "timer.h"
macro_reference_t AllMacros[MAX_MACRO_NUM]; macro_reference_t AllMacros[MAX_MACRO_NUM];
uint8_t AllMacrosCount; uint8_t AllMacrosCount;
@@ -18,69 +19,102 @@ uint8_t characterToScancode(char character)
{ {
switch (character) { switch (character) {
case 'A' ... 'Z': case 'A' ... 'Z':
return 0;
case 'a' ... 'z': case 'a' ... 'z':
return 0; return HID_KEYBOARD_SC_A - 1 + (character & 0x1F);
case '1' ... '9': case '1' ... '9':
return 0; return HID_KEYBOARD_SC_1_AND_EXCLAMATION - 1 + (character & 0x0F);
case ')': case ')':
case '0': case '0':
return 0; return HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS;
case '!': case '!':
return 0; return HID_KEYBOARD_SC_1_AND_EXCLAMATION;
case '@': case '@':
return 0; return HID_KEYBOARD_SC_2_AND_AT;
case '#': case '#':
return 0; return HID_KEYBOARD_SC_3_AND_HASHMARK;
case '$': case '$':
return 0; return HID_KEYBOARD_SC_4_AND_DOLLAR;
case '%': case '%':
return 0; return HID_KEYBOARD_SC_5_AND_PERCENTAGE;
case '^': case '^':
return 0; return HID_KEYBOARD_SC_6_AND_CARET;
case '&': case '&':
return 0; return HID_KEYBOARD_SC_7_AND_AMPERSAND;
case '*': case '*':
return 0; return HID_KEYBOARD_SC_8_AND_ASTERISK;
case '(': case '(':
return 0; return HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS;
case '`': case '`':
case '~': case '~':
return 0; return HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE;
case '[': case '[':
case '{': case '{':
return 0; return HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE;
case ']': case ']':
case '}': case '}':
return 0; return HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE;
case ';': case ';':
case ':': case ':':
return 0; return HID_KEYBOARD_SC_SEMICOLON_AND_COLON;
case '\'': case '\'':
case '\"': case '\"':
return 0; return HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE;
case '+': case '+':
case '=': case '=':
return 0; return HID_KEYBOARD_SC_EQUAL_AND_PLUS;
case '\\': case '\\':
case '|': case '|':
return 0; return HID_KEYBOARD_SC_BACKSLASH_AND_PIPE;
case '.': case '.':
case '>': case '>':
return 0; return HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN;
case ',': case ',':
case '<': case '<':
return 0; return HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN;
case '/': case '/':
case '\?': case '\?':
return 0; return HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK;
case '-': case '-':
case '_': case '_':
return 0; return HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE;
case '\n':
return HID_KEYBOARD_SC_ENTER;
case ' ':
return HID_KEYBOARD_SC_SPACE;
} }
return 0; return 0;
} }
bool characterToShift(char character)
{
switch (character) {
case 'A' ... 'Z':
case ')':
case '!':
case '@':
case '#':
case '$':
case '%':
case '^':
case '&':
case '*':
case '(':
case '~':
case '{':
case '}':
case ':':
case '\"':
case '+':
case '|':
case '>':
case '<':
case '\?':
case '_':
return true;
}
return false;
}
void addBasicScancode(uint8_t scancode) void addBasicScancode(uint8_t scancode)
{ {
if (!scancode) { if (!scancode) {
@@ -184,89 +218,183 @@ void deleteSystemScancode(uint8_t scancode)
} }
} }
bool processKeyMacroAction(void) void addScancode(uint16_t scancode, macro_sub_action_t type)
{
switch (type) {
case KeystrokeType_Basic:
addBasicScancode(scancode);
break;
case KeystrokeType_Media:
addMediaScancode(scancode);
break;
case KeystrokeType_System:
addSystemScancode(scancode);
break;
}
}
void deleteScancode(uint16_t scancode, macro_sub_action_t type)
{
switch (type) {
case KeystrokeType_Basic:
deleteBasicScancode(scancode);
break;
case KeystrokeType_Media:
deleteMediaScancode(scancode);
break;
case KeystrokeType_System:
deleteSystemScancode(scancode);
break;
}
}
bool processKeyAction(void)
{ {
static bool pressStarted; static bool pressStarted;
switch (currentMacroAction.key.action) { switch (currentMacroAction.key.action) {
case MacroSubAction_Press: case MacroSubAction_Tap:
if (!pressStarted) { if (!pressStarted) {
pressStarted = true; pressStarted = true;
addModifiers(currentMacroAction.key.modifierMask); addModifiers(currentMacroAction.key.modifierMask);
switch (currentMacroAction.key.type) { addScancode(currentMacroAction.key.scancode, currentMacroAction.key.type);
case KeystrokeType_Basic:
addBasicScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_Media:
// addMediaScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_System:
addSystemScancode(currentMacroAction.key.scancode);
break;
}
return true; return true;
} }
pressStarted = false; pressStarted = false;
deleteModifiers(currentMacroAction.key.modifierMask); deleteModifiers(currentMacroAction.key.modifierMask);
switch (currentMacroAction.key.type) { deleteScancode(currentMacroAction.key.scancode, currentMacroAction.key.type);
case KeystrokeType_Basic:
deleteBasicScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_Media:
// deleteMediaScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_System:
deleteSystemScancode(currentMacroAction.key.scancode);
break;
}
break; break;
case MacroSubAction_Release: case MacroSubAction_Release:
deleteModifiers(currentMacroAction.key.modifierMask); deleteModifiers(currentMacroAction.key.modifierMask);
switch (currentMacroAction.key.type) { deleteScancode(currentMacroAction.key.scancode, currentMacroAction.key.type);
case KeystrokeType_Basic:
deleteBasicScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_Media:
// deleteMediaScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_System:
deleteSystemScancode(currentMacroAction.key.scancode);
break;
}
break; break;
case MacroSubAction_Hold: case MacroSubAction_Press:
addModifiers(currentMacroAction.key.modifierMask); addModifiers(currentMacroAction.key.modifierMask);
switch (currentMacroAction.key.type) { addScancode(currentMacroAction.key.scancode, currentMacroAction.key.type);
case KeystrokeType_Basic:
addBasicScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_Media:
// addMediaScancode(currentMacroAction.key.scancode);
break;
case KeystrokeType_System:
addSystemScancode(currentMacroAction.key.scancode);
break;
}
break; break;
} }
return false; return false;
} }
bool processDelayAction(void)
{
static bool inDelay;
static uint32_t delayStart;
if (inDelay) {
if (Timer_GetElapsedTime(&delayStart) >= currentMacroAction.delay.delay) {
inDelay = false;
}
} else {
Timer_SetCurrentTime(&delayStart);
inDelay = true;
}
return inDelay;
}
bool processMouseButtonAction(void)
{
static bool pressStarted;
switch (currentMacroAction.key.action) {
case MacroSubAction_Tap:
if (!pressStarted) {
pressStarted = true;
MacroMouseReport.buttons |= currentMacroAction.mouseButton.mouseButtonsMask;
return true;
}
pressStarted = false;
MacroMouseReport.buttons &= ~currentMacroAction.mouseButton.mouseButtonsMask;
break;
case MacroSubAction_Release:
MacroMouseReport.buttons &= ~currentMacroAction.mouseButton.mouseButtonsMask;
break;
case MacroSubAction_Press:
MacroMouseReport.buttons |= currentMacroAction.mouseButton.mouseButtonsMask;
break;
}
return false;
}
bool processMoveMouseAction(void)
{
static bool inMotion;
if (inMotion) {
MacroMouseReport.x = 0;
MacroMouseReport.y = 0;
inMotion = false;
} else {
MacroMouseReport.x = currentMacroAction.moveMouse.x;
MacroMouseReport.y = currentMacroAction.moveMouse.y;
inMotion = true;
}
return inMotion;
}
bool processScrollMouseAction(void)
{
static bool inMotion;
if (inMotion) {
MacroMouseReport.wheelX = 0;
MacroMouseReport.wheelY = 0;
inMotion = false;
} else {
MacroMouseReport.wheelX = currentMacroAction.scrollMouse.x;
MacroMouseReport.wheelY = currentMacroAction.scrollMouse.y;
inMotion = true;
}
return inMotion;
}
bool processTextAction(void)
{
static uint16_t textIndex;
static uint8_t reportIndex = USB_BASIC_KEYBOARD_MAX_KEYS;
char character;
uint8_t scancode;
if (textIndex == currentMacroAction.text.textLen) {
textIndex = 0;
reportIndex = USB_BASIC_KEYBOARD_MAX_KEYS;
memset(&MacroBasicKeyboardReport, 0, sizeof MacroBasicKeyboardReport);
return false;
}
if (reportIndex == USB_BASIC_KEYBOARD_MAX_KEYS) {
reportIndex = 0;
memset(&MacroBasicKeyboardReport, 0, sizeof MacroBasicKeyboardReport);
return true;
}
character = currentMacroAction.text.text[textIndex];
scancode = characterToScancode(character);
for (uint8_t i = 0; i < reportIndex; i++) {
if (MacroBasicKeyboardReport.scancodes[i] == scancode) {
reportIndex = USB_BASIC_KEYBOARD_MAX_KEYS;
return true;
}
}
MacroBasicKeyboardReport.scancodes[reportIndex++] = scancode;
MacroBasicKeyboardReport.modifiers = characterToShift(character) ? HID_KEYBOARD_MODIFIER_LEFTSHIFT : 0;
++textIndex;
return true;
}
bool processCurrentMacroAction(void) bool processCurrentMacroAction(void)
{ {
switch (currentMacroAction.type) { switch (currentMacroAction.type) {
case MacroActionType_Delay: case MacroActionType_Delay:
return false; return processDelayAction();
case MacroActionType_Key: case MacroActionType_Key:
return processKeyMacroAction(); return processKeyAction();
case MacroActionType_MouseButton: case MacroActionType_MouseButton:
return false; return processMouseButtonAction();
case MacroActionType_MoveMouse: case MacroActionType_MoveMouse:
return false; return processMoveMouseAction();
case MacroActionType_ScrollMouse: case MacroActionType_ScrollMouse:
return false; return processScrollMouseAction();
case MacroActionType_Text: case MacroActionType_Text:
return false; return processTextAction();
} }
return false; return false;
} }

View File

@@ -20,8 +20,8 @@
} macro_reference_t; } macro_reference_t;
typedef enum { typedef enum {
MacroSubAction_Tap,
MacroSubAction_Press, MacroSubAction_Press,
MacroSubAction_Hold,
MacroSubAction_Release, MacroSubAction_Release,
} macro_sub_action_t; } macro_sub_action_t;
@@ -55,7 +55,7 @@
int16_t y; int16_t y;
} ATTR_PACKED scrollMouse; } ATTR_PACKED scrollMouse;
struct { struct {
int16_t delay; uint16_t delay;
} ATTR_PACKED delay; } ATTR_PACKED delay;
struct { struct {
const char *text; const char *text;

View File

@@ -1,10 +1,31 @@
#include "test_led.h" #include "test_led.h"
#include "fsl_port.h" #include "fsl_port.h"
#include "timer.h"
void InitTestLed(void) void TestLed_Init(void)
{ {
CLOCK_EnableClock(TEST_LED_CLOCK); CLOCK_EnableClock(TEST_LED_CLOCK);
PORT_SetPinMux(TEST_LED_GPIO_PORT, TEST_LED_GPIO_PIN, kPORT_MuxAsGpio); PORT_SetPinMux(TEST_LED_GPIO_PORT, TEST_LED_GPIO_PIN, kPORT_MuxAsGpio);
GPIO_PinInit(TEST_LED_GPIO, TEST_LED_GPIO_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1}); GPIO_PinInit(TEST_LED_GPIO, TEST_LED_GPIO_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
TEST_LED_ON(); TestLed_On();
}
void TestLed_Blink(uint8_t times)
{
TestLed_Off();
Timer_Delay(500);
if (!times) {
TestLed_On();
Timer_Delay(500);
TestLed_Off();
Timer_Delay(500);
return;
}
while (times--) {
TestLed_On();
Timer_Delay(100);
TestLed_Off();
Timer_Delay(100);
}
Timer_Delay(400);
} }

View File

@@ -15,13 +15,29 @@
#define TEST_LED_CLOCK kCLOCK_PortD #define TEST_LED_CLOCK kCLOCK_PortD
#define TEST_LED_GPIO_PIN 7U #define TEST_LED_GPIO_PIN 7U
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN) static inline void TestLed_On(void)
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN) {
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_GPIO_PIN, (state)) GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN) }
static inline void TestLed_Off(void)
{
GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
}
static inline void TestLed_Set(bool state)
{
GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_GPIO_PIN, state);
}
static inline void TestLed_Toggle(void)
{
GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
}
// Functions: // Functions:
void InitTestLed(void); void TestLed_Init(void);
void TestLed_Blink(uint8_t times);
#endif #endif

View File

@@ -4,11 +4,14 @@
static volatile uint32_t CurrentTime; static volatile uint32_t CurrentTime;
static uint32_t timerClockFrequency; static uint32_t timerClockFrequency;
static volatile uint32_t currentTime, delayLength;
void PIT_TIMER_HANDLER(void) void PIT_TIMER_HANDLER(void)
{ {
CurrentTime++; currentTime++;
//TEST_LED_TOGGLE(); if (delayLength) {
--delayLength;
}
PIT_ClearStatusFlags(PIT, PIT_TIMER_CHANNEL, kPIT_TimerFlag); PIT_ClearStatusFlags(PIT, PIT_TIMER_CHANNEL, kPIT_TimerFlag);
} }
@@ -27,14 +30,14 @@ void Timer_Init(void)
} }
uint32_t Timer_GetCurrentTime() { uint32_t Timer_GetCurrentTime() {
return CurrentTime; return currentTime;
} }
uint32_t Timer_GetCurrentTimeMicros() { uint32_t Timer_GetCurrentTimeMicros() {
uint32_t primask, count, ms; uint32_t primask, count, ms;
primask = DisableGlobalIRQ(); // Make sure the read is atomic primask = DisableGlobalIRQ(); // Make sure the read is atomic
count = PIT_GetCurrentTimerCount(PIT, PIT_TIMER_CHANNEL); // Read the current timer count count = PIT_GetCurrentTimerCount(PIT, PIT_TIMER_CHANNEL); // Read the current timer count
ms = CurrentTime; // Read the overflow counter ms = currentTime; // Read the overflow counter
EnableGlobalIRQ(primask); // Enable interrupts again if they where enabled before - this should make it interrupt safe EnableGlobalIRQ(primask); // Enable interrupts again if they where enabled before - this should make it interrupt safe
// Calculate the counter value in microseconds - note that the PIT timer is counting downward, so we need to subtract the count from the period value // Calculate the counter value in microseconds - note that the PIT timer is counting downward, so we need to subtract the count from the period value
@@ -77,3 +80,11 @@ uint32_t Timer_GetElapsedTimeAndSetCurrentMicros(uint32_t *time)
*time = Timer_GetCurrentTimeMicros(); *time = Timer_GetCurrentTimeMicros();
return elapsedTime; return elapsedTime;
} }
void Timer_Delay(uint32_t length)
{
delayLength = length;
while (delayLength) {
;
}
}

View File

@@ -6,6 +6,6 @@
void UsbCommand_SetTestLed(void) void UsbCommand_SetTestLed(void)
{ {
bool isTestLedOn = GetUsbRxBufferUint8(1); bool isTestLedOn = GetUsbRxBufferUint8(1);
TEST_LED_SET(isTestLedOn); TestLed_Set(isTestLedOn);
UhkModuleStates[UhkModuleDriverId_LeftKeyboardHalf].sourceVars.isTestLedOn = isTestLedOn; UhkModuleStates[UhkModuleDriverId_LeftKeyboardHalf].sourceVars.isTestLedOn = isTestLedOn;
} }

View File

@@ -280,6 +280,11 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
SwitchKeymapById(action->switchKeymap.keymapId); SwitchKeymapById(action->switchKeymap.keymapId);
} }
break; break;
case KeyActionType_PlayMacro:
if (!keyState->previous) {
Macros_StartMacro(action->playMacro.macroId);
}
break;
} }
} }
@@ -292,10 +297,19 @@ static bool sendChar = false;
static void updateActiveUsbReports(void) static void updateActiveUsbReports(void)
{ {
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
static uint8_t previousModifiers = 0; static uint8_t previousModifiers = 0;
if (MacroPlaying) {
Macros_ContinueMacro();
memcpy(ActiveUsbMouseReport, &MacroMouseReport, sizeof MacroMouseReport);
memcpy(ActiveUsbBasicKeyboardReport, &MacroBasicKeyboardReport, sizeof MacroBasicKeyboardReport);
memcpy(ActiveUsbMediaKeyboardReport, &MacroMediaKeyboardReport, sizeof MacroMediaKeyboardReport);
memcpy(ActiveUsbSystemKeyboardReport, &MacroSystemKeyboardReport, sizeof MacroSystemKeyboardReport);
return;
}
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
basicScancodeIndex = 0; basicScancodeIndex = 0;
mediaScancodeIndex = 0; mediaScancodeIndex = 0;
systemScancodeIndex = 0; systemScancodeIndex = 0;
@@ -314,15 +328,6 @@ static void updateActiveUsbReports(void)
bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base; bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base;
LedDisplay_SetLayer(activeLayer); LedDisplay_SetLayer(activeLayer);
if (MacroPlaying) {
Macros_ContinueMacro();
memcpy(&ActiveUsbMouseReport, &MacroMouseReport, sizeof MacroMouseReport);
memcpy(&ActiveUsbBasicKeyboardReport, &MacroBasicKeyboardReport, sizeof MacroBasicKeyboardReport);
memcpy(&ActiveUsbMediaKeyboardReport, &MacroMediaKeyboardReport, sizeof MacroMediaKeyboardReport);
memcpy(&ActiveUsbSystemKeyboardReport, &MacroSystemKeyboardReport, sizeof MacroSystemKeyboardReport);
return;
}
key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0]; key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0];
if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) { if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) {
simulateKeypresses = !simulateKeypresses; simulateKeypresses = !simulateKeypresses;