1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef KEYCODES_H 4 #define KEYCODES_H 5 6 #include <stdio.h> 7 #include <string> 8 #include <map> 9 #include <set> 10 11 class CKeyCodes { 12 public: 13 CKeyCodes(); 14 void Reset(); 15 16 int GetCode(const std::string& name) const; 17 18 std::string GetName(int code) const; 19 std::string GetDefaultName(int code) const; 20 21 bool AddKeySymbol(const std::string& name, int code); 22 23 static bool IsModifier(int code); 24 bool IsPrintable(int code); 25 26 void PrintNameToCode() const; 27 void PrintCodeToName() const; 28 29 void SaveUserKeySymbols(FILE* file) const; 30 31 public: 32 static bool IsValidLabel(const std::string& label); 33 34 protected: 35 void AddPair(const std::string& name, const int code, const bool printable = false); 36 37 protected: 38 std::map<std::string, int> nameToCode; 39 std::map<int, std::string> codeToName; 40 std::map<std::string, int> defaultNameToCode; 41 std::map<int, std::string> defaultCodeToName; 42 std::set<int> printableCodes; 43 }; 44 45 extern CKeyCodes* keyCodes; 46 47 #endif /* KEYCODES_H */ 48