|
|
@ -21,31 +21,31 @@
|
|
|
|
#include <Kaleidoscope-Focus.h>
|
|
|
|
#include <Kaleidoscope-Focus.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
TypingBreaks::settings_t TypingBreaks::settings = {
|
|
|
|
TypingBreaks::settings_t TypingBreaks::settings = {
|
|
|
|
.idleTimeLimit = 10000, // 10s
|
|
|
|
.idleTimeLimit = 10000, // 10s
|
|
|
|
.lockTimeOut = 2700000, // 45m
|
|
|
|
.lockTimeOut = 2700000, // 45m
|
|
|
|
.lockLength = 300000, // 5m
|
|
|
|
.lockLength = 300000, // 5m
|
|
|
|
.leftHandMaxKeys = 0,
|
|
|
|
.leftHandMaxKeys = 0,
|
|
|
|
.rightHandMaxKeys = 0
|
|
|
|
.rightHandMaxKeys = 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t TypingBreaks::sessionStartTime;
|
|
|
|
uint32_t TypingBreaks::sessionStartTime;
|
|
|
|
uint32_t TypingBreaks::lastKeyTime;
|
|
|
|
uint32_t TypingBreaks::lastKeyTime;
|
|
|
|
uint32_t TypingBreaks::lockStartTime;
|
|
|
|
uint32_t TypingBreaks::lockStartTime;
|
|
|
|
uint16_t TypingBreaks::leftHandKeys;
|
|
|
|
uint16_t TypingBreaks::leftHandKeys;
|
|
|
|
uint16_t TypingBreaks::rightHandKeys;
|
|
|
|
uint16_t TypingBreaks::rightHandKeys;
|
|
|
|
uint16_t TypingBreaks::settingsBase;
|
|
|
|
uint16_t TypingBreaks::settingsBase;
|
|
|
|
|
|
|
|
|
|
|
|
TypingBreaks::TypingBreaks (void) {
|
|
|
|
TypingBreaks::TypingBreaks (void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TypingBreaks::begin (void) {
|
|
|
|
TypingBreaks::begin (void) {
|
|
|
|
event_handler_hook_use (this->eventHandlerHook);
|
|
|
|
event_handler_hook_use (this->eventHandlerHook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
TypingBreaks::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
TypingBreaks::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
// If we are locked, and didn't time out yet, no key has to be pressed.
|
|
|
|
// If we are locked, and didn't time out yet, no key has to be pressed.
|
|
|
|
if (lockStartTime && (millis () - lockStartTime <= settings.lockLength))
|
|
|
|
if (lockStartTime && (millis () - lockStartTime <= settings.lockLength))
|
|
|
|
return Key_NoKey;
|
|
|
|
return Key_NoKey;
|
|
|
@ -110,10 +110,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mappedKey;
|
|
|
|
return mappedKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TypingBreaks::enableEEPROM (void) {
|
|
|
|
TypingBreaks::enableEEPROM (void) {
|
|
|
|
settingsBase = ::EEPROMSettings.requestSlice (sizeof (settings));
|
|
|
|
settingsBase = ::EEPROMSettings.requestSlice (sizeof (settings));
|
|
|
|
|
|
|
|
|
|
|
|
// If idleTime is max, assume that EEPROM is uninitialized, and store the
|
|
|
|
// If idleTime is max, assume that EEPROM is uninitialized, and store the
|
|
|
@ -125,10 +125,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EEPROM.get (settingsBase, settings);
|
|
|
|
EEPROM.get (settingsBase, settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
TypingBreaks::focusHook (const char *command) {
|
|
|
|
TypingBreaks::focusHook (const char *command) {
|
|
|
|
enum {
|
|
|
|
enum {
|
|
|
|
IDLE_TIME_LIMIT,
|
|
|
|
IDLE_TIME_LIMIT,
|
|
|
|
LOCK_TIMEOUT,
|
|
|
|
LOCK_TIMEOUT,
|
|
|
@ -192,7 +192,7 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
|
|
|
|
|
|
|
EEPROM.put (settingsBase, settings);
|
|
|
|
EEPROM.put (settingsBase, settings);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
KaleidoscopePlugins::TypingBreaks TypingBreaks;
|
|
|
|
KaleidoscopePlugins::TypingBreaks TypingBreaks;
|
|
|
|