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