Make UpdateUsbReports() not exit prematurely even if a previously active USB interface is not polled anymore by the host. Tweak the Timer API to not set the current time automatically.
This commit is contained in:
@@ -24,9 +24,20 @@ void Timer_Init(void)
|
|||||||
PIT_StartTimer(PIT, PIT_TIMER_CHANNEL);
|
PIT_StartTimer(PIT, PIT_TIMER_CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timer_SetCurrentTime(uint32_t *time)
|
||||||
|
{
|
||||||
|
*time = CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t Timer_GetElapsedTime(uint32_t *time)
|
uint32_t Timer_GetElapsedTime(uint32_t *time)
|
||||||
{
|
{
|
||||||
uint32_t elapsedTime = CurrentTime - *time;
|
uint32_t elapsedTime = CurrentTime - *time;
|
||||||
|
return elapsedTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time)
|
||||||
|
{
|
||||||
|
uint32_t elapsedTime = Timer_GetElapsedTime(time);
|
||||||
*time = CurrentTime;
|
*time = CurrentTime;
|
||||||
return elapsedTime;
|
return elapsedTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void Timer_Init(void);
|
void Timer_Init(void);
|
||||||
|
void Timer_SetCurrentTime(uint32_t *time);
|
||||||
uint32_t Timer_GetElapsedTime(uint32_t *time);
|
uint32_t Timer_GetElapsedTime(uint32_t *time);
|
||||||
|
uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
|||||||
case KeyActionType_SwitchLayer:
|
case KeyActionType_SwitchLayer:
|
||||||
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
||||||
if (doubleTapSwitchLayerKey) {
|
if (doubleTapSwitchLayerKey) {
|
||||||
if (Timer_GetElapsedTime(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
if (Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
||||||
ToggledLayer = action->switchLayer.layer;
|
ToggledLayer = action->switchLayer.layer;
|
||||||
}
|
}
|
||||||
doubleTapSwitchLayerKey = NULL;
|
doubleTapSwitchLayerKey = NULL;
|
||||||
@@ -237,7 +237,7 @@ void updateActiveUsbReports(void)
|
|||||||
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
|
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
|
||||||
|
|
||||||
static uint8_t previousModifiers = 0;
|
static uint8_t previousModifiers = 0;
|
||||||
elapsedTime = Timer_GetElapsedTime(&UsbReportUpdateTime);
|
elapsedTime = Timer_GetElapsedTimeAndSetCurrent(&UsbReportUpdateTime);
|
||||||
|
|
||||||
basicScancodeIndex = 0;
|
basicScancodeIndex = 0;
|
||||||
mediaScancodeIndex = 0;
|
mediaScancodeIndex = 0;
|
||||||
@@ -346,11 +346,19 @@ bool UsbSystemKeyboardReportEverSent = false;
|
|||||||
bool UsbMouseReportEverSentEverSent = false;
|
bool UsbMouseReportEverSentEverSent = false;
|
||||||
|
|
||||||
uint32_t UsbReportUpdateCounter;
|
uint32_t UsbReportUpdateCounter;
|
||||||
|
static uint32_t lastUsbUpdateTime;
|
||||||
|
|
||||||
void UpdateUsbReports(void)
|
void UpdateUsbReports(void)
|
||||||
{
|
{
|
||||||
UsbReportUpdateCounter++;
|
UsbReportUpdateCounter++;
|
||||||
|
|
||||||
|
if (Timer_GetElapsedTime(&lastUsbUpdateTime) > 100) {
|
||||||
|
UsbBasicKeyboardReportEverSent = false;
|
||||||
|
UsbMediaKeyboardReportEverSent = false;
|
||||||
|
UsbSystemKeyboardReportEverSent = false;
|
||||||
|
UsbMouseReportEverSentEverSent = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsUsbBasicKeyboardReportSent) {
|
if (IsUsbBasicKeyboardReportSent) {
|
||||||
UsbBasicKeyboardReportEverSent = true;
|
UsbBasicKeyboardReportEverSent = true;
|
||||||
}
|
}
|
||||||
@@ -397,4 +405,6 @@ void UpdateUsbReports(void)
|
|||||||
IsUsbMediaKeyboardReportSent = false;
|
IsUsbMediaKeyboardReportSent = false;
|
||||||
IsUsbSystemKeyboardReportSent = false;
|
IsUsbSystemKeyboardReportSent = false;
|
||||||
IsUsbMouseReportSent = false;
|
IsUsbMouseReportSent = false;
|
||||||
|
|
||||||
|
Timer_SetCurrentTime(&lastUsbUpdateTime);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user