#include <fstream>
#include <string>
+#include "keys.h"
+
using std::ifstream;
using std::string;
-typedef std::map<string,SDLKey> kMap;
+typedef std::map<string, SDLKey, comparestrings> kMap;
kMap keyMap;
/// ***** Private Method Headers *****
-void processLine(const string& str, inputMap* map);
+void processLine(const string& str);
bool extractLine(const string& str, string* name, string* value);
+void createKeyMap();
/// ***** Private Variables *****
const char* configDir = "configs/";
-const char* testFile = "test.cfg";
+const char* testFile = "test2.cfg";
/// ***** Public Methods *****
-void readConfigs(inputMap* map)
+void readConfigs()
{
char fileName[64];
+ createKeyMap();
+
strcpy(fileName, configDir);
strcat(fileName, testFile);
if(file.eof())
break;
- processLine(line, map);
+ processLine(line);
}
file.close();
/// ***** Private Methods *****
-void processLine(const string& str, inputMap* map)
+void processLine(const string& str)
{
string name;
string value;
if(extracted)
{
- //map->insert(name, value);
+ SDLKey key = keyMap[value];
+
+ if(0 != key)
+ {
+ *(key::sdlMap[name]) = key;
+ }
cout << name << endl;
cout << value << endl;
+ cout << key << endl;
}
}
name->clear();
value->clear();
- name->replace(0, 0, c_str, name_start, name_end-name_start);
- value->replace(0, 0, c_str, value_start, value_end-value_start);
+ name->replace (0, 0, c_str, name_start, name_end - name_start);
+ value->replace (0, 0, c_str, value_start, value_end - value_start);
return true;
}
-bool extractKey(const string& str, Uint8* key)
-{
-// if(str.length() != 1)
-// return false;
-
- return false;
-}
-
void createKeyMap()
{
// add all the letters
for (int i = '0'; i <= '9'; i++)
keyMap["" + (char)i] = (SDLKey)i;
+ keyMap["k"] = (SDLKey)'k';
+
/*
// add the function keys
int F1 = (int)Key.F1;
}
*/
- keyMap["LCtrl"] = SDLK_LCTRL;
- keyMap["LeftControl"] = SDLK_LCTRL;
- keyMap["LAlt"] = SDLK_LALT;
- keyMap["LeftAlt"] = SDLK_LALT;
- keyMap["LShift"] = SDLK_LSHIFT;
- keyMap["LeftShift"] = SDLK_LSHIFT;
- keyMap["LWin"] = SDLK_LSUPER;
- keyMap["LeftWindows"] = SDLK_LSUPER;
- keyMap["LeftMeta"] = SDLK_LMETA;
- keyMap["LMeta"] = SDLK_LMETA;
-
- keyMap["RCtrl"] = SDLK_RCTRL;
- keyMap["RightControl"] = SDLK_RCTRL;
- keyMap["RAlt"] = SDLK_RALT;
- keyMap["RightAlt"] = SDLK_RALT;
- keyMap["RShift"] = SDLK_RSHIFT;
- keyMap["RightShift"] = SDLK_RSHIFT;
- keyMap["RWin"] = SDLK_RSUPER;
- keyMap["RightWindows"] = SDLK_RSUPER;
- keyMap["RightMeta"] = SDLK_RMETA;
- keyMap["RMeta"] = SDLK_RMETA;
-
- keyMap["Esc"] = SDLK_ESCAPE;
- keyMap["Escape"] = SDLK_ESCAPE;
-
- keyMap["Return"] = SDLK_RETURN;
- keyMap["Enter"] = SDLK_RETURN;
-
- keyMap["Insert"] = SDLK_INSERT;
- keyMap["Home"] = SDLK_HOME;
- keyMap["Delete"] = SDLK_DELETE;
- keyMap["End"] = SDLK_END;
- keyMap["PageUp"] = SDLK_PAGEUP;
- keyMap["PageDown"] = SDLK_PAGEDOWN;
-
- keyMap["Minus"] = SDLK_MINUS;
- keyMap["Equal"] = SDLK_EQUALS;
- keyMap["Equals"] = SDLK_EQUALS;
- keyMap["LeftBracket"] = SDLK_LEFTBRACKET;
- keyMap["LBracket"] = SDLK_LEFTBRACKET;
- keyMap["RightBracket"] = SDLK_RIGHTBRACKET;
- keyMap["RBracket"] = SDLK_RIGHTBRACKET;
- keyMap["Backslash"] = SDLK_BACKSLASH;
- keyMap["Slash"] = SDLK_SLASH;
- keyMap["Semicolon"] = SDLK_SEMICOLON;
- keyMap["Semi"] = SDLK_SEMICOLON;
- keyMap["Quote"] = SDLK_QUOTE;
- keyMap["Comma"] = SDLK_COMMA;
- keyMap["Period"] = SDLK_PERIOD;
- keyMap["Space"] = SDLK_SPACE;
- keyMap["BSpace"] = SDLK_BACKSPACE;
- keyMap["Backspace"] = SDLK_BACKSPACE;
- keyMap["BackSpace"] = SDLK_BACKSPACE;
-
- keyMap["Tab"] = SDLK_TAB;
- keyMap["BackQuote"] = SDLK_BACKQUOTE;
- keyMap["BQuote"] = SDLK_BACKQUOTE;
- keyMap["CapsLock"] = SDLK_CAPSLOCK;
- keyMap["Caps"] = SDLK_CAPSLOCK;
-
- keyMap["Up"] = SDLK_UP;
- keyMap["Down"] = SDLK_DOWN;
- keyMap["Left"] = SDLK_LEFT;
- keyMap["Right"] = SDLK_RIGHT;
+ keyMap["LCtrl"] = SDLK_LCTRL;
+ keyMap["LeftControl"] = SDLK_LCTRL;
+ keyMap["LAlt"] = SDLK_LALT;
+ keyMap["LeftAlt"] = SDLK_LALT;
+ keyMap["LShift"] = SDLK_LSHIFT;
+ keyMap["LeftShift"] = SDLK_LSHIFT;
+ keyMap["LWin"] = SDLK_LSUPER;
+ keyMap["LeftWindows"] = SDLK_LSUPER;
+ keyMap["LeftMeta"] = SDLK_LMETA;
+ keyMap["LMeta"] = SDLK_LMETA;
+
+ keyMap["RCtrl"] = SDLK_RCTRL;
+ keyMap["RightControl"] = SDLK_RCTRL;
+ keyMap["RAlt"] = SDLK_RALT;
+ keyMap["RightAlt"] = SDLK_RALT;
+ keyMap["RShift"] = SDLK_RSHIFT;
+ keyMap["RightShift"] = SDLK_RSHIFT;
+ keyMap["RWin"] = SDLK_RSUPER;
+ keyMap["RightWindows"] = SDLK_RSUPER;
+ keyMap["RightMeta"] = SDLK_RMETA;
+ keyMap["RMeta"] = SDLK_RMETA;
+
+ keyMap["Esc"] = SDLK_ESCAPE;
+ keyMap["Escape"] = SDLK_ESCAPE;
+
+ keyMap["Return"] = SDLK_RETURN;
+ keyMap["Enter"] = SDLK_RETURN;
+
+ keyMap["Insert"] = SDLK_INSERT;
+ keyMap["Home"] = SDLK_HOME;
+ keyMap["Delete"] = SDLK_DELETE;
+ keyMap["End"] = SDLK_END;
+ keyMap["PageUp"] = SDLK_PAGEUP;
+ keyMap["PageDown"] = SDLK_PAGEDOWN;
+
+ keyMap["Minus"] = SDLK_MINUS;
+ keyMap["Equal"] = SDLK_EQUALS;
+ keyMap["Equals"] = SDLK_EQUALS;
+ keyMap["LeftBracket"] = SDLK_LEFTBRACKET;
+ keyMap["LBracket"] = SDLK_LEFTBRACKET;
+ keyMap["RightBracket"] = SDLK_RIGHTBRACKET;
+ keyMap["RBracket"] = SDLK_RIGHTBRACKET;
+ keyMap["Backslash"] = SDLK_BACKSLASH;
+ keyMap["Slash"] = SDLK_SLASH;
+ keyMap["Semicolon"] = SDLK_SEMICOLON;
+ keyMap["Semi"] = SDLK_SEMICOLON;
+ keyMap["Quote"] = SDLK_QUOTE;
+ keyMap["Comma"] = SDLK_COMMA;
+ keyMap["Period"] = SDLK_PERIOD;
+ keyMap["Space"] = SDLK_SPACE;
+ keyMap["BSpace"] = SDLK_BACKSPACE;
+ keyMap["Backspace"] = SDLK_BACKSPACE;
+ keyMap["BackSpace"] = SDLK_BACKSPACE;
+
+ keyMap["Tab"] = SDLK_TAB;
+ keyMap["BackQuote"] = SDLK_BACKQUOTE;
+ keyMap["BQuote"] = SDLK_BACKQUOTE;
+ keyMap["CapsLock"] = SDLK_CAPSLOCK;
+ keyMap["Caps"] = SDLK_CAPSLOCK;
+
+ keyMap["Up"] = SDLK_UP;
+ keyMap["Down"] = SDLK_DOWN;
+ keyMap["Left"] = SDLK_LEFT;
+ keyMap["Right"] = SDLK_RIGHT;
+
+ cout << "done" << endl;
+ cout << keyMap["k"] << endl;
}