diff --git a/inc/hgl/io/event/InputEvent.h b/inc/hgl/io/event/InputEvent.h index 51aea9f..b1c24a7 100644 --- a/inc/hgl/io/event/InputEvent.h +++ b/inc/hgl/io/event/InputEvent.h @@ -14,8 +14,8 @@ namespace hgl::io constexpr size_t EventHeaderBytes=sizeof(EventHeader); /** - * 事件处理结果 - */ + * 事件处理结果 + */ enum class EventProcResult { Continue, diff --git a/inc/hgl/io/event/InputMapping.h b/inc/hgl/io/event/InputMapping.h new file mode 100644 index 0000000..2b4404c --- /dev/null +++ b/inc/hgl/io/event/InputMapping.h @@ -0,0 +1,70 @@ +#pragma once + +#include +#include +#include +#include + +namespace hgl::io +{ + /** + * @brief 输入映射系统的名称 + * + * 这个名称用于标识输入映射系统的类型或实例。 + * 它可以用于在不同的输入映射系统之间进行区分。 + * + * 注意:这个名称并不是唯一的,可能会有多个输入映射系统使用相同的名称。 + * 因此,在使用时需要确保上下文的正确性。 + * + * 1.输入映射系统会让开发者定义一些输入事件名称,这些名称可以是任意的字符串。 + * + * 2.一个输入事件,可能被多个输入设备触发,比如你可以定义键盘上的某个按键、鼠标的左键、手柄的某个按钮均可以触发同一个输入事件。 + * + * 3.真实的输入部分是可以配置的。比如一个FPS游戏的主角移动,有的用户喜欢用WASD,而有的用户喜欢用方向键。 + * + * 4.这里映射的并不一定就是物理输入设备的键入,也可以数据流的输入。比如游戏回放,或是网络同步。更有可能是程序自己做的输入。 + */ + HGL_DEFINE_ANSI_IDNAME(InputEventName) + + enum class InputSourceType + { + None, //无效输入 + Button, //按键输入 + Axis, //轴输入 + Touch, //触控输入 + Trigger, //触发器输入 + Hat, //方向盘输入 + + ENUM_CLASS_RANGE(Button,Hat) + }; + + struct InputSource + { + InputSourceType type; //输入类型 + }; + + struct KeyboardInputSource:public InputSource + { + KeyboardButton key; //键盘按键 + }; + + struct MouseInputSource:public InputSource + { + MouseButton button; //鼠标按键 + }; + + struct JoystickButtonInputSource:public InputSource + { + JoystickButton button; //手柄按键 + }; + + class InputMapping + { + InputEventName name; //输入事件名称 + + ObjectList sources; //输入源列表 + + public: + + }; +}//namespace hgl::io diff --git a/inc/hgl/io/event/JoystickEvent.h b/inc/hgl/io/event/JoystickEvent.h index c81135f..dd86cbd 100644 --- a/inc/hgl/io/event/JoystickEvent.h +++ b/inc/hgl/io/event/JoystickEvent.h @@ -1,61 +1,28 @@ -#ifndef HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE -#define HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE +#pragma once #include -namespace hgl -{ - namespace io - { - /** - * 手柄按键枚举 - */ - enum class JoystickButton - { - NONE=0, +namespace hgl::io +{ + /** + * 手柄按键枚举 + */ + enum class JoystickButton + { + NONE=0, - Up, - Down, - Left, - Right, + Select, + Start, - _0, _1, _2, _3, _4, _5, _6, _7, - _8, _9, _10, _11, _12, _13, _14, _15, - _16, _17, _18, _19, _20, _21, _22, _23, - _24, _25, _26, _27, _28, _29, _30, _31, + Up, + Down, + Left, + Right, - ENUM_CLASS_RANGE(NONE,_31) - }; + _0, _1, _2, _3, _4, _5, _6, _7, + _8, _9, _10, _11, _12, _13, _14, _15, + _16, _17, _18, _19, _20, _21, _22, _23, + _24, _25, _26, _27, _28, _29, _30, _31, - enum class PlayStationButton - { - Up =JoystickButton::Up, - Down =JoystickButton::Down, - Left =JoystickButton::Left, - Right =JoystickButton::Right, - - Fork =JoystickButton::_0, // 叉 - Circle =JoystickButton::_1, // 圆 - Square =JoystickButton::_2, // 方 - Triangle =JoystickButton::_3, // 三角 - - L1 =JoystickButton::_6, L2 =JoystickButton::_4, - R1 =JoystickButton::_7, R2 =JoystickButton::_5, - Select =JoystickButton::_8, Start =JoystickButton::_9, - }; - - //enum class XBoxButton - //{ - // //DreamCast/XBOX - // X=JoystickButton::_2, - // Y=JoystickButton::_3, - // A=JoystickButton::_0, - // B=JoystickButton::_1, - // L=JoystickButton::_4, - // R=JoystickButton::_5, - - // //XBOX/XBOX360 - // //XBOX, //西瓜键 - //}; - }//namespace io -}//namespace hgl -#endif//HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE + ENUM_CLASS_RANGE(NONE,_31) + };//enum class JoystickButton +}//namespace hgl::io