@ -52,6 +52,7 @@ constexpr uint8_t release_state = WAS_PRESSED | INJECTED;
// Initialized to zeroes (i.e. `Key_NoKey`)
// Initialized to zeroes (i.e. `Key_NoKey`)
Key Macros : : active_macro_keys_ [ ] ;
Key Macros : : active_macro_keys_ [ ] ;
Macros : : readMacroByteFunction Macros : : readMacroByte = & Macros : : readMacroByteFromPROGMEM ;
# ifndef NDEPRECATED
# ifndef NDEPRECATED
# pragma GCC diagnostic push
# pragma GCC diagnostic push
@ -106,7 +107,7 @@ void Macros::tap(Key key) const {
Runtime . handleKeyEvent ( KeyEvent { KeyAddr : : none ( ) , release_state , key } ) ;
Runtime . handleKeyEvent ( KeyEvent { KeyAddr : : none ( ) , release_state , key } ) ;
}
}
void Macros : : play ( const macro_t * macro_p ) {
void Macros : : play ( const macro_t * macro_p , uint8_t source ) {
macro_t macro = MACRO_ACTION_END ;
macro_t macro = MACRO_ACTION_END ;
uint8_t interval = 0 ;
uint8_t interval = 0 ;
Key key ;
Key key ;
@ -115,7 +116,7 @@ void Macros::play(const macro_t *macro_p) {
return ;
return ;
while ( true ) {
while ( true ) {
switch ( macro = pgm_read_byte( macro_p + + ) ) {
switch ( macro = readMacroByte( macro_p , source ) ) {
// These are unlikely to be useful now that we have KeyEvent. I think the
// These are unlikely to be useful now that we have KeyEvent. I think the
// whole `explicit_report` came about as a result of scan-order bugs.
// whole `explicit_report` came about as a result of scan-order bugs.
case MACRO_ACTION_STEP_EXPLICIT_REPORT :
case MACRO_ACTION_STEP_EXPLICIT_REPORT :
@ -126,50 +127,50 @@ void Macros::play(const macro_t *macro_p) {
// Timing
// Timing
case MACRO_ACTION_STEP_INTERVAL :
case MACRO_ACTION_STEP_INTERVAL :
interval = pgm_read_byte( macro_p + + ) ;
interval = readMacroByte( macro_p , source ) ;
break ;
break ;
case MACRO_ACTION_STEP_WAIT : {
case MACRO_ACTION_STEP_WAIT : {
uint8_t wait = pgm_read_byte( macro_p + + ) ;
uint8_t wait = readMacroByte( macro_p , source ) ;
delay ( wait ) ;
delay ( wait ) ;
break ;
break ;
}
}
case MACRO_ACTION_STEP_KEYDOWN :
case MACRO_ACTION_STEP_KEYDOWN :
key . setFlags ( pgm_read_byte( macro_p + + ) ) ;
key . setFlags ( readMacroByte( macro_p , source ) ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
press ( key ) ;
press ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_KEYUP :
case MACRO_ACTION_STEP_KEYUP :
key . setFlags ( pgm_read_byte( macro_p + + ) ) ;
key . setFlags ( readMacroByte( macro_p , source ) ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
release ( key ) ;
release ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_TAP :
case MACRO_ACTION_STEP_TAP :
key . setFlags ( pgm_read_byte( macro_p + + ) ) ;
key . setFlags ( readMacroByte( macro_p , source ) ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
tap ( key ) ;
tap ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_KEYCODEDOWN :
case MACRO_ACTION_STEP_KEYCODEDOWN :
key . setFlags ( 0 ) ;
key . setFlags ( 0 ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
press ( key ) ;
press ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_KEYCODEUP :
case MACRO_ACTION_STEP_KEYCODEUP :
key . setFlags ( 0 ) ;
key . setFlags ( 0 ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
release ( key ) ;
release ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_TAPCODE :
case MACRO_ACTION_STEP_TAPCODE :
key . setFlags ( 0 ) ;
key . setFlags ( 0 ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
tap ( key ) ;
tap ( key ) ;
break ;
break ;
case MACRO_ACTION_STEP_TAP_SEQUENCE : {
case MACRO_ACTION_STEP_TAP_SEQUENCE : {
while ( true ) {
while ( true ) {
key . setFlags ( 0 ) ;
key . setFlags ( 0 ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
if ( key = = Key_NoKey )
if ( key = = Key_NoKey )
break ;
break ;
tap ( key ) ;
tap ( key ) ;
@ -180,7 +181,7 @@ void Macros::play(const macro_t *macro_p) {
case MACRO_ACTION_STEP_TAP_CODE_SEQUENCE : {
case MACRO_ACTION_STEP_TAP_CODE_SEQUENCE : {
while ( true ) {
while ( true ) {
key . setFlags ( 0 ) ;
key . setFlags ( 0 ) ;
key . setKeyCode ( pgm_read_byte( macro_p + + ) ) ;
key . setKeyCode ( readMacroByte( macro_p , source ) ) ;
if ( key . getKeyCode ( ) = = 0 )
if ( key . getKeyCode ( ) = = 0 )
break ;
break ;
tap ( key ) ;
tap ( key ) ;