@ -23,9 +23,9 @@ using namespace Akela::Ranges;
namespace Akela {
namespace Akela {
// ---- state ---------
// ---- state ---------
uint 8_t OneShot : : Timer = 0 ;
uint 32_t OneShot : : startTime = 0 ;
uint 8_t OneShot : : timeOut = 4 0;
uint 16_t OneShot : : timeOut = 250 0;
uint 8 _t OneShot : : holdTimeOut = 5;
uint 16 _t OneShot : : holdTimeOut = 2 50 ;
uint32_t OneShot : : State = 0 ;
uint32_t OneShot : : State = 0 ;
uint32_t OneShot : : stickyState = 0 ;
uint32_t OneShot : : stickyState = 0 ;
uint32_t OneShot : : pressedState = 0 ;
uint32_t OneShot : : pressedState = 0 ;
@ -58,7 +58,7 @@ namespace Akela {
# define toNormalMod(key, idx) {key.flags = 0; key.keyCode = Key_LCtrl.keyCode + idx;}
# define toNormalMod(key, idx) {key.flags = 0; key.keyCode = Key_LCtrl.keyCode + idx;}
# define toNormalMT(key, idx) { key.raw = Key_NoKey.raw; Layer.on (idx - 8); }
# define toNormalMT(key, idx) { key.raw = Key_NoKey.raw; Layer.on (idx - 8); }
# define hasTimedOut() ( Timer >= timeOut)
# define hasTimedOut() ( millis () - start Time >= timeOut)
// ----- passthrough ------
// ----- passthrough ------
@ -187,8 +187,8 @@ namespace Akela {
idx = mappedKey . raw - OS_FIRST ;
idx = mappedKey . raw - OS_FIRST ;
if ( key_toggled_off ( keyState ) ) {
if ( key_toggled_off ( keyState ) ) {
clearPressed ( idx ) ;
clearPressed ( idx ) ;
} else if ( key_toggled_on ( keyState ) ) {
} else if ( key_toggled_on ( keyState ) ) {
Timer = 0 ;
startTime = millis ( ) ;
setPressed ( idx ) ;
setPressed ( idx ) ;
setOneShot ( idx ) ;
setOneShot ( idx ) ;
saveAsPrevious ( mappedKey ) ;
saveAsPrevious ( mappedKey ) ;
@ -214,7 +214,7 @@ namespace Akela {
} else {
} else {
if ( key_toggled_off ( keyState ) ) {
if ( key_toggled_off ( keyState ) ) {
clearPressed ( idx ) ;
clearPressed ( idx ) ;
if ( Timer > = holdTimeOut ) {
if ( ( millis ( ) - startTime ) > = holdTimeOut ) {
cancelOneShot ( idx ) ;
cancelOneShot ( idx ) ;
}
}
}
}
@ -226,7 +226,7 @@ namespace Akela {
saveAsPrevious ( mappedKey ) ;
saveAsPrevious ( mappedKey ) ;
} else {
} else {
Timer = 0 ;
startTime = millis ( ) ;
setOneShot ( idx ) ;
setOneShot ( idx ) ;
saveAsPrevious ( mappedKey ) ;
saveAsPrevious ( mappedKey ) ;
@ -256,9 +256,6 @@ namespace Akela {
return ;
return ;
if ( postClear ) {
if ( postClear ) {
if ( Timer < timeOut )
Timer + + ;
if ( hasTimedOut ( ) )
if ( hasTimedOut ( ) )
cancel ( ) ;
cancel ( ) ;
@ -266,11 +263,9 @@ namespace Akela {
if ( shouldCancel ) {
if ( shouldCancel ) {
if ( isSticky ( i ) ) {
if ( isSticky ( i ) ) {
if ( shouldCancelStickies ) {
if ( shouldCancelStickies ) {
Timer = 0 ;
clearSticky ( i ) ;
clearSticky ( i ) ;
}
}
} else if ( isOneShot ( i ) & & ! isPressed ( i ) ) {
} else if ( isOneShot ( i ) & & ! isPressed ( i ) ) {
Timer = 0 ;
cancelOneShot ( i ) ;
cancelOneShot ( i ) ;
}
}
}
}