#pragma once #include "character/CharacterActionTypes.h" #include #include namespace frostbite2D { /// 将 SDL 键盘/手柄事件统一转换为角色命令,避免状态机直接依赖设备细节。 class CharacterInputRouter { public: bool OnKeyDown(const KeyEvent& event); bool OnKeyUp(const KeyUpEvent& event); bool OnJoystickAxis(const JoystickAxisEvent& event); bool OnJoystickButtonDown(const JoystickButtonDownEvent& event); bool OnJoystickButtonUp(const JoystickButtonUpEvent& event); void EmitCommands(CharacterCommandBuffer& commandBuffer); void ClearFrameState(); private: bool left_ = false; bool right_ = false; bool up_ = false; bool down_ = false; bool jumpPressed_ = false; bool attackPressed_ = false; bool skill1Pressed_ = false; bool dashPressed_ = false; float leftStickX_ = 0.0f; float leftStickY_ = 0.0f; float joystickDeadZone_ = 0.2f; }; } // namespace frostbite2D