|
ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
输入管理(单例) 更多...
#include <Input.h>
Public 成员函数 | |
| bool | isKeyDown (KeyCode code) const |
| bool | isKeyPressed (KeyCode code) const |
| bool | isKeyReleased (KeyCode code) const |
| bool | isMouseButtonDown (MouseButton code) const |
| bool | isMouseButtonPressed (MouseButton code) const |
| bool | isMouseButtonReleased (MouseButton code) const |
| Vector2 | getMousePosition () const |
| Vector2 | getMouseScroll () const |
| bool | isActionDown (const std::string &action) const |
| bool | isActionPressed (const std::string &action) const |
| bool | isActionReleased (const std::string &action) const |
| float | getAxis (const std::string &axis) const |
| void | initMappings () |
| 从 Config 预编译动作/轴绑定(Config::Init 之后调用) | |
| void | update () |
| 帧末:current → previous | |
| void | handleEvent (const SDL_Event &event) |
静态 Public 成员函数 | |
| static Input & | GetInstance () |
| static bool | IsKeyDown (KeyCode code) |
| static bool | IsKeyPressed (KeyCode code) |
| static bool | IsKeyReleased (KeyCode code) |
| static bool | IsMouseButtonDown (MouseButton code) |
| static bool | IsMouseButtonPressed (MouseButton code) |
| static bool | IsMouseButtonReleased (MouseButton code) |
| static Vector2 | GetMousePosition () |
| static Vector2 | GetMouseScroll () |
| static bool | IsActionDown (const std::string &action) |
| static bool | IsActionPressed (const std::string &action) |
| static bool | IsActionReleased (const std::string &action) |
| static float | GetAxis (const std::string &axis) |
| static void | InitMappings () |
| static void | Update () |
| static void | HandleEvent (const SDL_Event &event) |
友元 | |
| class | EngineContext |
输入管理(单例)
同时提供两层 API(类似 Unity / Godot):
命名约定(与 Unity 不同,请注意): Down = 刚按下(仅一帧) Pressed = 持续按住 Released = 刚松开(仅一帧)
键名使用 SDL 官方 scancode 名("Space"/"A"/"Left Shift"), 也接受无空格别名("LeftShift" → "Left Shift")。 鼠标:MouseButton.Left / Right / Middle / XButton1 / XButton2
|
inlinestatic |
| float getAxis | ( | const std::string & | axis | ) | const |
|
static |
|
inlinestatic |
| Vector2 getMousePosition | ( | ) | const |
|
inlinestatic |
| Vector2 getMouseScroll | ( | ) | const |
|
inlinestatic |
| void handleEvent | ( | const SDL_Event & | event | ) |
|
inlinestatic |
| void initMappings | ( | ) |
从 Config 预编译动作/轴绑定(Config::Init 之后调用)
|
inlinestatic |
| bool isActionDown | ( | const std::string & | action | ) | const |
|
inlinestatic |
| bool isActionPressed | ( | const std::string & | action | ) | const |
|
inlinestatic |
| bool isActionReleased | ( | const std::string & | action | ) | const |
|
inlinestatic |
| bool isKeyDown | ( | KeyCode | code | ) | const |
|
inlinestatic |
| bool isKeyPressed | ( | KeyCode | code | ) | const |
|
inlinestatic |
| bool isKeyReleased | ( | KeyCode | code | ) | const |
|
inlinestatic |
| bool isMouseButtonDown | ( | MouseButton | code | ) | const |
|
inlinestatic |
| bool isMouseButtonPressed | ( | MouseButton | code | ) | const |
|
inlinestatic |
| bool isMouseButtonReleased | ( | MouseButton | code | ) | const |
|
inlinestatic |
| void update | ( | ) |
帧末:current → previous
|
friend |