增加InputMapping.h
This commit is contained in:
parent
5fde4980e1
commit
10108953eb
@ -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,
|
||||||
|
70
inc/hgl/io/event/InputMapping.h
Normal file
70
inc/hgl/io/event/InputMapping.h
Normal 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
|
@ -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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user