Extra2D/Extra2D/include/extra2d/modules/input_module.h

84 lines
1.6 KiB
C++

#pragma once
#include <extra2d/core/module.h>
#include <extra2d/input/input_config.h>
#include <extra2d/platform/iinput.h>
#include <extra2d/platform/iwindow.h>
namespace extra2d {
/**
* @brief 输入模块
* 管理键盘、鼠标、手柄和触摸输入
*/
class InputModule : public Module {
public:
/**
* @brief 构造函数
*/
InputModule();
/**
* @brief 析构函数
*/
~InputModule() override;
/**
* @brief 获取模块名称
* @return 模块名称
*/
const char* getName() const override { return "Input"; }
/**
* @brief 获取模块优先级
* @return 优先级
*/
int getPriority() const override { return 30; }
/**
* @brief 设置模块
*/
void setupModule() override;
/**
* @brief 销毁模块
*/
void destroyModule() override;
/**
* @brief 更新时
* @param ctx 更新上下文
*/
void onUpdate(UpdateContext& ctx) override;
/**
* @brief 设置输入配置
* @param config 输入配置数据
*/
void setInputConfig(const InputConfigData& config) { config_ = config; }
/**
* @brief 获取输入接口
* @return 输入接口指针
*/
IInput* getInput() const { return input_; }
/**
* @brief 设置窗口
* @param window 窗口接口指针
*/
void setWindow(IWindow* window);
private:
/**
* @brief 使用窗口初始化输入
*/
void initializeWithWindow();
IWindow* window_ = nullptr;
IInput* input_ = nullptr;
InputConfigData config_;
};
} // namespace extra2d