@ -41,6 +41,9 @@ int16_t OneShot::double_tap_time_out = -1;
uint16_t OneShot : : stickable_keys_ = - 1 ;
uint16_t OneShot : : stickable_keys_ = - 1 ;
bool OneShot : : auto_modifiers_ = false ;
bool OneShot : : auto_layers_ = false ;
KeyAddrBitfield OneShot : : temp_addrs_ ;
KeyAddrBitfield OneShot : : temp_addrs_ ;
KeyAddrBitfield OneShot : : glue_addrs_ ;
KeyAddrBitfield OneShot : : glue_addrs_ ;
@ -199,7 +202,9 @@ 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.
if ( isOneShotKey ( key ) ) {
if ( isOneShotKey ( key ) | |
( auto_modifiers_ & & isModifier ( key ) ) | |
( auto_layers_ & & isLayerShift ( key ) ) ) {
// Replace the OneShot key with its corresponding normal key.
// Replace the OneShot key with its corresponding normal key.
pressKey ( key_addr , key ) ;
pressKey ( key_addr , key ) ;
return EventHandlerResult : : ABORT ;
return EventHandlerResult : : ABORT ;
@ -382,8 +387,10 @@ Key OneShot::decodeOneShotKey(Key oneshot_key) {
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// Helper functions for sending key events for keys in OneShot states
// Helper functions for sending key events for keys in OneShot states
void OneShot : : pressKey ( KeyAddr key_addr , Key oneshot_key ) {
void OneShot : : pressKey ( KeyAddr key_addr , Key key ) {
Key key = decodeOneShotKey ( oneshot_key ) ;
if ( isOneShotKey ( key ) ) {
key = decodeOneShotKey ( key ) ;
}
prev_key_addr_ = key_addr ;
prev_key_addr_ = key_addr ;
start_time_ = Runtime . millisAtCycleStart ( ) ;
start_time_ = Runtime . millisAtCycleStart ( ) ;
temp_addrs_ . set ( key_addr ) ;
temp_addrs_ . set ( key_addr ) ;
@ -404,8 +411,8 @@ void OneShot::releaseKey(KeyAddr key_addr) {
// Deprecated functions
// Deprecated functions
void OneShot : : inject ( Key key , uint8_t key_state ) {
void OneShot : : inject ( Key key , uint8_t key_state ) {
if ( ! isOneShotKey ( key ) ) {
if ( isOneShotKey ( key ) ) {
return ;
key = decodeOneShotKey ( key ) ;
}
}
// Find an idle keyswitch to use for the injected OneShot key and activate
// Find an idle keyswitch to use for the injected OneShot key and activate
// it. This is an ugly hack, but it will work. It does mean that whatever key
// it. This is an ugly hack, but it will work. It does mean that whatever key
@ -435,11 +442,10 @@ bool OneShot::isModifierActive(Key key) {
return false ;
return false ;
}
}
bool OneShot : : isActive ( Key oneshot_ key) {
bool OneShot : : isActive ( Key key) {
if ( ! isOneShotKey ( oneshot_ key) ) {
if ( isOneShotKey ( key) ) {
return false ;
key = decodeOneShotKey ( key ) ;
}
}
Key key = decodeOneShotKey ( oneshot_key ) ;
for ( KeyAddr key_addr : glue_addrs_ ) {
for ( KeyAddr key_addr : glue_addrs_ ) {
if ( live_keys [ key_addr ] = = key ) {
if ( live_keys [ key_addr ] = = key ) {
return true ;
return true ;
@ -448,11 +454,10 @@ bool OneShot::isActive(Key oneshot_key) {
return false ;
return false ;
}
}
bool OneShot : : isSticky ( Key oneshot_ key) {
bool OneShot : : isSticky ( Key key) {
if ( ! isOneShotKey ( oneshot_ key) ) {
if ( isOneShotKey ( key) ) {
return false ;
key = decodeOneShotKey ( key ) ;
}
}
Key key = decodeOneShotKey ( oneshot_key ) ;
for ( KeyAddr key_addr : glue_addrs_ ) {
for ( KeyAddr key_addr : glue_addrs_ ) {
if ( live_keys [ key_addr ] = = key & &
if ( live_keys [ key_addr ] = = key & &
! temp_addrs_ . read ( key_addr ) ) {
! temp_addrs_ . read ( key_addr ) ) {