|
|
@ -32,9 +32,11 @@ uint16_t OneShot::hold_timeout_ = 250;
|
|
|
|
int16_t OneShot::double_tap_timeout_ = -1;
|
|
|
|
int16_t OneShot::double_tap_timeout_ = -1;
|
|
|
|
|
|
|
|
|
|
|
|
// Deprecated
|
|
|
|
// Deprecated
|
|
|
|
|
|
|
|
#ifndef NDEPRECATED
|
|
|
|
uint16_t OneShot::time_out = 2500;
|
|
|
|
uint16_t OneShot::time_out = 2500;
|
|
|
|
uint16_t OneShot::hold_time_out = 250;
|
|
|
|
uint16_t OneShot::hold_time_out = 250;
|
|
|
|
int16_t OneShot::double_tap_time_out = -1;
|
|
|
|
int16_t OneShot::double_tap_time_out = -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// State variables
|
|
|
|
// State variables
|
|
|
@ -44,8 +46,6 @@ uint16_t OneShot::stickable_keys_ = -1;
|
|
|
|
bool OneShot::auto_modifiers_ = false;
|
|
|
|
bool OneShot::auto_modifiers_ = false;
|
|
|
|
bool OneShot::auto_layers_ = false;
|
|
|
|
bool OneShot::auto_layers_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
KeyAddr OneShot::meta_sticky_key_addr_ = KeyAddr{KeyAddr::invalid_state};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeyAddrBitfield OneShot::temp_addrs_;
|
|
|
|
KeyAddrBitfield OneShot::temp_addrs_;
|
|
|
|
KeyAddrBitfield OneShot::glue_addrs_;
|
|
|
|
KeyAddrBitfield OneShot::glue_addrs_;
|
|
|
|
|
|
|
|
|
|
|
@ -53,6 +53,10 @@ uint16_t OneShot::start_time_ = 0;
|
|
|
|
KeyAddr OneShot::prev_key_addr_ = OneShot::invalid_key_addr;
|
|
|
|
KeyAddr OneShot::prev_key_addr_ = OneShot::invalid_key_addr;
|
|
|
|
uint8_t OneShot::release_countdown_ = 0;
|
|
|
|
uint8_t OneShot::release_countdown_ = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef ONESHOT_WITHOUT_METASTICKY
|
|
|
|
|
|
|
|
KeyAddr OneShot::meta_sticky_key_addr_ {KeyAddr::invalid_state};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// ============================================================================
|
|
|
|
// Public interface
|
|
|
|
// Public interface
|
|
|
@ -142,8 +146,10 @@ bool OneShot::isStickable(Key key) {
|
|
|
|
if (n < oneshot_key_count) {
|
|
|
|
if (n < oneshot_key_count) {
|
|
|
|
return bitRead(stickable_keys_, n);
|
|
|
|
return bitRead(stickable_keys_, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef ONESHOT_WITHOUT_METASTICKY
|
|
|
|
} else if (key == OneShot_MetaStickyKey) {
|
|
|
|
} else if (key == OneShot_MetaStickyKey) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -206,6 +212,7 @@ EventHandlerResult OneShot::onKeyswitchEvent(
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp && !glue) {
|
|
|
|
if (!temp && !glue) {
|
|
|
|
// This key_addr is not in a OneShot state.
|
|
|
|
// This key_addr is not in a OneShot state.
|
|
|
|
|
|
|
|
#ifndef ONESHOT_WITHOUT_METASTICKY
|
|
|
|
if (meta_sticky_key_addr_.isValid()) {
|
|
|
|
if (meta_sticky_key_addr_.isValid()) {
|
|
|
|
// If the meta key isn't sticky, release it
|
|
|
|
// If the meta key isn't sticky, release it
|
|
|
|
bool ms_temp = temp_addrs_.read(meta_sticky_key_addr_);
|
|
|
|
bool ms_temp = temp_addrs_.read(meta_sticky_key_addr_);
|
|
|
@ -231,8 +238,13 @@ EventHandlerResult OneShot::onKeyswitchEvent(
|
|
|
|
meta_sticky_key_addr_ = key_addr;
|
|
|
|
meta_sticky_key_addr_ = key_addr;
|
|
|
|
temp_addrs_.set(key_addr);
|
|
|
|
temp_addrs_.set(key_addr);
|
|
|
|
start_time_ = Runtime.millisAtCycleStart();
|
|
|
|
start_time_ = Runtime.millisAtCycleStart();
|
|
|
|
|
|
|
|
} else // NOLINT
|
|
|
|
} else if (isOneShotKey(key) ||
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// *INDENT-OFF*
|
|
|
|
|
|
|
|
// Because of the preceding #ifdef, indentation gets thrown off for astyle here.
|
|
|
|
|
|
|
|
// This is only an independent `if` block if `ONESHOT_WITHOUT_METASTICKY`
|
|
|
|
|
|
|
|
// is set (see above); otherwise it's an `else if`.
|
|
|
|
|
|
|
|
if (isOneShotKey(key) ||
|
|
|
|
(auto_modifiers_ && isModifier(key)) ||
|
|
|
|
(auto_modifiers_ && isModifier(key)) ||
|
|
|
|
(auto_layers_ && isLayerShift(key))) {
|
|
|
|
(auto_layers_ && isLayerShift(key))) {
|
|
|
|
// Replace the OneShot key with its corresponding normal key.
|
|
|
|
// Replace the OneShot key with its corresponding normal key.
|
|
|
@ -244,7 +256,7 @@ EventHandlerResult OneShot::onKeyswitchEvent(
|
|
|
|
// pressed key is neither a modifier nor a layer shift.
|
|
|
|
// pressed key is neither a modifier nor a layer shift.
|
|
|
|
release_countdown_ = (1 << 1);
|
|
|
|
release_countdown_ = (1 << 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// return EventHandlerResult::OK;
|
|
|
|
// *INDENT-ON*
|
|
|
|
|
|
|
|
|
|
|
|
} else if (temp && glue) {
|
|
|
|
} else if (temp && glue) {
|
|
|
|
// This key_addr is in the temporary OneShot state.
|
|
|
|
// This key_addr is in the temporary OneShot state.
|
|
|
@ -307,9 +319,10 @@ EventHandlerResult OneShot::onKeyswitchEvent(
|
|
|
|
// `beforeReportingState()` hook below.
|
|
|
|
// `beforeReportingState()` hook below.
|
|
|
|
//Layer.updateLiveCompositeKeymap(key_addr, key);
|
|
|
|
//Layer.updateLiveCompositeKeymap(key_addr, key);
|
|
|
|
return EventHandlerResult::ABORT;
|
|
|
|
return EventHandlerResult::ABORT;
|
|
|
|
|
|
|
|
#ifndef ONESHOT_WITHOUT_METASTICKY
|
|
|
|
} else if (key == OneShot_MetaStickyKey) {
|
|
|
|
} else if (key == OneShot_MetaStickyKey) {
|
|
|
|
meta_sticky_key_addr_ = KeyAddr{KeyAddr::invalid_state};
|
|
|
|
meta_sticky_key_addr_ = KeyAddr{KeyAddr::invalid_state};
|
|
|
|
//cancel(true);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -367,12 +380,14 @@ EventHandlerResult OneShot::afterEachCycle() {
|
|
|
|
release_countdown_ >>= 1;
|
|
|
|
release_countdown_ >>= 1;
|
|
|
|
|
|
|
|
|
|
|
|
// Temporary fix for deprecated variables
|
|
|
|
// Temporary fix for deprecated variables
|
|
|
|
|
|
|
|
#ifndef NDEPRECATED
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
timeout_ = time_out;
|
|
|
|
timeout_ = time_out;
|
|
|
|
hold_timeout_ = hold_time_out;
|
|
|
|
hold_timeout_ = hold_time_out;
|
|
|
|
double_tap_timeout_ = double_tap_time_out;
|
|
|
|
double_tap_timeout_ = double_tap_time_out;
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -450,7 +465,7 @@ void OneShot::releaseKey(KeyAddr key_addr) {
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// Deprecated functions
|
|
|
|
// Deprecated functions
|
|
|
|
|
|
|
|
#ifndef NDEPRECATED
|
|
|
|
void OneShot::inject(Key key, uint8_t key_state) {
|
|
|
|
void OneShot::inject(Key key, uint8_t key_state) {
|
|
|
|
if (isOneShotKey(key)) {
|
|
|
|
if (isOneShotKey(key)) {
|
|
|
|
key = decodeOneShotKey(key);
|
|
|
|
key = decodeOneShotKey(key);
|
|
|
@ -507,6 +522,7 @@ bool OneShot::isSticky(Key key) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace plugin
|
|
|
|
} // namespace plugin
|
|
|
|