summaryrefslogtreecommitdiff
path: root/core/input/input_enums.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/input/input_enums.h')
-rw-r--r--core/input/input_enums.h184
1 files changed, 112 insertions, 72 deletions
diff --git a/core/input/input_enums.h b/core/input/input_enums.h
index 4479a85bfe..8601007ac9 100644
--- a/core/input/input_enums.h
+++ b/core/input/input_enums.h
@@ -31,90 +31,106 @@
#ifndef INPUT_ENUMS_H
#define INPUT_ENUMS_H
-enum HatDir {
- HAT_UP = 0,
- HAT_RIGHT = 1,
- HAT_DOWN = 2,
- HAT_LEFT = 3,
- HAT_MAX = 4,
+enum class HatDir {
+ UP = 0,
+ RIGHT = 1,
+ DOWN = 2,
+ LEFT = 3,
+ MAX = 4,
};
-enum HatMask {
- HAT_MASK_CENTER = 0,
- HAT_MASK_UP = 1,
- HAT_MASK_RIGHT = 2,
- HAT_MASK_DOWN = 4,
- HAT_MASK_LEFT = 8,
+enum class HatMask {
+ CENTER = 0,
+ UP = 1,
+ RIGHT = 2,
+ DOWN = 4,
+ LEFT = 8,
};
-enum JoyAxis {
- JOY_AXIS_INVALID = -1,
- JOY_AXIS_LEFT_X = 0,
- JOY_AXIS_LEFT_Y = 1,
- JOY_AXIS_RIGHT_X = 2,
- JOY_AXIS_RIGHT_Y = 3,
- JOY_AXIS_TRIGGER_LEFT = 4,
- JOY_AXIS_TRIGGER_RIGHT = 5,
- JOY_AXIS_SDL_MAX = 6,
- JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
+enum class JoyAxis {
+ INVALID = -1,
+ LEFT_X = 0,
+ LEFT_Y = 1,
+ RIGHT_X = 2,
+ RIGHT_Y = 3,
+ TRIGGER_LEFT = 4,
+ TRIGGER_RIGHT = 5,
+ SDL_MAX = 6,
+ MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
};
-enum JoyButton {
- JOY_BUTTON_INVALID = -1,
- JOY_BUTTON_A = 0,
- JOY_BUTTON_B = 1,
- JOY_BUTTON_X = 2,
- JOY_BUTTON_Y = 3,
- JOY_BUTTON_BACK = 4,
- JOY_BUTTON_GUIDE = 5,
- JOY_BUTTON_START = 6,
- JOY_BUTTON_LEFT_STICK = 7,
- JOY_BUTTON_RIGHT_STICK = 8,
- JOY_BUTTON_LEFT_SHOULDER = 9,
- JOY_BUTTON_RIGHT_SHOULDER = 10,
- JOY_BUTTON_DPAD_UP = 11,
- JOY_BUTTON_DPAD_DOWN = 12,
- JOY_BUTTON_DPAD_LEFT = 13,
- JOY_BUTTON_DPAD_RIGHT = 14,
- JOY_BUTTON_MISC1 = 15,
- JOY_BUTTON_PADDLE1 = 16,
- JOY_BUTTON_PADDLE2 = 17,
- JOY_BUTTON_PADDLE3 = 18,
- JOY_BUTTON_PADDLE4 = 19,
- JOY_BUTTON_TOUCHPAD = 20,
- JOY_BUTTON_SDL_MAX = 21,
- JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
+enum class JoyButton {
+ INVALID = -1,
+ A = 0,
+ B = 1,
+ X = 2,
+ Y = 3,
+ BACK = 4,
+ GUIDE = 5,
+ START = 6,
+ LEFT_STICK = 7,
+ RIGHT_STICK = 8,
+ LEFT_SHOULDER = 9,
+ RIGHT_SHOULDER = 10,
+ DPAD_UP = 11,
+ DPAD_DOWN = 12,
+ DPAD_LEFT = 13,
+ DPAD_RIGHT = 14,
+ MISC1 = 15,
+ PADDLE1 = 16,
+ PADDLE2 = 17,
+ PADDLE3 = 18,
+ PADDLE4 = 19,
+ TOUCHPAD = 20,
+ SDL_MAX = 21,
+ MAX = 36, // Android supports up to 36 buttons.
};
-enum MIDIMessage {
- MIDI_MESSAGE_NONE = 0,
- MIDI_MESSAGE_NOTE_OFF = 0x8,
- MIDI_MESSAGE_NOTE_ON = 0x9,
- MIDI_MESSAGE_AFTERTOUCH = 0xA,
- MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
- MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
- MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
- MIDI_MESSAGE_PITCH_BEND = 0xE,
+enum class MIDIMessage {
+ NONE = 0,
+ NOTE_OFF = 0x8,
+ NOTE_ON = 0x9,
+ AFTERTOUCH = 0xA,
+ CONTROL_CHANGE = 0xB,
+ PROGRAM_CHANGE = 0xC,
+ CHANNEL_PRESSURE = 0xD,
+ PITCH_BEND = 0xE,
};
-enum MouseButton {
- MOUSE_BUTTON_NONE = 0,
- MOUSE_BUTTON_LEFT = 1,
- MOUSE_BUTTON_RIGHT = 2,
- MOUSE_BUTTON_MIDDLE = 3,
- MOUSE_BUTTON_WHEEL_UP = 4,
- MOUSE_BUTTON_WHEEL_DOWN = 5,
- MOUSE_BUTTON_WHEEL_LEFT = 6,
- MOUSE_BUTTON_WHEEL_RIGHT = 7,
- MOUSE_BUTTON_XBUTTON1 = 8,
- MOUSE_BUTTON_XBUTTON2 = 9,
- MOUSE_BUTTON_MASK_LEFT = (1 << (MOUSE_BUTTON_LEFT - 1)),
- MOUSE_BUTTON_MASK_RIGHT = (1 << (MOUSE_BUTTON_RIGHT - 1)),
- MOUSE_BUTTON_MASK_MIDDLE = (1 << (MOUSE_BUTTON_MIDDLE - 1)),
- MOUSE_BUTTON_MASK_XBUTTON1 = (1 << (MOUSE_BUTTON_XBUTTON1 - 1)),
- MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1)),
+enum class MouseButton {
+ NONE = 0,
+ LEFT = 1,
+ RIGHT = 2,
+ MIDDLE = 3,
+ WHEEL_UP = 4,
+ WHEEL_DOWN = 5,
+ WHEEL_LEFT = 6,
+ WHEEL_RIGHT = 7,
+ MB_XBUTTON1 = 8, // "XBUTTON1" is a reserved word on Windows.
+ MB_XBUTTON2 = 9, // "XBUTTON2" is a reserved word on Windows.
+ MASK_LEFT = (1 << (LEFT - 1)),
+ MASK_RIGHT = (1 << (RIGHT - 1)),
+ MASK_MIDDLE = (1 << (MIDDLE - 1)),
+ MASK_XBUTTON1 = (1 << (MB_XBUTTON1 - 1)),
+ MASK_XBUTTON2 = (1 << (MB_XBUTTON2 - 1)),
};
+inline MouseButton mouse_button_to_mask(MouseButton button) {
+ return MouseButton(1 << ((int)button - 1));
+}
+
+inline MouseButton operator&(MouseButton a, MouseButton b) {
+ return (MouseButton)((int)a & (int)b);
+}
+
+inline MouseButton operator|(MouseButton a, MouseButton b) {
+ return (MouseButton)((int)a | (int)b);
+}
+
+inline MouseButton operator^(MouseButton a, MouseButton b) {
+ return (MouseButton)((int)a ^ (int)b);
+}
+
inline MouseButton &operator|=(MouseButton &a, MouseButton b) {
return (MouseButton &)((int &)a |= (int)b);
}
@@ -123,4 +139,28 @@ inline MouseButton &operator&=(MouseButton &a, MouseButton b) {
return (MouseButton &)((int &)a &= (int)b);
}
+inline MouseButton operator~(MouseButton a) {
+ return (MouseButton)(~(int)a);
+}
+
+inline HatMask operator|(HatMask a, HatMask b) {
+ return (HatMask)((int)a | (int)b);
+}
+
+inline HatMask operator&(HatMask a, HatMask b) {
+ return (HatMask)((int)a & (int)b);
+}
+
+inline HatMask &operator&=(HatMask &a, HatMask b) {
+ return (HatMask &)((int &)a &= (int)b);
+}
+
+inline HatMask &operator|=(HatMask &a, HatMask b) {
+ return (HatMask &)((int &)a |= (int)b);
+}
+
+inline HatMask operator~(HatMask a) {
+ return (HatMask)(~(int)a);
+}
+
#endif // INPUT_ENUMS_H