forked from jjiangweilan/WeilanEngine-GL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.hpp
49 lines (45 loc) · 1.75 KB
/
Input.hpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "System/InputSystem.hpp"
namespace wlEngine {
using ControllerAxisType=Sint16;
using ControllerButtonType=Uint8;
enum class ControllerButton {
ButtonLeft = SDL_CONTROLLER_BUTTON_X,
ButtonRight = SDL_CONTROLLER_BUTTON_B,
ButtonUp = SDL_CONTROLLER_BUTTON_Y,
ButtonDown = SDL_CONTROLLER_BUTTON_A,
LeftShoulder = SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
RightShoulder = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
DpadDown = SDL_CONTROLLER_BUTTON_DPAD_DOWN,
DpadUp = SDL_CONTROLLER_BUTTON_DPAD_UP,
DpadLeft = SDL_CONTROLLER_BUTTON_DPAD_LEFT,
DpadRight = SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
Start = SDL_CONTROLLER_BUTTON_START,
Back = SDL_CONTROLLER_BUTTON_BACK,
RightStick = SDL_CONTROLLER_BUTTON_RIGHTSTICK,
LeftStick = SDL_CONTROLLER_BUTTON_LEFTSTICK,
Home = SDL_CONTROLLER_BUTTON_GUIDE
};
enum class ControllerAxis {
AxisLeftX = SDL_CONTROLLER_AXIS_LEFTX,
AxisLeftY = SDL_CONTROLLER_AXIS_LEFTY,
AxisRightX = SDL_CONTROLLER_AXIS_RIGHTX,
AxisRightY = SDL_CONTROLLER_AXIS_RIGHTY,
TriggerLeft = SDL_CONTROLLER_AXIS_TRIGGERLEFT,
TriggerRight = SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
};
/**
* @brief Input class is used to hide InputSystem from Gameplay Code
*/
class Input {
public:
static const ControllerAxisType AXIS_MAX = 0x7fff;
/* Keyboard ********************************************/
static uint8_t getKeyStatus(SDL_Scancode);
static const std::vector<SDL_Scancode>& getKeypressSequence();
static void getMouseWheel(int& x, int& y);
/* Controller ********************************************/
static ControllerAxisType getControllerAxis(const ControllerAxis& axis);
static ControllerButtonType getControllerButton(const ControllerButton& button);
};
}