summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/interpreter/command_handler.c
blob: dcd97b2735db93ab018b2da56bc1af0b8efa4182 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#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;
	}
}