增加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

@ -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,11 +1,8 @@
#ifndef HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
#define HGL_IO_DEVICE_MOUSE_EVENT_INCLUDE
#pragma once
#include<hgl/TypeFunc.h>
namespace hgl
namespace hgl::io
{
namespace io
{
/**
*
*/
@ -13,6 +10,9 @@ namespace hgl
{
NONE=0,
Select,
Start,
Up,
Down,
Left,
@ -24,38 +24,5 @@ namespace hgl
_24, _25, _26, _27, _28, _29, _30, _31,
ENUM_CLASS_RANGE(NONE,_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 JoystickButton
}//namespace hgl::io