summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/keyboard.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/Concept/Framework/keyboard.h')
-rw-r--r--source/Concept/Framework/keyboard.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/source/Concept/Framework/keyboard.h b/source/Concept/Framework/keyboard.h
new file mode 100644
index 0000000..d984586
--- /dev/null
+++ b/source/Concept/Framework/keyboard.h
@@ -0,0 +1,87 @@
+#ifndef _KEYBOARD_H
+#define _KEYBOARD_H
+
+#include "stdafx.h"
+
+class Keyboard : public IO_Module
+{
+public:
+ Keyboard()
+ {
+ this->parent = NULL;
+ this->moduleId = 0;
+ this->commandSetting = 0;
+ this->settingClearBuffer = 0;
+ }
+
+ Keyboard(uint32 keyboardId)
+ {
+ this->parent = NULL;
+ this->moduleId = keyboardId;
+
+ switch(keyboardId)
+ {
+ case IO_KEYBOARD_MAIN:
+ this->commandSetting = 27;
+ this->settingClearBuffer = 123;
+ break;
+ default:
+ this->commandSetting = 0;
+ this->settingClearBuffer = 0;
+ break;
+ }
+ }
+
+protected:
+ //Commands
+ uint8 commandSetting;
+ //Settings
+ uint8 settingClearBuffer;
+
+ void SendCommand(uint8 newCommand)
+ {
+ switch(moduleId)
+ {
+ case IO_KEYBOARD_MAIN:
+ uart1_putc(newCommand);
+ break;
+ default:
+ break;
+ }
+ }
+
+public:
+ uint8 GetInput()
+ {
+ uint16 input = uart1_getc();
+
+ if(input == 0x100)//no data
+ {
+ return 0xEE;//empty
+ }
+ else if(input >= '0' && input <= '9')
+ {
+ return (uint8)(input - '0');
+ }
+ else if(input == '*')
+ {
+ return 10;
+ }
+ else if(input == '#')
+ {
+ return 11;
+ }
+ else
+ {
+ return 0xFF;//unknown
+ }
+ }
+
+ void ClearKeyBuffer()
+ {
+ SendCommand(commandSetting);
+ SendCommand(settingClearBuffer);
+ }
+};
+
+#endif