branches/osd/src/lib/bgfx/common/entry/input.cpp
| r31739 | r31740 | |
| 5 | 5 | |
| 6 | 6 | #include <memory.h> |
| 7 | 7 | #include <string> |
| 8 | | #include <unordered_map> |
| 9 | 8 | |
| 10 | 9 | #include "entry_p.h" |
| 11 | 10 | #include "input.h" |
| 12 | 11 | |
| 12 | #include <tinystl/allocator.h> |
| 13 | #include <tinystl/unordered_map.h> |
| 14 | namespace stl = tinystl; |
| 15 | |
| 13 | 16 | struct Mouse |
| 14 | 17 | { |
| 15 | 18 | Mouse() |
| r31739 | r31740 | |
| 112 | 115 | |
| 113 | 116 | void addBindings(const char* _name, const InputBinding* _bindings) |
| 114 | 117 | { |
| 115 | | m_inputBindingsMap.insert(std::make_pair(_name, _bindings) ); |
| 118 | m_inputBindingsMap.insert(stl::make_pair(_name, _bindings) ); |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | void removeBindings(const char* _name) |
| 119 | 122 | { |
| 120 | | m_inputBindingsMap.erase(_name); |
| 123 | m_inputBindingsMap.erase(m_inputBindingsMap.find(_name)); |
| 121 | 124 | } |
| 122 | 125 | |
| 123 | 126 | void process(const InputBinding* _bindings) |
| r31739 | r31740 | |
| 169 | 172 | m_keyboard.reset(); |
| 170 | 173 | } |
| 171 | 174 | |
| 172 | | typedef std::unordered_map<std::string, const InputBinding*> InputBindingMap; |
| 175 | typedef stl::unordered_map<const char*, const InputBinding*> InputBindingMap; |
| 173 | 176 | InputBindingMap m_inputBindingsMap; |
| 174 | 177 | Mouse m_mouse; |
| 175 | 178 | Keyboard m_keyboard; |
branches/osd/src/lib/bgfx/common/entry/cmd.cpp
| r31739 | r31740 | |
| 13 | 13 | #include "dbg.h" |
| 14 | 14 | #include "cmd.h" |
| 15 | 15 | #include <string> |
| 16 | | #include <unordered_map> |
| 16 | #include <tinystl/allocator.h> |
| 17 | #include <tinystl/unordered_map.h> |
| 18 | namespace stl = tinystl; |
| 17 | 19 | |
| 18 | 20 | struct CmdContext |
| 19 | 21 | { |
| r31739 | r31740 | |
| 30 | 32 | uint32_t cmd = bx::hashMurmur2A(_name, (uint32_t)strlen(_name) ); |
| 31 | 33 | BX_CHECK(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name); |
| 32 | 34 | Func fn = { _fn, _userData }; |
| 33 | | m_lookup.insert(std::make_pair(cmd, fn) ); |
| 35 | m_lookup.insert(stl::make_pair(cmd, fn) ); |
| 34 | 36 | } |
| 35 | 37 | |
| 36 | 38 | void exec(const char* _cmd) |
| r31739 | r31740 | |
| 82 | 84 | void* m_userData; |
| 83 | 85 | }; |
| 84 | 86 | |
| 85 | | typedef std::unordered_map<uint32_t, Func> CmdLookup; |
| 87 | typedef stl::unordered_map<uint32_t, Func> CmdLookup; |
| 86 | 88 | CmdLookup m_lookup; |
| 87 | 89 | }; |
| 88 | 90 | |