3 #include "forwarddecl/Event.hpp"
11 enum class ButtonState {
14 namespace button_state::unsafe {
15 constexpr ButtonState fromSDLEnum(
const uint8_t s) noexcept {
16 if (s == SDL_RELEASED)
17 return ButtonState::Up;
19 return ButtonState::Down;
21 constexpr uint8_t toSDLEnum(
const ButtonState s) noexcept {
22 if (s == ButtonState::Up)
32 kb::Scancode scancode;
40 TopLeft, Top, TopRight,
42 BottomLeft, Bottom, BottomRight
45 constexpr
explicit HatState(
const uint8_t v) noexcept :
46 data_(unsafe_fromSDLEnum_(v))
48 constexpr uint8_t unsafe_toSDLEnum()
const {
49 if (data_ == Position::TopLeft)
50 return SDL_HAT_LEFTUP;
51 if (data_ == Position::Top)
53 if (data_ == Position::TopRight)
54 return SDL_HAT_RIGHTUP;
56 if (data_ == Position::Left)
58 if (data_ == Position::Center)
59 return SDL_HAT_CENTERED;
60 if (data_ == Position::Right)
61 return SDL_HAT_RIGHTUP;
63 if (data_ == Position::BottomLeft)
64 return SDL_HAT_LEFTDOWN;
65 if (data_ == Position::Bottom)
68 return SDL_HAT_RIGHTDOWN;
71 constexpr
bool pointsLeft()
const {
72 return data_ == Position::TopLeft || data_ == Position::Left || data_ == Position::BottomLeft;
74 constexpr
bool pointsRight()
const {
75 return data_ == Position::TopRight || data_ == Position::Right || data_ == Position::BottomRight;
78 constexpr
bool pointsUp()
const {
79 return data_ == Position::TopLeft || data_ == Position::Top || data_ == Position::TopRight;
81 constexpr
bool pointsDown()
const {
82 return data_ == Position::BottomLeft || data_ == Position::Bottom || data_ == Position::BottomRight;
85 constexpr Position pos()
const {
92 constexpr Position unsafe_fromSDLEnum_(
const uint8_t v) noexcept {
93 if (v == SDL_HAT_LEFTUP)
94 return Position::TopLeft;
95 else if (v == SDL_HAT_UP)
97 else if (v == SDL_HAT_RIGHTUP)
98 return Position::TopRight;
100 else if (v == SDL_HAT_LEFT)
101 return Position::Left;
102 else if (v == SDL_HAT_CENTERED)
103 return Position::Center;
104 else if (v == SDL_HAT_RIGHT)
105 return Position::Right;
107 else if (v == SDL_HAT_LEFTDOWN)
108 return Position::BottomLeft;
109 else if (v == SDL_HAT_DOWN)
110 return Position::Bottom;
112 return Position::BottomRight;
115 namespace hatState::position {
116 constexpr
const char* toString(
const HatState::Position p) {
117 if (p == HatState::Position::TopLeft)
119 if (p == HatState::Position::Top)
121 if (p == HatState::Position::TopRight)
124 if (p == HatState::Position::Left)
126 if (p == HatState::Position::Center)
128 if (p == HatState::Position::Right)
131 if (p == HatState::Position::BottomLeft)
132 return "bottom-left";
133 if (p == HatState::Position::Bottom)
136 return "bottom-right";
146 uint32_t unsafe_winId;
169 SDL_FingerID fingerId;
177 SDL_FingerID fingerId;
185 SDL_FingerID fingerId;
209 enum class WheelDirection {
212 namespace wheel_direction::unsafe {
213 constexpr WheelDirection fromSDLEnum(
const uint32_t v) noexcept {
214 if (v == SDL_MOUSEWHEEL_NORMAL)
215 return WheelDirection::Normal;
217 return WheelDirection::Reverse;
219 constexpr uint32_t toSDLEnum(
const WheelDirection v) noexcept {
220 if (v == WheelDirection::Normal)
221 return SDL_MOUSEWHEEL_NORMAL;
223 return SDL_MOUSEWHEEL_FLIPPED;
230 ::rolmodl::mouse::Btn button;
238 ::rolmodl::mouse::Btn button;
256 WheelDirection direction;
262 SDL_JoystickID joystickId;
267 SDL_JoystickID joystickId;
272 SDL_JoystickID joystickId;
278 SDL_JoystickID joystickId;
283 SDL_JoystickID joystickId;
298 namespace controller {
300 SDL_JoystickID controllerId;
306 SDL_JoystickID controllerId;
311 SDL_JoystickID controllerId;
318 SDL_JoystickID controllerId;
321 SDL_JoystickID controllerId;
324 SDL_JoystickID controllerId;
342 SDL_GestureID gestureId;
350 SDL_GestureID gestureId;
396 namespace drag_n_drop {
407 namespace audio_device {