Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/core/input/input_enums.h
9898 views
1
/**************************************************************************/
2
/* input_enums.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "core/error/error_macros.h"
34
35
enum class InputEventType {
36
INVALID = -1,
37
KEY,
38
MOUSE_BUTTON,
39
MOUSE_MOTION,
40
JOY_MOTION,
41
JOY_BUTTON,
42
SCREEN_TOUCH,
43
SCREEN_DRAG,
44
MAGNIFY_GESTURE,
45
PAN_GESTURE,
46
MIDI,
47
SHORTCUT,
48
ACTION,
49
MAX,
50
};
51
52
enum class HatDir {
53
UP = 0,
54
RIGHT = 1,
55
DOWN = 2,
56
LEFT = 3,
57
MAX = 4,
58
};
59
60
enum class HatMask {
61
CENTER = 0,
62
UP = 1,
63
RIGHT = 2,
64
DOWN = 4,
65
LEFT = 8,
66
};
67
68
enum class JoyAxis {
69
INVALID = -1,
70
LEFT_X = 0,
71
LEFT_Y = 1,
72
RIGHT_X = 2,
73
RIGHT_Y = 3,
74
TRIGGER_LEFT = 4,
75
TRIGGER_RIGHT = 5,
76
SDL_MAX = 6,
77
MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
78
};
79
80
enum class JoyButton {
81
INVALID = -1,
82
A = 0,
83
B = 1,
84
X = 2,
85
Y = 3,
86
BACK = 4,
87
GUIDE = 5,
88
START = 6,
89
LEFT_STICK = 7,
90
RIGHT_STICK = 8,
91
LEFT_SHOULDER = 9,
92
RIGHT_SHOULDER = 10,
93
DPAD_UP = 11,
94
DPAD_DOWN = 12,
95
DPAD_LEFT = 13,
96
DPAD_RIGHT = 14,
97
MISC1 = 15,
98
PADDLE1 = 16,
99
PADDLE2 = 17,
100
PADDLE3 = 18,
101
PADDLE4 = 19,
102
TOUCHPAD = 20,
103
SDL_MAX = 21,
104
MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.
105
};
106
107
enum class MIDIMessage {
108
NONE = 0,
109
NOTE_OFF = 0x8,
110
NOTE_ON = 0x9,
111
AFTERTOUCH = 0xA,
112
CONTROL_CHANGE = 0xB,
113
PROGRAM_CHANGE = 0xC,
114
CHANNEL_PRESSURE = 0xD,
115
PITCH_BEND = 0xE,
116
SYSTEM_EXCLUSIVE = 0xF0,
117
QUARTER_FRAME = 0xF1,
118
SONG_POSITION_POINTER = 0xF2,
119
SONG_SELECT = 0xF3,
120
TUNE_REQUEST = 0xF6,
121
TIMING_CLOCK = 0xF8,
122
START = 0xFA,
123
CONTINUE = 0xFB,
124
STOP = 0xFC,
125
ACTIVE_SENSING = 0xFE,
126
SYSTEM_RESET = 0xFF,
127
};
128
129
enum class MouseButton {
130
NONE = 0,
131
LEFT = 1,
132
RIGHT = 2,
133
MIDDLE = 3,
134
WHEEL_UP = 4,
135
WHEEL_DOWN = 5,
136
WHEEL_LEFT = 6,
137
WHEEL_RIGHT = 7,
138
MB_XBUTTON1 = 8, // "XBUTTON1" is a reserved word on Windows.
139
MB_XBUTTON2 = 9, // "XBUTTON2" is a reserved word on Windows.
140
};
141
142
enum class MouseButtonMask {
143
NONE = 0,
144
LEFT = (1 << (int(MouseButton::LEFT) - 1)),
145
RIGHT = (1 << (int(MouseButton::RIGHT) - 1)),
146
MIDDLE = (1 << (int(MouseButton::MIDDLE) - 1)),
147
MB_XBUTTON1 = (1 << (int(MouseButton::MB_XBUTTON1) - 1)),
148
MB_XBUTTON2 = (1 << (int(MouseButton::MB_XBUTTON2) - 1)),
149
};
150
151
inline MouseButtonMask mouse_button_to_mask(MouseButton button) {
152
ERR_FAIL_COND_V(button == MouseButton::NONE, MouseButtonMask::NONE);
153
154
return MouseButtonMask(1 << ((int)button - 1));
155
}
156
157
constexpr MouseButtonMask operator|(MouseButtonMask p_a, MouseButtonMask p_b) {
158
return static_cast<MouseButtonMask>(static_cast<int>(p_a) | static_cast<int>(p_b));
159
}
160
161
constexpr MouseButtonMask &operator|=(MouseButtonMask &p_a, MouseButtonMask p_b) {
162
return p_a = p_a | p_b;
163
}
164
165