summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-11-12 23:39:17 +0100
committerGitHub <noreply@github.com>2021-11-12 23:39:17 +0100
commit5aae92f069b47c040d93e5edba2aad5b104fd1a5 (patch)
treee6d222c6488c1e4f1a9e4ffa68c1404473a00843 /core/input
parent4f85cad013c5469a39287e9aa474735f950e302c (diff)
parent3c0fdcc8acfadb124fbfa914532868948561c351 (diff)
Merge pull request #51684 from aaronfranke/enum-class
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input.cpp180
-rw-r--r--core/input/input.h22
-rw-r--r--core/input/input_enums.h184
-rw-r--r--core/input/input_event.cpp156
-rw-r--r--core/input/input_event.h24
-rw-r--r--core/input/input_map.cpp172
6 files changed, 391 insertions, 347 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 35ca8aefe6..4b5a84f401 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -35,7 +35,7 @@
#include "core/input/input_map.h"
#include "core/os/os.h"
-static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
+static const char *_joy_buttons[(size_t)JoyButton::SDL_MAX] = {
"a",
"b",
"x",
@@ -59,7 +59,7 @@ static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
"touchpad",
};
-static const char *_joy_axes[JOY_AXIS_SDL_MAX] = {
+static const char *_joy_axes[(size_t)JoyAxis::SDL_MAX] = {
"leftx",
"lefty",
"rightx",
@@ -225,11 +225,15 @@ bool Input::is_key_pressed(Key p_keycode) const {
bool Input::is_mouse_button_pressed(MouseButton p_button) const {
_THREAD_SAFE_METHOD_
- return (mouse_button_mask & (1 << (p_button - 1))) != 0;
+ return (mouse_button_mask & mouse_button_to_mask(p_button)) != MouseButton::NONE;
}
-static int _combine_device(int p_value, int p_device) {
- return p_value | (p_device << 20);
+static JoyAxis _combine_device(JoyAxis p_value, int p_device) {
+ return JoyAxis((int)p_value | (p_device << 20));
+}
+
+static JoyButton _combine_device(JoyButton p_value, int p_device) {
+ return JoyButton((int)p_value | (p_device << 20));
}
bool Input::is_joy_button_pressed(int p_device, JoyButton p_button) const {
@@ -338,7 +342,7 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po
float Input::get_joy_axis(int p_device, JoyAxis p_axis) const {
_THREAD_SAFE_METHOD_
- int c = _combine_device(p_axis, p_device);
+ JoyAxis c = _combine_device(p_axis, p_device);
if (_joy_axis.has(c)) {
return _joy_axis[c];
} else {
@@ -412,11 +416,11 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S
js.mapping = mapping;
} else {
js.connected = false;
- for (int i = 0; i < JOY_BUTTON_MAX; i++) {
- int c = _combine_device(i, p_idx);
+ for (int i = 0; i < (int)JoyButton::MAX; i++) {
+ JoyButton c = _combine_device((JoyButton)i, p_idx);
joy_buttons_pressed.erase(c);
}
- for (int i = 0; i < JOY_AXIS_MAX; i++) {
+ for (int i = 0; i < (int)JoyAxis::MAX; i++) {
set_joy_axis(p_idx, (JoyAxis)i, 0.0f);
}
}
@@ -454,7 +458,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
// require additional handling by this class.
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && !k->is_echo() && k->get_keycode() != 0) {
+ if (k.is_valid() && !k->is_echo() && k->get_keycode() != Key::NONE) {
if (k->is_pressed()) {
keys_pressed.insert(k->get_keycode());
} else {
@@ -466,9 +470,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
if (mb.is_valid()) {
if (mb->is_pressed()) {
- mouse_button_mask |= (MouseButton)(1 << (mb->get_button_index() - 1));
+ mouse_button_mask |= mouse_button_to_mask(mb->get_button_index());
} else {
- mouse_button_mask &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
+ mouse_button_mask &= ~mouse_button_to_mask(mb->get_button_index());
}
Point2 pos = mb->get_global_position();
@@ -476,7 +480,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
set_mouse_position(pos);
}
- if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == 1) {
+ if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == MouseButton::LEFT) {
Ref<InputEventScreenTouch> touch_event;
touch_event.instantiate();
touch_event->set_pressed(mb->is_pressed());
@@ -493,7 +497,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
set_mouse_position(pos);
}
- if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) {
+ if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && (mm->get_button_mask() & MouseButton::LEFT) != MouseButton::NONE) {
Ref<InputEventScreenDrag> drag_event;
drag_event.instantiate();
@@ -539,11 +543,11 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
button_event->set_position(st->get_position());
button_event->set_global_position(st->get_position());
button_event->set_pressed(st->is_pressed());
- button_event->set_button_index(MOUSE_BUTTON_LEFT);
+ button_event->set_button_index(MouseButton::LEFT);
if (st->is_pressed()) {
- button_event->set_button_mask(MouseButton(mouse_button_mask | MOUSE_BUTTON_MASK_LEFT));
+ button_event->set_button_mask(MouseButton(mouse_button_mask | MouseButton::MASK_LEFT));
} else {
- button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
+ button_event->set_button_mask(MouseButton(mouse_button_mask & ~MouseButton::MASK_LEFT));
}
_parse_input_event_impl(button_event, true);
@@ -576,7 +580,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventJoypadButton> jb = p_event;
if (jb.is_valid()) {
- int c = _combine_device(jb->get_button_index(), jb->get_device());
+ JoyButton c = _combine_device(jb->get_button_index(), jb->get_device());
if (jb->is_pressed()) {
joy_buttons_pressed.insert(c);
@@ -624,7 +628,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
void Input::set_joy_axis(int p_device, JoyAxis p_axis, float p_value) {
_THREAD_SAFE_METHOD_
- int c = _combine_device(p_axis, p_device);
+ JoyAxis c = _combine_device(p_axis, p_device);
_joy_axis[c] = p_value;
}
@@ -692,7 +696,7 @@ Point2 Input::get_last_mouse_speed() const {
return mouse_speed_track.speed;
}
-int Input::get_mouse_button_mask() const {
+MouseButton Input::get_mouse_button_mask() const {
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
}
@@ -771,8 +775,8 @@ void Input::ensure_touch_mouse_raised() {
button_event->set_position(mouse_pos);
button_event->set_global_position(mouse_pos);
button_event->set_pressed(false);
- button_event->set_button_index(MOUSE_BUTTON_LEFT);
- button_event->set_button_mask(MouseButton(mouse_button_mask & ~MOUSE_BUTTON_MASK_LEFT));
+ button_event->set_button_index(MouseButton::LEFT);
+ button_event->set_button_mask(MouseButton(mouse_button_mask & ~MouseButton::MASK_LEFT));
_parse_input_event_impl(button_event, true);
}
@@ -876,10 +880,10 @@ void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
_THREAD_SAFE_METHOD_;
Joypad &joy = joy_names[p_device];
//printf("got button %i, mapping is %i\n", p_button, joy.mapping);
- if (joy.last_buttons[p_button] == p_pressed) {
+ if (joy.last_buttons[(size_t)p_button] == p_pressed) {
return;
}
- joy.last_buttons[p_button] = p_pressed;
+ joy.last_buttons[(size_t)p_button] = p_pressed;
if (joy.mapping == -1) {
_button_event(p_device, p_button, p_pressed);
return;
@@ -901,16 +905,16 @@ void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value) {
_THREAD_SAFE_METHOD_;
- ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
+ ERR_FAIL_INDEX((int)p_axis, (int)JoyAxis::MAX);
Joypad &joy = joy_names[p_device];
- if (joy.last_axis[p_axis] == p_value.value) {
+ if (joy.last_axis[(size_t)p_axis] == p_value.value) {
return;
}
//when changing direction quickly, insert fake event to release pending inputmap actions
- float last = joy.last_axis[p_axis];
+ float last = joy.last_axis[(size_t)p_axis];
if (p_value.min == 0 && (last < 0.25 || last > 0.75) && (last - 0.5) * (p_value.value - 0.5) < 0) {
JoyAxisValue jx;
jx.min = p_value.min;
@@ -923,7 +927,7 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value)
joy_axis(p_device, p_axis, jx);
}
- joy.last_axis[p_axis] = p_value.value;
+ joy.last_axis[(size_t)p_axis] = p_value.value;
float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value;
if (joy.mapping == -1) {
@@ -935,32 +939,32 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value)
if (map.type == TYPE_BUTTON) {
bool pressed = map.value > 0.5;
- if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) {
+ if (pressed == joy_buttons_pressed.has(_combine_device((JoyButton)map.index, p_device))) {
// Button already pressed or released; so ignore.
return;
}
_button_event(p_device, (JoyButton)map.index, pressed);
// Ensure opposite D-Pad button is also released.
- switch (map.index) {
- case JOY_BUTTON_DPAD_UP:
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_DOWN, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_DOWN, false);
+ switch ((JoyButton)map.index) {
+ case JoyButton::DPAD_UP:
+ if (joy_buttons_pressed.has(_combine_device(JoyButton::DPAD_DOWN, p_device))) {
+ _button_event(p_device, JoyButton::DPAD_DOWN, false);
}
break;
- case JOY_BUTTON_DPAD_DOWN:
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_UP, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_UP, false);
+ case JoyButton::DPAD_DOWN:
+ if (joy_buttons_pressed.has(_combine_device(JoyButton::DPAD_UP, p_device))) {
+ _button_event(p_device, JoyButton::DPAD_UP, false);
}
break;
- case JOY_BUTTON_DPAD_LEFT:
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_RIGHT, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_RIGHT, false);
+ case JoyButton::DPAD_LEFT:
+ if (joy_buttons_pressed.has(_combine_device(JoyButton::DPAD_RIGHT, p_device))) {
+ _button_event(p_device, JoyButton::DPAD_RIGHT, false);
}
break;
- case JOY_BUTTON_DPAD_RIGHT:
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_LEFT, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_LEFT, false);
+ case JoyButton::DPAD_RIGHT:
+ if (joy_buttons_pressed.has(_combine_device(JoyButton::DPAD_LEFT, p_device))) {
+ _button_event(p_device, JoyButton::DPAD_LEFT, false);
}
break;
default:
@@ -977,27 +981,27 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value)
//printf("invalid mapping\n");
}
-void Input::joy_hat(int p_device, int p_val) {
+void Input::joy_hat(int p_device, HatMask p_val) {
_THREAD_SAFE_METHOD_;
const Joypad &joy = joy_names[p_device];
- JoyEvent map[HAT_MAX];
+ JoyEvent map[(size_t)HatDir::MAX];
- map[HatDir::HAT_UP].type = TYPE_BUTTON;
- map[HatDir::HAT_UP].index = JOY_BUTTON_DPAD_UP;
- map[HatDir::HAT_UP].value = 0;
+ map[(size_t)HatDir::UP].type = TYPE_BUTTON;
+ map[(size_t)HatDir::UP].index = (int)JoyButton::DPAD_UP;
+ map[(size_t)HatDir::UP].value = 0;
- map[HatDir::HAT_RIGHT].type = TYPE_BUTTON;
- map[HatDir::HAT_RIGHT].index = JOY_BUTTON_DPAD_RIGHT;
- map[HatDir::HAT_RIGHT].value = 0;
+ map[(size_t)HatDir::RIGHT].type = TYPE_BUTTON;
+ map[(size_t)HatDir::RIGHT].index = (int)JoyButton::DPAD_RIGHT;
+ map[(size_t)HatDir::RIGHT].value = 0;
- map[HatDir::HAT_DOWN].type = TYPE_BUTTON;
- map[HatDir::HAT_DOWN].index = JOY_BUTTON_DPAD_DOWN;
- map[HatDir::HAT_DOWN].value = 0;
+ map[(size_t)HatDir::DOWN].type = TYPE_BUTTON;
+ map[(size_t)HatDir::DOWN].index = (int)JoyButton::DPAD_DOWN;
+ map[(size_t)HatDir::DOWN].value = 0;
- map[HatDir::HAT_LEFT].type = TYPE_BUTTON;
- map[HatDir::HAT_LEFT].index = JOY_BUTTON_DPAD_LEFT;
- map[HatDir::HAT_LEFT].value = 0;
+ map[(size_t)HatDir::LEFT].type = TYPE_BUTTON;
+ map[(size_t)HatDir::LEFT].index = (int)JoyButton::DPAD_LEFT;
+ map[(size_t)HatDir::LEFT].value = 0;
if (joy.mapping != -1) {
_get_mapped_hat_events(map_db[joy.mapping], (HatDir)0, map);
@@ -1005,18 +1009,18 @@ void Input::joy_hat(int p_device, int p_val) {
int cur_val = joy_names[p_device].hat_current;
- for (int hat_direction = 0, hat_mask = 1; hat_direction < HAT_MAX; hat_direction++, hat_mask <<= 1) {
- if ((p_val & hat_mask) != (cur_val & hat_mask)) {
+ for (int hat_direction = 0, hat_mask = 1; hat_direction < (int)HatDir::MAX; hat_direction++, hat_mask <<= 1) {
+ if (((int)p_val & hat_mask) != (cur_val & hat_mask)) {
if (map[hat_direction].type == TYPE_BUTTON) {
- _button_event(p_device, (JoyButton)map[hat_direction].index, p_val & hat_mask);
+ _button_event(p_device, (JoyButton)map[hat_direction].index, (int)p_val & hat_mask);
}
if (map[hat_direction].type == TYPE_AXIS) {
- _axis_event(p_device, (JoyAxis)map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
+ _axis_event(p_device, (JoyAxis)map[hat_direction].index, ((int)p_val & hat_mask) ? map[hat_direction].value : 0.0);
}
}
}
- joy_names[p_device].hat_current = p_val;
+ joy_names[p_device].hat_current = (int)p_val;
}
void Input::_button_event(int p_device, JoyButton p_index, bool p_pressed) {
@@ -1049,10 +1053,10 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
event.type = binding.outputType;
switch (binding.outputType) {
case TYPE_BUTTON:
- event.index = binding.output.button;
+ event.index = (int)binding.output.button;
return event;
case TYPE_AXIS:
- event.index = binding.output.axis.axis;
+ event.index = (int)binding.output.axis.axis;
switch (binding.output.axis.range) {
case POSITIVE_HALF_AXIS:
event.value = 1;
@@ -1104,7 +1108,7 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J
}
switch (binding.outputType) {
case TYPE_BUTTON:
- event.index = binding.output.button;
+ event.index = (int)binding.output.button;
switch (binding.input.axis.range) {
case POSITIVE_HALF_AXIS:
event.value = shifted_positive_value;
@@ -1121,7 +1125,7 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J
}
return event;
case TYPE_AXIS:
- event.index = binding.output.axis.axis;
+ event.index = (int)binding.output.axis.axis;
event.value = value;
if (binding.output.axis.range != binding.input.axis.range) {
switch (binding.output.axis.range) {
@@ -1150,43 +1154,43 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
- int hat_direction;
+ HatDir hat_direction;
switch (binding.input.hat.hat_mask) {
- case HatMask::HAT_MASK_UP:
- hat_direction = HatDir::HAT_UP;
+ case HatMask::UP:
+ hat_direction = HatDir::UP;
break;
- case HatMask::HAT_MASK_RIGHT:
- hat_direction = HatDir::HAT_RIGHT;
+ case HatMask::RIGHT:
+ hat_direction = HatDir::RIGHT;
break;
- case HatMask::HAT_MASK_DOWN:
- hat_direction = HatDir::HAT_DOWN;
+ case HatMask::DOWN:
+ hat_direction = HatDir::DOWN;
break;
- case HatMask::HAT_MASK_LEFT:
- hat_direction = HatDir::HAT_LEFT;
+ case HatMask::LEFT:
+ hat_direction = HatDir::LEFT;
break;
default:
ERR_PRINT_ONCE("Joypad button mapping error.");
continue;
}
- r_events[hat_direction].type = binding.outputType;
+ r_events[(size_t)hat_direction].type = binding.outputType;
switch (binding.outputType) {
case TYPE_BUTTON:
- r_events[hat_direction].index = binding.output.button;
+ r_events[(size_t)hat_direction].index = (int)binding.output.button;
break;
case TYPE_AXIS:
- r_events[hat_direction].index = binding.output.axis.axis;
+ r_events[(size_t)hat_direction].index = (int)binding.output.axis.axis;
switch (binding.output.axis.range) {
case POSITIVE_HALF_AXIS:
- r_events[hat_direction].value = 1;
+ r_events[(size_t)hat_direction].value = 1;
break;
case NEGATIVE_HALF_AXIS:
- r_events[hat_direction].value = -1;
+ r_events[(size_t)hat_direction].value = -1;
break;
case FULL_AXIS:
// It doesn't make sense for a hat direction to map to a full axis,
// but keeping as a default for a trigger with a positive half-axis.
- r_events[hat_direction].value = 1;
+ r_events[(size_t)hat_direction].value = 1;
break;
}
break;
@@ -1198,21 +1202,21 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat
}
JoyButton Input::_get_output_button(String output) {
- for (int i = 0; i < JOY_BUTTON_SDL_MAX; i++) {
+ for (int i = 0; i < (int)JoyButton::SDL_MAX; i++) {
if (output == _joy_buttons[i]) {
return JoyButton(i);
}
}
- return JoyButton::JOY_BUTTON_INVALID;
+ return JoyButton::INVALID;
}
JoyAxis Input::_get_output_axis(String output) {
- for (int i = 0; i < JOY_AXIS_SDL_MAX; i++) {
+ for (int i = 0; i < (int)JoyAxis::SDL_MAX; i++) {
if (output == _joy_axes[i]) {
return JoyAxis(i);
}
}
- return JoyAxis::JOY_AXIS_INVALID;
+ return JoyAxis::INVALID;
}
void Input::parse_mapping(String p_mapping) {
@@ -1273,16 +1277,16 @@ void Input::parse_mapping(String p_mapping) {
JoyButton output_button = _get_output_button(output);
JoyAxis output_axis = _get_output_axis(output);
- ERR_CONTINUE_MSG(output_button == JOY_BUTTON_INVALID && output_axis == JOY_AXIS_INVALID,
+ ERR_CONTINUE_MSG(output_button == JoyButton::INVALID && output_axis == JoyAxis::INVALID,
vformat("Unrecognised output string \"%s\" in mapping:\n%s", output, p_mapping));
- ERR_CONTINUE_MSG(output_button != JOY_BUTTON_INVALID && output_axis != JOY_AXIS_INVALID,
+ ERR_CONTINUE_MSG(output_button != JoyButton::INVALID && output_axis != JoyAxis::INVALID,
vformat("Output string \"%s\" matched both button and axis in mapping:\n%s", output, p_mapping));
JoyBinding binding;
- if (output_button != JOY_BUTTON_INVALID) {
+ if (output_button != JoyButton::INVALID) {
binding.outputType = TYPE_BUTTON;
binding.output.button = output_button;
- } else if (output_axis != JOY_AXIS_INVALID) {
+ } else if (output_axis != JoyAxis::INVALID) {
binding.outputType = TYPE_AXIS;
binding.output.axis.axis = output_axis;
binding.output.axis.range = output_range;
diff --git a/core/input/input.h b/core/input/input.h
index f63138a875..dd57ebb563 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -85,11 +85,11 @@ public:
typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
private:
- int mouse_button_mask = 0;
+ MouseButton mouse_button_mask = MouseButton::NONE;
- Set<int> keys_pressed;
- Set<int> joy_buttons_pressed;
- Map<int, float> _joy_axis;
+ Set<Key> keys_pressed;
+ Set<JoyButton> joy_buttons_pressed;
+ Map<JoyAxis, float> _joy_axis;
//Map<StringName,int> custom_action_press;
Vector3 gravity;
Vector3 accelerometer;
@@ -133,9 +133,9 @@ private:
StringName name;
StringName uid;
bool connected = false;
- bool last_buttons[JOY_BUTTON_MAX] = { false };
- float last_axis[JOY_AXIS_MAX] = { 0.0f };
- int last_hat = HatMask::HAT_MASK_CENTER;
+ bool last_buttons[(size_t)JoyButton::MAX] = { false };
+ float last_axis[(size_t)JoyAxis::MAX] = { 0.0f };
+ HatMask last_hat = HatMask::CENTER;
int mapping = -1;
int hat_current = 0;
};
@@ -162,7 +162,7 @@ private:
struct JoyEvent {
int type;
- int index;
+ int index; // Can be either JoyAxis or JoyButton.
float value;
};
@@ -206,7 +206,7 @@ private:
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button);
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value);
- void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[HAT_MAX]);
+ void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[(size_t)HatDir::MAX]);
JoyButton _get_output_button(String output);
JoyAxis _get_output_axis(String output);
void _button_event(int p_device, JoyButton p_index, bool p_pressed);
@@ -273,7 +273,7 @@ public:
Point2 get_mouse_position() const;
Point2 get_last_mouse_speed() const;
- int get_mouse_button_mask() const;
+ MouseButton get_mouse_button_mask() const;
void warp_mouse_position(const Vector2 &p_to);
Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
@@ -312,7 +312,7 @@ public:
void parse_mapping(String p_mapping);
void joy_button(int p_device, JoyButton p_button, bool p_pressed);
void joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value);
- void joy_hat(int p_device, int p_val);
+ void joy_hat(int p_device, HatMask p_val);
void add_joy_mapping(String p_mapping, bool p_update_existing = false);
void remove_joy_mapping(String p_guid);
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
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index af3190bb17..ccde8838e1 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -203,19 +203,19 @@ void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModif
set_meta_pressed(event->is_meta_pressed());
}
-uint32_t InputEventWithModifiers::get_modifiers_mask() const {
- uint32_t mask = 0;
+Key InputEventWithModifiers::get_modifiers_mask() const {
+ Key mask = Key::NONE;
if (is_ctrl_pressed()) {
- mask |= KEY_MASK_CTRL;
+ mask |= KeyModifierMask::CTRL;
}
if (is_shift_pressed()) {
- mask |= KEY_MASK_SHIFT;
+ mask |= KeyModifierMask::SHIFT;
}
if (is_alt_pressed()) {
- mask |= KEY_MASK_ALT;
+ mask |= KeyModifierMask::ALT;
}
if (is_meta_pressed()) {
- mask |= KEY_MASK_META;
+ mask |= KeyModifierMask::META;
}
return mask;
}
@@ -224,16 +224,16 @@ String InputEventWithModifiers::as_text() const {
Vector<String> mod_names;
if (is_ctrl_pressed()) {
- mod_names.push_back(find_keycode_name(KEY_CTRL));
+ mod_names.push_back(find_keycode_name(Key::CTRL));
}
if (is_shift_pressed()) {
- mod_names.push_back(find_keycode_name(KEY_SHIFT));
+ mod_names.push_back(find_keycode_name(Key::SHIFT));
}
if (is_alt_pressed()) {
- mod_names.push_back(find_keycode_name(KEY_ALT));
+ mod_names.push_back(find_keycode_name(Key::ALT));
}
if (is_meta_pressed()) {
- mod_names.push_back(find_keycode_name(KEY_META));
+ mod_names.push_back(find_keycode_name(Key::META));
}
if (!mod_names.is_empty()) {
@@ -325,12 +325,12 @@ Key InputEventKey::get_physical_keycode() const {
return physical_keycode;
}
-void InputEventKey::set_unicode(uint32_t p_unicode) {
+void InputEventKey::set_unicode(char32_t p_unicode) {
unicode = p_unicode;
emit_changed();
}
-uint32_t InputEventKey::get_unicode() const {
+char32_t InputEventKey::get_unicode() const {
return unicode;
}
@@ -343,18 +343,18 @@ bool InputEventKey::is_echo() const {
return echo;
}
-uint32_t InputEventKey::get_keycode_with_modifiers() const {
+Key InputEventKey::get_keycode_with_modifiers() const {
return keycode | get_modifiers_mask();
}
-uint32_t InputEventKey::get_physical_keycode_with_modifiers() const {
+Key InputEventKey::get_physical_keycode_with_modifiers() const {
return physical_keycode | get_modifiers_mask();
}
String InputEventKey::as_text() const {
String kc;
- if (keycode == 0) {
+ if (keycode == Key::NONE) {
kc = keycode_get_string(physical_keycode) + " (" + RTR("Physical") + ")";
} else {
kc = keycode_get_string(keycode);
@@ -374,11 +374,11 @@ String InputEventKey::to_string() {
String kc = "";
String physical = "false";
- if (keycode == 0) {
- kc = itos(physical_keycode) + " (" + keycode_get_string(physical_keycode) + ")";
+ if (keycode == Key::NONE) {
+ kc = itos((int64_t)physical_keycode) + " (" + keycode_get_string(physical_keycode) + ")";
physical = "true";
} else {
- kc = itos(keycode) + " (" + keycode_get_string(keycode) + ")";
+ kc = itos((int64_t)keycode) + " (" + keycode_get_string(keycode) + ")";
}
String mods = InputEventWithModifiers::as_text();
@@ -390,22 +390,22 @@ String InputEventKey::to_string() {
Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode) {
Ref<InputEventKey> ie;
ie.instantiate();
- ie->set_keycode(p_keycode & KEY_CODE_MASK);
- ie->set_unicode(p_keycode & KEY_CODE_MASK);
+ ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK);
+ ie->set_unicode(char32_t(p_keycode & KeyModifierMask::CODE_MASK));
- if (p_keycode & KEY_MASK_SHIFT) {
+ if ((p_keycode & KeyModifierMask::SHIFT) != Key::NONE) {
ie->set_shift_pressed(true);
}
- if (p_keycode & KEY_MASK_ALT) {
+ if ((p_keycode & KeyModifierMask::ALT) != Key::NONE) {
ie->set_alt_pressed(true);
}
- if (p_keycode & KEY_MASK_CTRL) {
+ if ((p_keycode & KeyModifierMask::CTRL) != Key::NONE) {
ie->set_ctrl_pressed(true);
}
- if (p_keycode & KEY_MASK_CMD) {
+ if ((p_keycode & KeyModifierMask::CMD) != Key::NONE) {
ie->set_command_pressed(true);
}
- if (p_keycode & KEY_MASK_META) {
+ if ((p_keycode & KeyModifierMask::META) != Key::NONE) {
ie->set_meta_pressed(true);
}
@@ -419,14 +419,14 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed
}
bool match = false;
- if (get_keycode() == 0) {
- uint32_t code = get_physical_keycode_with_modifiers();
- uint32_t event_code = key->get_physical_keycode_with_modifiers();
+ if (get_keycode() == Key::NONE) {
+ Key code = get_physical_keycode_with_modifiers();
+ Key event_code = key->get_physical_keycode_with_modifiers();
match = get_physical_keycode() == key->get_physical_keycode() && (!key->is_pressed() || (code & event_code) == code);
} else {
- uint32_t code = get_keycode_with_modifiers();
- uint32_t event_code = key->get_keycode_with_modifiers();
+ Key code = get_keycode_with_modifiers();
+ Key event_code = key->get_keycode_with_modifiers();
match = get_keycode() == key->get_keycode() && (!key->is_pressed() || (code & event_code) == code);
}
@@ -452,7 +452,7 @@ bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match)
return false;
}
- if (keycode == 0) {
+ if (keycode == Key::NONE) {
return physical_keycode == key->physical_keycode &&
(!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask());
} else {
@@ -487,12 +487,12 @@ void InputEventKey::_bind_methods() {
///////////////////////////////////
-void InputEventMouse::set_button_mask(int p_mask) {
+void InputEventMouse::set_button_mask(MouseButton p_mask) {
button_mask = p_mask;
emit_changed();
}
-int InputEventMouse::get_button_mask() const {
+MouseButton InputEventMouse::get_button_mask() const {
return button_mask;
}
@@ -637,21 +637,21 @@ String InputEventMouseButton::as_text() const {
String full_string = mods_text == "" ? "" : mods_text + "+";
// Button
- int idx = get_button_index();
+ MouseButton idx = get_button_index();
switch (idx) {
- case MOUSE_BUTTON_LEFT:
- case MOUSE_BUTTON_RIGHT:
- case MOUSE_BUTTON_MIDDLE:
- case MOUSE_BUTTON_WHEEL_UP:
- case MOUSE_BUTTON_WHEEL_DOWN:
- case MOUSE_BUTTON_WHEEL_LEFT:
- case MOUSE_BUTTON_WHEEL_RIGHT:
- case MOUSE_BUTTON_XBUTTON1:
- case MOUSE_BUTTON_XBUTTON2:
- full_string += RTR(_mouse_button_descriptions[idx - 1]); // button index starts from 1, array index starts from 0, so subtract 1
+ case MouseButton::LEFT:
+ case MouseButton::RIGHT:
+ case MouseButton::MIDDLE:
+ case MouseButton::WHEEL_UP:
+ case MouseButton::WHEEL_DOWN:
+ case MouseButton::WHEEL_LEFT:
+ case MouseButton::WHEEL_RIGHT:
+ case MouseButton::MB_XBUTTON1:
+ case MouseButton::MB_XBUTTON2:
+ full_string += RTR(_mouse_button_descriptions[(size_t)idx - 1]); // button index starts from 1, array index starts from 0, so subtract 1
break;
default:
- full_string += RTR("Button") + " #" + itos(idx);
+ full_string += RTR("Button") + " #" + itos((int64_t)idx);
break;
}
@@ -667,20 +667,20 @@ String InputEventMouseButton::to_string() {
String p = is_pressed() ? "true" : "false";
String d = double_click ? "true" : "false";
- int idx = get_button_index();
- String button_string = itos(idx);
+ MouseButton idx = get_button_index();
+ String button_string = itos((int64_t)idx);
switch (idx) {
- case MOUSE_BUTTON_LEFT:
- case MOUSE_BUTTON_RIGHT:
- case MOUSE_BUTTON_MIDDLE:
- case MOUSE_BUTTON_WHEEL_UP:
- case MOUSE_BUTTON_WHEEL_DOWN:
- case MOUSE_BUTTON_WHEEL_LEFT:
- case MOUSE_BUTTON_WHEEL_RIGHT:
- case MOUSE_BUTTON_XBUTTON1:
- case MOUSE_BUTTON_XBUTTON2:
- button_string += " (" + RTR(_mouse_button_descriptions[idx - 1]) + ")"; // button index starts from 1, array index starts from 0, so subtract 1
+ case MouseButton::LEFT:
+ case MouseButton::RIGHT:
+ case MouseButton::MIDDLE:
+ case MouseButton::WHEEL_UP:
+ case MouseButton::WHEEL_DOWN:
+ case MouseButton::WHEEL_LEFT:
+ case MouseButton::WHEEL_RIGHT:
+ case MouseButton::MB_XBUTTON1:
+ case MouseButton::MB_XBUTTON2:
+ button_string += " (" + RTR(_mouse_button_descriptions[(size_t)idx - 1]) + ")"; // button index starts from 1, array index starts from 0, so subtract 1
break;
default:
break;
@@ -778,23 +778,23 @@ String InputEventMouseMotion::as_text() const {
}
String InputEventMouseMotion::to_string() {
- int button_mask = get_button_mask();
- String button_mask_string = itos(button_mask);
- switch (get_button_mask()) {
- case MOUSE_BUTTON_MASK_LEFT:
- button_mask_string += " (" + RTR(_mouse_button_descriptions[MOUSE_BUTTON_LEFT - 1]) + ")";
+ MouseButton button_mask = get_button_mask();
+ String button_mask_string = itos((int64_t)button_mask);
+ switch (button_mask) {
+ case MouseButton::MASK_LEFT:
+ button_mask_string += " (" + RTR(_mouse_button_descriptions[(size_t)MouseButton::LEFT - 1]) + ")";
break;
- case MOUSE_BUTTON_MASK_MIDDLE:
- button_mask_string += " (" + RTR(_mouse_button_descriptions[MOUSE_BUTTON_MIDDLE - 1]) + ")";
+ case MouseButton::MASK_MIDDLE:
+ button_mask_string += " (" + RTR(_mouse_button_descriptions[(size_t)MouseButton::MIDDLE - 1]) + ")";
break;
- case MOUSE_BUTTON_MASK_RIGHT:
- button_mask_string += " (" + RTR(_mouse_button_descriptions[MOUSE_BUTTON_RIGHT - 1]) + ")";
+ case MouseButton::MASK_RIGHT:
+ button_mask_string += " (" + RTR(_mouse_button_descriptions[(size_t)MouseButton::RIGHT - 1]) + ")";
break;
- case MOUSE_BUTTON_MASK_XBUTTON1:
- button_mask_string += " (" + RTR(_mouse_button_descriptions[MOUSE_BUTTON_XBUTTON1 - 1]) + ")";
+ case MouseButton::MASK_XBUTTON1:
+ button_mask_string += " (" + RTR(_mouse_button_descriptions[(size_t)MouseButton::MB_XBUTTON1 - 1]) + ")";
break;
- case MOUSE_BUTTON_MASK_XBUTTON2:
- button_mask_string += " (" + RTR(_mouse_button_descriptions[MOUSE_BUTTON_XBUTTON2 - 1]) + ")";
+ case MouseButton::MASK_XBUTTON2:
+ button_mask_string += " (" + RTR(_mouse_button_descriptions[(size_t)MouseButton::MB_XBUTTON2 - 1]) + ")";
break;
default:
break;
@@ -869,7 +869,7 @@ void InputEventMouseMotion::_bind_methods() {
///////////////////////////////////
void InputEventJoypadMotion::set_axis(JoyAxis p_axis) {
- ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
+ ERR_FAIL_COND(p_axis < JoyAxis::LEFT_X || p_axis > JoyAxis::MAX);
axis = p_axis;
emit_changed();
@@ -938,7 +938,7 @@ bool InputEventJoypadMotion::is_match(const Ref<InputEvent> &p_event, bool p_exa
(!p_exact_match || ((axis_value < 0) == (jm->axis_value < 0)));
}
-static const char *_joy_axis_descriptions[JOY_AXIS_MAX] = {
+static const char *_joy_axis_descriptions[(size_t)JoyAxis::MAX] = {
TTRC("Left Stick X-Axis, Joystick 0 X-Axis"),
TTRC("Left Stick Y-Axis, Joystick 0 Y-Axis"),
TTRC("Right Stick X-Axis, Joystick 1 X-Axis"),
@@ -952,7 +952,7 @@ static const char *_joy_axis_descriptions[JOY_AXIS_MAX] = {
};
String InputEventJoypadMotion::as_text() const {
- String desc = axis < JOY_AXIS_MAX ? RTR(_joy_axis_descriptions[axis]) : TTR("Unknown Joypad Axis");
+ String desc = axis < JoyAxis::MAX ? RTR(_joy_axis_descriptions[(size_t)axis]) : TTR("Unknown Joypad Axis");
return vformat(TTR("Joypad Motion on Axis %d (%s) with Value %.2f"), axis, desc, axis_value);
}
@@ -1032,7 +1032,7 @@ bool InputEventJoypadButton::is_match(const Ref<InputEvent> &p_event, bool p_exa
return button_index == button->button_index;
}
-static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = {
+static const char *_joy_button_descriptions[(size_t)JoyButton::SDL_MAX] = {
TTRC("Bottom Action, Sony Cross, Xbox A, Nintendo B"),
TTRC("Right Action, Sony Circle, Xbox B, Nintendo A"),
TTRC("Left Action, Sony Square, Xbox X, Nintendo Y"),
@@ -1057,10 +1057,10 @@ static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = {
};
String InputEventJoypadButton::as_text() const {
- String text = "Joypad Button " + itos(button_index);
+ String text = "Joypad Button " + itos((int64_t)button_index);
- if (button_index >= 0 && button_index < JOY_BUTTON_SDL_MAX) {
- text += vformat(" (%s)", _joy_button_descriptions[button_index]);
+ if (button_index > JoyButton::INVALID && button_index < JoyButton::SDL_MAX) {
+ text += vformat(" (%s)", _joy_button_descriptions[(size_t)button_index]);
}
if (pressure != 0) {
@@ -1506,7 +1506,7 @@ int InputEventMIDI::get_controller_value() const {
}
String InputEventMIDI::as_text() const {
- return vformat(RTR("MIDI Input on Channel=%s Message=%s"), itos(channel), itos(message));
+ return vformat(RTR("MIDI Input on Channel=%s Message=%s"), itos(channel), itos((int64_t)message));
}
String InputEventMIDI::to_string() {
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 3fc8078a09..70046e4491 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -151,7 +151,7 @@ public:
void set_modifiers_from_event(const InputEventWithModifiers *event);
- uint32_t get_modifiers_mask() const;
+ Key get_modifiers_mask() const;
virtual String as_text() const override;
virtual String to_string() override;
@@ -164,8 +164,8 @@ class InputEventKey : public InputEventWithModifiers {
bool pressed = false; /// otherwise release
- Key keycode = KEY_NONE; // Key enum, without modifier masks.
- Key physical_keycode = KEY_NONE;
+ Key keycode = Key::NONE; // Key enum, without modifier masks.
+ Key physical_keycode = Key::NONE;
uint32_t unicode = 0; ///unicode
bool echo = false; /// true if this is an echo key
@@ -183,14 +183,14 @@ public:
void set_physical_keycode(Key p_keycode);
Key get_physical_keycode() const;
- void set_unicode(uint32_t p_unicode);
- uint32_t get_unicode() const;
+ void set_unicode(char32_t p_unicode);
+ char32_t get_unicode() const;
void set_echo(bool p_enable);
virtual bool is_echo() const override;
- uint32_t get_keycode_with_modifiers() const;
- uint32_t get_physical_keycode_with_modifiers() const;
+ Key get_keycode_with_modifiers() const;
+ Key get_physical_keycode_with_modifiers() const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override;
virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override;
@@ -208,7 +208,7 @@ public:
class InputEventMouse : public InputEventWithModifiers {
GDCLASS(InputEventMouse, InputEventWithModifiers);
- int button_mask = 0;
+ MouseButton button_mask = MouseButton::NONE;
Vector2 pos;
Vector2 global_pos;
@@ -217,8 +217,8 @@ protected:
static void _bind_methods();
public:
- void set_button_mask(int p_mask);
- int get_button_mask() const;
+ void set_button_mask(MouseButton p_mask);
+ MouseButton get_button_mask() const;
void set_position(const Vector2 &p_pos);
Vector2 get_position() const;
@@ -233,7 +233,7 @@ class InputEventMouseButton : public InputEventMouse {
GDCLASS(InputEventMouseButton, InputEventMouse);
float factor = 1;
- MouseButton button_index = MOUSE_BUTTON_NONE;
+ MouseButton button_index = MouseButton::NONE;
bool pressed = false; //otherwise released
bool double_click = false; //last even less than double click time
@@ -501,7 +501,7 @@ class InputEventMIDI : public InputEvent {
GDCLASS(InputEventMIDI, InputEvent);
int channel = 0;
- MIDIMessage message = MIDI_MESSAGE_NONE;
+ MIDIMessage message = MIDIMessage::NONE;
int pitch = 0;
int velocity = 0;
int instrument = 0;
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 1ec4299093..84e1313756 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -381,320 +381,320 @@ const OrderedHashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
}
List<Ref<InputEvent>> inputs;
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
- inputs.push_back(InputEventKey::create_reference(KEY_SPACE));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::SPACE));
default_builtin_cache.insert("ui_accept", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_Y));
- inputs.push_back(InputEventKey::create_reference(KEY_SPACE));
+ inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::Y));
+ inputs.push_back(InputEventKey::create_reference(Key::SPACE));
default_builtin_cache.insert("ui_select", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ESCAPE));
+ inputs.push_back(InputEventKey::create_reference(Key::ESCAPE));
default_builtin_cache.insert("ui_cancel", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ inputs.push_back(InputEventKey::create_reference(Key::TAB));
default_builtin_cache.insert("ui_focus_next", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_TAB | KEY_MASK_SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::TAB | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_focus_prev", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_LEFT));
- inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_LEFT));
+ inputs.push_back(InputEventKey::create_reference(Key::LEFT));
+ inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_LEFT));
default_builtin_cache.insert("ui_left", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_RIGHT));
- inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_RIGHT));
+ inputs.push_back(InputEventKey::create_reference(Key::RIGHT));
+ inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_RIGHT));
default_builtin_cache.insert("ui_right", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_UP));
- inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_UP));
+ inputs.push_back(InputEventKey::create_reference(Key::UP));
+ inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_UP));
default_builtin_cache.insert("ui_up", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DOWN));
- inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_DOWN));
+ inputs.push_back(InputEventKey::create_reference(Key::DOWN));
+ inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_DOWN));
default_builtin_cache.insert("ui_down", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_PAGEUP));
+ inputs.push_back(InputEventKey::create_reference(Key::PAGEUP));
default_builtin_cache.insert("ui_page_up", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_PAGEDOWN));
+ inputs.push_back(InputEventKey::create_reference(Key::PAGEDOWN));
default_builtin_cache.insert("ui_page_down", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_HOME));
+ inputs.push_back(InputEventKey::create_reference(Key::HOME));
default_builtin_cache.insert("ui_home", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_END));
+ inputs.push_back(InputEventKey::create_reference(Key::END));
default_builtin_cache.insert("ui_end", inputs);
// ///// UI basic Shortcuts /////
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_X | KEY_MASK_CMD));
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::X | KeyModifierMask::CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_cut", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_C | KEY_MASK_CMD));
- inputs.push_back(InputEventKey::create_reference(KEY_INSERT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::C | KeyModifierMask::CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::INSERT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_copy", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_V | KEY_MASK_CMD));
- inputs.push_back(InputEventKey::create_reference(KEY_INSERT | KEY_MASK_SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::V | KeyModifierMask::CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::INSERT | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_paste", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_Z | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::Z | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_undo", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_Z | KEY_MASK_CMD | KEY_MASK_SHIFT));
- inputs.push_back(InputEventKey::create_reference(KEY_Y | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::Z | KeyModifierMask::CMD | KeyModifierMask::SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::Y | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_redo", inputs);
// ///// UI Text Input Shortcuts /////
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_SPACE | KEY_MASK_CTRL));
+ inputs.push_back(InputEventKey::create_reference(Key::SPACE | KeyModifierMask::CTRL));
default_builtin_cache.insert("ui_text_completion_query", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
default_builtin_cache.insert("ui_text_completion_accept", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ inputs.push_back(InputEventKey::create_reference(Key::TAB));
default_builtin_cache.insert("ui_text_completion_replace", inputs);
// Newlines
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
default_builtin_cache.insert("ui_text_newline", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER | KEY_MASK_CMD));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER | KeyModifierMask::CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_newline_blank", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER | KEY_MASK_SHIFT | KEY_MASK_CMD));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER | KEY_MASK_SHIFT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER | KeyModifierMask::SHIFT | KeyModifierMask::CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER | KeyModifierMask::SHIFT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_newline_above", inputs);
// Indentation
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ inputs.push_back(InputEventKey::create_reference(Key::TAB));
default_builtin_cache.insert("ui_text_indent", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_TAB | KEY_MASK_SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::TAB | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_text_dedent", inputs);
// Text Backspace and Delete
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE));
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_SHIFT));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_text_backspace", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_backspace_word", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_backspace_word.macos", inputs);
inputs = List<Ref<InputEvent>>();
default_builtin_cache.insert("ui_text_backspace_all_to_left", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_backspace_all_to_left.macos", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE));
default_builtin_cache.insert("ui_text_delete", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_delete_word", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_delete_word.macos", inputs);
inputs = List<Ref<InputEvent>>();
default_builtin_cache.insert("ui_text_delete_all_to_right", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_delete_all_to_right.macos", inputs);
// Text Caret Movement Left/Right
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_LEFT));
+ inputs.push_back(InputEventKey::create_reference(Key::LEFT));
default_builtin_cache.insert("ui_text_caret_left", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_word_left", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_caret_word_left.macos", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_RIGHT));
+ inputs.push_back(InputEventKey::create_reference(Key::RIGHT));
default_builtin_cache.insert("ui_text_caret_right", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_word_right", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_caret_word_right.macos", inputs);
// Text Caret Movement Up/Down
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_UP));
+ inputs.push_back(InputEventKey::create_reference(Key::UP));
default_builtin_cache.insert("ui_text_caret_up", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DOWN));
+ inputs.push_back(InputEventKey::create_reference(Key::DOWN));
default_builtin_cache.insert("ui_text_caret_down", inputs);
// Text Caret Movement Line Start/End
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_HOME));
+ inputs.push_back(InputEventKey::create_reference(Key::HOME));
default_builtin_cache.insert("ui_text_caret_line_start", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_A | KEY_MASK_CTRL));
- inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::A | KeyModifierMask::CTRL));
+ inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_line_start.macos", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_END));
+ inputs.push_back(InputEventKey::create_reference(Key::END));
default_builtin_cache.insert("ui_text_caret_line_end", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_E | KEY_MASK_CTRL));
- inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::E | KeyModifierMask::CTRL));
+ inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_line_end.macos", inputs);
// Text Caret Movement Page Up/Down
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_PAGEUP));
+ inputs.push_back(InputEventKey::create_reference(Key::PAGEUP));
default_builtin_cache.insert("ui_text_caret_page_up", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_PAGEDOWN));
+ inputs.push_back(InputEventKey::create_reference(Key::PAGEDOWN));
default_builtin_cache.insert("ui_text_caret_page_down", inputs);
// Text Caret Movement Document Start/End
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_HOME | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::HOME | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_document_start", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_document_start.macos", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_END | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::END | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_document_end", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_caret_document_end.macos", inputs);
// Text Scrolling
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_scroll_up", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_scroll_up.macos", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_scroll_down", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD | KEY_MASK_ALT));
+ inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD | KeyModifierMask::ALT));
default_builtin_cache.insert("ui_text_scroll_down.macos", inputs);
// Text Misc
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_A | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::A | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_select_all", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_D | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_text_select_word_under_caret", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_INSERT));
+ inputs.push_back(InputEventKey::create_reference(Key::INSERT));
default_builtin_cache.insert("ui_text_toggle_insert_mode", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_MENU));
+ inputs.push_back(InputEventKey::create_reference(Key::MENU));
default_builtin_cache.insert("ui_menu", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
- inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
default_builtin_cache.insert("ui_text_submit", inputs);
// ///// UI Graph Shortcuts /////
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_D | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_graph_duplicate", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_DELETE));
+ inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE));
default_builtin_cache.insert("ui_graph_delete", inputs);
// ///// UI File Dialog Shortcuts /////
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE));
+ inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE));
default_builtin_cache.insert("ui_filedialog_up_one_level", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_F5));
+ inputs.push_back(InputEventKey::create_reference(Key::F5));
default_builtin_cache.insert("ui_filedialog_refresh", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_H));
+ inputs.push_back(InputEventKey::create_reference(Key::H));
default_builtin_cache.insert("ui_filedialog_show_hidden", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_QUOTELEFT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(Key::QUOTELEFT | KeyModifierMask::CMD));
default_builtin_cache.insert("ui_swap_input_direction", inputs);
return default_builtin_cache;