增加InputMapping.h

This commit is contained in:
hyzboy 2025-06-08 22:09:22 +08:00
parent 5fde4980e1
commit 10108953eb
3 changed files with 94 additions and 57 deletions

View File

@ -14,8 +14,8 @@ namespace hgl::io
constexpr size_t EventHeaderBytes=sizeof(EventHeader); constexpr size_t EventHeaderBytes=sizeof(EventHeader);
/** /**
* *
*/ */
enum class EventProcResult enum class EventProcResult
{ {
Continue, Continue,

View File

@ -0,0 +1,70 @@
#pragma once
#include<hgl/type/IDName.h>
#include<hgl/io/event/KeyboardEvent.h>
#include<hgl/io/event/MouseEvent.h>
#include<hgl/io/event/JoystickEvent.h>
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<InputSource> sources; //输入源列表
public:
};
}//namespace hgl::io

View File

@ -1,61 +1,28 @@
#ifndef HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE #pragma once
#define HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
#include<hgl/TypeFunc.h> #include<hgl/TypeFunc.h>
namespace hgl namespace hgl::io
{ {
namespace io /**
{ *
/** */
* enum class JoystickButton
*/ {
enum class JoystickButton NONE=0,
{
NONE=0,
Up, Select,
Down, Start,
Left,
Right,
_0, _1, _2, _3, _4, _5, _6, _7, Up,
_8, _9, _10, _11, _12, _13, _14, _15, Down,
_16, _17, _18, _19, _20, _21, _22, _23, Left,
_24, _25, _26, _27, _28, _29, _30, _31, 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 ENUM_CLASS_RANGE(NONE,_31)
{ };//enum class JoystickButton
Up =JoystickButton::Up, }//namespace hgl::io
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