@ -28,6 +28,8 @@ namespace Akela {
uint32_t TapDance : : pressedState ;
uint32_t TapDance : : pressedState ;
uint32_t TapDance : : triggeredState ;
uint32_t TapDance : : triggeredState ;
Key TapDance : : lastTapDanceKey ;
Key TapDance : : lastTapDanceKey ;
byte TapDance : : lastTapDanceRow ;
byte TapDance : : lastTapDanceCol ;
// --- helpers ---
// --- helpers ---
@ -42,7 +44,7 @@ namespace Akela {
TapDance : : interrupt ( void ) {
TapDance : : interrupt ( void ) {
uint8_t idx = lastTapDanceKey . raw - TD_FIRST ;
uint8_t idx = lastTapDanceKey . raw - TD_FIRST ;
tapDanceAction ( idx , tapCount[ idx ] , Interrupt ) ;
tapDanceAction ( idx , lastTapDanceRow, lastTapDanceCol , tapCount[ idx ] , Interrupt ) ;
bitWrite ( triggeredState , idx , 1 ) ;
bitWrite ( triggeredState , idx , 1 ) ;
timer = 0 ;
timer = 0 ;
@ -57,7 +59,7 @@ namespace Akela {
TapDance : : timeout ( void ) {
TapDance : : timeout ( void ) {
uint8_t idx = lastTapDanceKey . raw - TD_FIRST ;
uint8_t idx = lastTapDanceKey . raw - TD_FIRST ;
tapDanceAction ( idx , tapCount[ idx ] , Timeout ) ;
tapDanceAction ( idx , lastTapDanceRow, lastTapDanceCol , tapCount[ idx ] , Timeout ) ;
bitWrite ( triggeredState , idx , 1 ) ;
bitWrite ( triggeredState , idx , 1 ) ;
if ( bitRead ( pressedState , idx ) )
if ( bitRead ( pressedState , idx ) )
@ -70,7 +72,7 @@ namespace Akela {
Key
Key
TapDance : : release ( uint8_t tapDanceIndex ) {
TapDance : : release ( uint8_t tapDanceIndex ) {
tapDanceAction ( tapDanceIndex , tapCount[ tapDanceIndex ] , Release ) ;
tapDanceAction ( tapDanceIndex , lastTapDanceRow, lastTapDanceCol , tapCount[ tapDanceIndex ] , Release ) ;
timer = 0 ;
timer = 0 ;
tapCount [ tapDanceIndex ] = 0 ;
tapCount [ tapDanceIndex ] = 0 ;
@ -88,7 +90,7 @@ namespace Akela {
tapCount [ idx ] + + ;
tapCount [ idx ] + + ;
timer = 0 ;
timer = 0 ;
tapDanceAction ( idx , tapCount[ idx ] , Tap ) ;
tapDanceAction ( idx , lastTapDanceRow, lastTapDanceCol , tapCount[ idx ] , Tap ) ;
return Key_NoKey ;
return Key_NoKey ;
}
}
@ -118,14 +120,14 @@ namespace Akela {
break ;
break ;
case Interrupt :
case Interrupt :
case Timeout :
case Timeout :
handle_key_event ( key , 255 , 255 , IS_PRESSED | INJECTED ) ;
handle_key_event ( key , lastTapDanceRow , lastTapDanceCol , IS_PRESSED | INJECTED ) ;
break ;
break ;
case Hold :
case Hold :
handle_key_event ( key , 255 , 255 , IS_PRESSED | WAS_PRESSED | INJECTED ) ;
handle_key_event ( key , lastTapDanceRow , lastTapDanceCol , IS_PRESSED | WAS_PRESSED | INJECTED ) ;
break ;
break ;
case Release :
case Release :
Keyboard . sendReport ( ) ;
Keyboard . sendReport ( ) ;
handle_key_event ( key , 255 , 255 , WAS_PRESSED | INJECTED ) ;
handle_key_event ( key , lastTapDanceRow , lastTapDanceCol , WAS_PRESSED | INJECTED ) ;
break ;
break ;
}
}
}
}
@ -167,6 +169,8 @@ namespace Akela {
}
}
lastTapDanceKey . raw = mappedKey . raw ;
lastTapDanceKey . raw = mappedKey . raw ;
lastTapDanceRow = row ;
lastTapDanceCol = col ;
return tap ( ) ;
return tap ( ) ;
} else {
} else {
if ( key_toggled_off ( keyState ) & & stillHeld ( tapDanceIndex ) ) {
if ( key_toggled_off ( keyState ) & & stillHeld ( tapDanceIndex ) ) {
@ -186,13 +190,15 @@ namespace Akela {
return Key_NoKey ;
return Key_NoKey ;
lastTapDanceKey . raw = mappedKey . raw ;
lastTapDanceKey . raw = mappedKey . raw ;
lastTapDanceRow = row ;
lastTapDanceCol = col ;
bitSet ( pressedState , tapDanceIndex ) ;
bitSet ( pressedState , tapDanceIndex ) ;
if ( key_toggled_on ( keyState ) )
if ( key_toggled_on ( keyState ) )
return tap ( ) ;
return tap ( ) ;
if ( bitRead ( triggeredState , tapDanceIndex ) )
if ( bitRead ( triggeredState , tapDanceIndex ) )
tapDanceAction ( tapDanceIndex , tapCount[ tapDanceIndex ] , Hold ) ;
tapDanceAction ( tapDanceIndex , row, col , tapCount[ tapDanceIndex ] , Hold ) ;
return Key_NoKey ;
return Key_NoKey ;
}
}
@ -215,7 +221,7 @@ namespace Akela {
__attribute__ ( ( weak ) )
__attribute__ ( ( weak ) )
void
void
tapDanceAction ( uint8_t tapDanceIndex , uint8_t tapCount , Akela : : TapDance : : ActionType tapDanceAction ) {
tapDanceAction ( uint8_t tapDanceIndex , byte row , byte col , uint8_t tapCount , Akela : : TapDance : : ActionType tapDanceAction ) {
}
}
Akela : : TapDance TapDance ;
Akela : : TapDance TapDance ;