@ -17,6 +17,8 @@
# include "Kaleidoscope-DynamicMacros.h"
# include "kaleidoscope/hid.h"
# include "Kaleidoscope-FocusSerial.h"
# include "kaleidoscope/keyswitch_state.h"
# include "kaleidoscope/key_events.h"
using namespace kaleidoscope : : ranges ;
@ -47,7 +49,7 @@ static void playKeyCode(Key key, uint8_t keyStates, bool explicit_report) {
}
static void readKeyCodeAndPlay ( uint16_t pos , uint8_t flags , uint8_t keyStates , bool explicit_report ) {
Key key ( Kaleidoscop e. storage ( ) . read ( pos + + ) , // key_code
Key key ( Runtim e. storage ( ) . read ( pos + + ) , // key_code
flags ) ;
playKeyCode ( key , keyStates , explicit_report ) ;
@ -62,7 +64,7 @@ void DynamicMacros::updateDynamicMacroCache(void) {
map_ [ 0 ] = 0 ;
while ( pos < storage_base_ + storage_size_ ) {
macro = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
macro = Runtim e. storage ( ) . read ( pos + + ) ;
switch ( macro ) {
case MACRO_ACTION_STEP_EXPLICIT_REPORT :
case MACRO_ACTION_STEP_IMPLICIT_REPORT :
@ -90,8 +92,8 @@ void DynamicMacros::updateDynamicMacroCache(void) {
previous_macro_ended = false ;
uint8_t keyCode , flags ;
do {
flags = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
keyCode = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
flags = Runtim e. storage ( ) . read ( pos + + ) ;
keyCode = Runtim e. storage ( ) . read ( pos + + ) ;
} while ( ! ( flags = = 0 & & keyCode = = 0 ) ) ;
break ;
}
@ -100,7 +102,7 @@ void DynamicMacros::updateDynamicMacroCache(void) {
previous_macro_ended = false ;
uint8_t keyCode , flags ;
do {
keyCode = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
keyCode = Runtim e. storage ( ) . read ( pos + + ) ;
} while ( keyCode ! = 0 ) ;
break ;
}
@ -127,7 +129,7 @@ void DynamicMacros::play(uint8_t macro_id) {
pos = storage_base_ + map_ [ macro_id ] ;
while ( true ) {
switch ( macro = Kaleidoscop e. storage ( ) . read ( pos + + ) ) {
switch ( macro = Runtim e. storage ( ) . read ( pos + + ) ) {
case MACRO_ACTION_STEP_EXPLICIT_REPORT :
explicit_report = true ;
break ;
@ -139,23 +141,23 @@ void DynamicMacros::play(uint8_t macro_id) {
kaleidoscope : : hid : : sendMouseReport ( ) ;
break ;
case MACRO_ACTION_STEP_INTERVAL :
interval = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
interval = Runtim e. storage ( ) . read ( pos + + ) ;
break ;
case MACRO_ACTION_STEP_WAIT : {
uint8_t wait = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
uint8_t wait = Runtim e. storage ( ) . read ( pos + + ) ;
delay ( wait ) ;
break ;
}
case MACRO_ACTION_STEP_KEYDOWN :
flags = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
flags = Runtim e. storage ( ) . read ( pos + + ) ;
readKeyCodeAndPlay ( pos + + , flags , IS_PRESSED , explicit_report ) ;
break ;
case MACRO_ACTION_STEP_KEYUP :
flags = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
flags = Runtim e. storage ( ) . read ( pos + + ) ;
readKeyCodeAndPlay ( pos + + , flags , WAS_PRESSED , explicit_report ) ;
break ;
case MACRO_ACTION_STEP_TAP :
flags = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
flags = Runtim e. storage ( ) . read ( pos + + ) ;
readKeyCodeAndPlay ( pos + + , flags , IS_PRESSED | WAS_PRESSED , false ) ;
break ;
@ -172,8 +174,8 @@ void DynamicMacros::play(uint8_t macro_id) {
case MACRO_ACTION_STEP_TAP_SEQUENCE : {
uint8_t keyCode ;
do {
flags = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
keyCode = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
flags = Runtim e. storage ( ) . read ( pos + + ) ;
keyCode = Runtim e. storage ( ) . read ( pos + + ) ;
playKeyCode ( Key ( keyCode , flags ) , IS_PRESSED | WAS_PRESSED , false ) ;
delay ( interval ) ;
} while ( ! ( flags = = 0 & & keyCode = = 0 ) ) ;
@ -182,7 +184,7 @@ void DynamicMacros::play(uint8_t macro_id) {
case MACRO_ACTION_STEP_TAP_CODE_SEQUENCE : {
uint8_t keyCode ;
do {
keyCode = Kaleidoscop e. storage ( ) . read ( pos + + ) ;
keyCode = Runtim e. storage ( ) . read ( pos + + ) ;
playKeyCode ( Key ( keyCode , 0 ) , IS_PRESSED | WAS_PRESSED , false ) ;
delay ( interval ) ;
} while ( keyCode ! = 0 ) ;
@ -220,7 +222,7 @@ EventHandlerResult DynamicMacros::onFocusEvent(const char *command) {
if ( : : Focus . isEOL ( ) ) {
for ( uint16_t i = 0 ; i < storage_size_ ; i + + ) {
uint8_t b ;
b = Kaleidoscop e. storage ( ) . read ( storage_base_ + i ) ;
b = Runtim e. storage ( ) . read ( storage_base_ + i ) ;
: : Focus . send ( b ) ;
}
} else {
@ -230,9 +232,9 @@ EventHandlerResult DynamicMacros::onFocusEvent(const char *command) {
uint8_t b ;
: : Focus . read ( b ) ;
Kaleidoscop e. storage ( ) . update ( storage_base_ + pos + + , b ) ;
Runtim e. storage ( ) . update ( storage_base_ + pos + + , b ) ;
}
Kaleidoscop e. storage ( ) . commit ( ) ;
Runtim e. storage ( ) . commit ( ) ;
updateDynamicMacroCache ( ) ;
}
}