@ -6,6 +6,8 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
return MACRO_NONE ;
return MACRO_NONE ;
}
}
MacroKeyEvent Macros_ : : active_macros [ ] ;
byte Macros_ : : active_macro_count ;
byte Macros_ : : row , Macros_ : : col ;
byte Macros_ : : row , Macros_ : : col ;
void playMacroKeyswitchEvent ( Key key , uint8_t flags ) {
void playMacroKeyswitchEvent ( Key key , uint8_t flags ) {
@ -181,24 +183,44 @@ const macro_t *Macros_::type(const char *string) {
return MACRO_NONE ;
return MACRO_NONE ;
}
}
static Key handleMacroEvent( Key mappedKey , byte row , byte col , uint8_t keyState ) {
Key Macros_ : : handleMacroEvent( Key mappedKey , byte row , byte col , uint8_t keyState ) {
if ( mappedKey . flags ! = ( SYNTHETIC | IS_MACRO ) )
if ( mappedKey . flags ! = ( SYNTHETIC | IS_MACRO ) )
return mappedKey ;
return mappedKey ;
Macros_ : : row = row ;
byte key_id = ( row * COLS ) + col ;
Macros_ : : col = col ;
addActiveMacroKey ( mappedKey . keyCode , key_id , keyState ) ;
const macro_t * m = macroAction ( mappedKey . keyCode , keyState ) ;
Macros . play ( m ) ;
return Key_NoKey ;
return Key_NoKey ;
}
}
void Macros_ : : loopHook ( bool post_clear ) {
if ( post_clear ) {
active_macro_count = 0 ;
return ;
}
for ( byte i = 0 ; i < active_macro_count ; + + i ) {
if ( active_macros [ i ] . key_id = = 0xFF ) {
// i.e. UNKNOWN_KEYSWITCH_LOCATION
row = 0xFF ;
col = 0xFF ;
} else {
row = active_macros [ i ] . key_id / COLS ;
col = active_macros [ i ] . key_id % COLS ;
}
const macro_t * m = macroAction ( active_macros [ i ] . key_code ,
active_macros [ i ] . key_state ) ;
Macros . play ( m ) ;
}
}
Macros_ : : Macros_ ( void ) {
Macros_ : : Macros_ ( void ) {
}
}
void
void
Macros_ : : begin ( void ) {
Macros_ : : begin ( void ) {
active_macro_count = 0 ;
Kaleidoscope . useEventHandlerHook ( handleMacroEvent ) ;
Kaleidoscope . useEventHandlerHook ( handleMacroEvent ) ;
Kaleidoscope . useLoopHook ( loopHook ) ;
}
}
Macros_ Macros ;
Macros_ Macros ;