9#include <unordered_map>
59 float getAxis(
const std::string& axis)
const;
96 enum class BindingType { Key, Mouse };
98 struct CompiledBinding {
99 BindingType type = BindingType::Key;
104 struct CompiledAction {
105 std::vector<CompiledBinding> bindings;
108 struct CompiledAxis {
109 std::vector<CompiledBinding> negative;
110 std::vector<CompiledBinding> positive;
116 Input(
const Input&) =
delete;
117 Input& operator=(
const Input&) =
delete;
118 Input(Input&&) =
delete;
119 Input& operator=(Input&&) =
delete;
122 bool compileBinding(
const std::string& name, CompiledBinding& out)
const;
123 static KeyCode parseKeyCode(
const std::string& name);
124 static MouseButton parseMouseButton(
const std::string& name);
125 static std::string normalizeKeyName(
const std::string& name);
127 bool isBindingDown(
const CompiledBinding& b)
const;
128 bool isBindingPressed(
const CompiledBinding& b)
const;
129 bool isBindingReleased(
const CompiledBinding& b)
const;
131 bool anyBindingDown(
const std::vector<CompiledBinding>& bindings)
const;
132 bool anyBindingPressed(
const std::vector<CompiledBinding>& bindings)
const;
133 bool anyBindingReleased(
const std::vector<CompiledBinding>& bindings)
const;
136 std::array<bool, static_cast<int>(KeyCode::Count)> m_currentKeys{};
137 std::array<bool, static_cast<int>(KeyCode::Count)> m_previousKeys{};
138 std::array<bool, static_cast<int>(MouseButton::Count)> m_currentMouseButtons{};
139 std::array<bool, static_cast<int>(MouseButton::Count)> m_previousMouseButtons{};
140 Vector2 m_mouseScroll{ 0.0f, 0.0f };
141 Vector2 m_injectedMousePosition{ 0.0f, 0.0f };
142 bool m_hasInjectedMousePosition =
false;
145 std::unordered_map<std::string, CompiledAction> m_actions;
146 std::unordered_map<std::string, CompiledAxis> m_axes;
147 bool m_mappingsReady =
false;
#define SHIT_API
定义 Core.h:14
MouseButton
鼠标按键码(左/右/中键 + 两个侧键)
定义 KeyCode.h:178
KeyCode
键盘键码表(基于 SDL 扫描码,值为物理键位、不随键盘布局变化)
定义 KeyCode.h:14
glm::vec2 Vector2
定义 Math.h:7