@ -27,20 +27,20 @@ namespace plugin {
char FocusSerial : : command_ [ 32 ] ;
char FocusSerial : : command_ [ 32 ] ;
void FocusSerial : : drain ( void ) {
void FocusSerial : : drain ( void ) {
if ( Serial . available ( ) )
if ( KeyboardHardware. serialPort ( ) . available ( ) )
while ( Serial . peek ( ) ! = ' \n ' )
while ( KeyboardHardware. serialPort ( ) . peek ( ) ! = ' \n ' )
Serial . read ( ) ;
KeyboardHardware. serialPort ( ) . read ( ) ;
}
}
EventHandlerResult FocusSerial : : beforeReportingState ( ) {
EventHandlerResult FocusSerial : : beforeReportingState ( ) {
if ( Serial . available ( ) = = 0 )
if ( KeyboardHardware. serialPort ( ) . available ( ) = = 0 )
return EventHandlerResult : : OK ;
return EventHandlerResult : : OK ;
uint8_t i = 0 ;
uint8_t i = 0 ;
do {
do {
command_ [ i + + ] = Serial . read ( ) ;
command_ [ i + + ] = KeyboardHardware. serialPort ( ) . read ( ) ;
if ( Serial . peek ( ) = = ' \n ' )
if ( KeyboardHardware. serialPort ( ) . peek ( ) = = ' \n ' )
break ;
break ;
} while ( command_ [ i - 1 ] ! = ' ' & & i < 32 ) ;
} while ( command_ [ i - 1 ] ! = ' ' & & i < 32 ) ;
if ( command_ [ i - 1 ] = = ' ' )
if ( command_ [ i - 1 ] = = ' ' )
@ -50,12 +50,12 @@ EventHandlerResult FocusSerial::beforeReportingState() {
Kaleidoscope . onFocusEvent ( command_ ) ;
Kaleidoscope . onFocusEvent ( command_ ) ;
Serial . println ( F ( " \r \n . " ) ) ;
KeyboardHardware. serialPort ( ) . println ( F ( " \r \n . " ) ) ;
drain ( ) ;
drain ( ) ;
if ( Serial . peek ( ) = = ' \n ' )
if ( KeyboardHardware. serialPort ( ) . peek ( ) = = ' \n ' )
Serial . read ( ) ;
KeyboardHardware. serialPort ( ) . read ( ) ;
return EventHandlerResult : : OK ;
return EventHandlerResult : : OK ;
}
}
@ -65,7 +65,7 @@ bool FocusSerial::handleHelp(const char *command,
if ( strcmp_P ( command , PSTR ( " help " ) ) ! = 0 )
if ( strcmp_P ( command , PSTR ( " help " ) ) ! = 0 )
return false ;
return false ;
Serial . println ( ( const __FlashStringHelper * ) help_message ) ;
KeyboardHardware. serialPort ( ) . println ( ( const __FlashStringHelper * ) help_message ) ;
return true ;
return true ;
}
}
@ -75,7 +75,7 @@ EventHandlerResult FocusSerial::onFocusEvent(const char *command) {
}
}
void FocusSerial : : printBool ( bool b ) {
void FocusSerial : : printBool ( bool b ) {
Serial . print ( ( b ) ? F ( " true " ) : F ( " false " ) ) ;
KeyboardHardware. serialPort ( ) . print ( ( b ) ? F ( " true " ) : F ( " false " ) ) ;
}
}
}
}