46 lines
1,021 B
C
46 lines
1,021 B
C
![]() |
#include "command_handler.h"
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
void Command_Handler::Update()
|
||
|
{
|
||
|
Keyboard* ourKeyboard = parent->GetModule<Keyboard>(IO_KEYBOARD_MAIN);
|
||
|
|
||
|
uint8 curInput = ourKeyboard->GetInput();
|
||
|
|
||
|
|
||
|
while(curInput != 0xEE && curInput != 0xFF)
|
||
|
{
|
||
|
if(curInput == 10)
|
||
|
{
|
||
|
ExecuteCommand();
|
||
|
}
|
||
|
else if(curInput == 11)
|
||
|
{
|
||
|
if(this->currentCommandLength > 0)
|
||
|
{
|
||
|
this->currentCommandLength--;
|
||
|
this->buffer[currentCommandLength] = NULL;
|
||
|
}
|
||
|
}
|
||
|
else if(curInput >= 0 && curInput <= 9)
|
||
|
{
|
||
|
if(this->currentCommandLength < COMMAND_BUFFER_SIZE)
|
||
|
{
|
||
|
this->buffer[this->currentCommandLength] = '0' + curInput;
|
||
|
this->currentCommandLength++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
curInput = ourKeyboard->GetInput();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
void Command_Handler::ExecuteCommand()
|
||
|
{
|
||
|
if(this->buffer[0] == '5')
|
||
|
{
|
||
|
this->displayDistanceSensors = true;
|
||
|
}
|
||
|
}
|