summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/display_server_android.cpp28
-rw-r--r--platform/android/display_server_android.h10
-rw-r--r--platform/javascript/display_server_javascript.cpp8
-rw-r--r--platform/linuxbsd/display_server_x11.cpp22
-rw-r--r--platform/linuxbsd/display_server_x11.h6
-rw-r--r--platform/linuxbsd/joypad_linux.cpp16
-rw-r--r--platform/osx/display_server_osx.h4
-rw-r--r--platform/osx/display_server_osx.mm15
-rw-r--r--platform/osx/joypad_osx.cpp6
-rw-r--r--platform/uwp/app.cpp6
-rw-r--r--platform/uwp/os_uwp.cpp4
-rw-r--r--platform/uwp/os_uwp.h4
-rw-r--r--platform/windows/display_server_windows.cpp26
-rw-r--r--platform/windows/display_server_windows.h4
-rw-r--r--platform/windows/joypad_windows.cpp10
15 files changed, 81 insertions, 88 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index db497133aa..66a2013c4e 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -410,8 +410,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
- buttons_state = 0;
-
#if defined(OPENGL_ENABLED)
if (rendering_driver == "opengl") {
bool gl_initialization_error = false;
@@ -484,16 +482,16 @@ DisplayServerAndroid::~DisplayServerAndroid() {
void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p_event) {
switch (p_event.type) {
case JOY_EVENT_BUTTON:
- Input::get_singleton()->joy_button(p_event.device, p_event.index, p_event.pressed);
+ Input::get_singleton()->joy_button(p_event.device, (JoyButton)p_event.index, p_event.pressed);
break;
case JOY_EVENT_AXIS:
Input::JoyAxisValue value;
value.min = -1;
value.value = p_event.value;
- Input::get_singleton()->joy_axis(p_event.device, p_event.index, value);
+ Input::get_singleton()->joy_axis(p_event.device, (JoyAxis)p_event.index, value);
break;
case JOY_EVENT_HAT:
- Input::get_singleton()->joy_hat(p_event.device, p_event.hat);
+ Input::get_singleton()->joy_hat(p_event.device, (HatMask)p_event.hat);
break;
default:
return;
@@ -697,7 +695,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
}
void DisplayServerAndroid::process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
- int event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
+ MouseButton event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
switch (event_action) {
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
case AMOTION_EVENT_ACTION_BUTTON_RELEASE: {
@@ -712,7 +710,7 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
ev->set_global_position(hover_prev_pos);
}
ev->set_pressed(event_action == AMOTION_EVENT_ACTION_BUTTON_PRESS);
- int changed_button_mask = buttons_state ^ event_buttons_mask;
+ MouseButton changed_button_mask = MouseButton(buttons_state ^ event_buttons_mask);
buttons_state = event_buttons_mask;
@@ -765,11 +763,11 @@ void DisplayServerAndroid::process_mouse_event(int input_device, int event_actio
}
}
-void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor) {
+void DisplayServerAndroid::_wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor) {
Ref<InputEventMouseButton> evd = ev->duplicate();
_set_key_modifier_state(evd);
evd->set_button_index(wheel_button);
- evd->set_button_mask(event_buttons_mask ^ (1 << (wheel_button - 1)));
+ evd->set_button_mask(MouseButton(event_buttons_mask ^ (1 << (wheel_button - 1))));
evd->set_factor(factor);
Input::get_singleton()->accumulate_input_event(evd);
Ref<InputEventMouseButton> evdd = evd->duplicate();
@@ -779,7 +777,7 @@ void DisplayServerAndroid::_wheel_button_click(int event_buttons_mask, const Ref
}
void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Point2 p_pos) {
- int event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
+ MouseButton event_button_mask = _android_button_mask_to_godot_button_mask(event_android_button_mask);
Ref<InputEventMouseButton> ev;
ev.instantiate();
_set_key_modifier_state(ev);
@@ -792,7 +790,7 @@ void DisplayServerAndroid::process_double_tap(int event_android_button_mask, Poi
Input::get_singleton()->accumulate_input_event(ev);
}
-int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
+MouseButton DisplayServerAndroid::_button_index_from_mask(MouseButton button_mask) {
switch (button_mask) {
case MOUSE_BUTTON_MASK_LEFT:
return MOUSE_BUTTON_LEFT;
@@ -805,7 +803,7 @@ int DisplayServerAndroid::_button_index_from_mask(int button_mask) {
case MOUSE_BUTTON_MASK_XBUTTON2:
return MOUSE_BUTTON_XBUTTON2;
default:
- return 0;
+ return MOUSE_BUTTON_NONE;
}
}
@@ -863,12 +861,12 @@ Point2i DisplayServerAndroid::mouse_get_position() const {
return hover_prev_pos;
}
-int DisplayServerAndroid::mouse_get_button_state() const {
+MouseButton DisplayServerAndroid::mouse_get_button_state() const {
return buttons_state;
}
-int DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
- int godot_button_mask = 0;
+MouseButton DisplayServerAndroid::_android_button_mask_to_godot_button_mask(int android_button_mask) {
+ MouseButton godot_button_mask = MOUSE_BUTTON_NONE;
if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) {
godot_button_mask |= MOUSE_BUTTON_MASK_LEFT;
}
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index a2f47dcccb..a39271d524 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -68,7 +68,7 @@ private:
bool control_mem = false;
bool meta_mem = false;
- int buttons_state;
+ MouseButton buttons_state = MOUSE_BUTTON_NONE;
// https://developer.android.com/reference/android/view/PointerIcon
// mapping between Godot's cursor shape to Android's'
@@ -120,11 +120,11 @@ private:
void _set_key_modifier_state(Ref<InputEventWithModifiers> ev);
- static int _button_index_from_mask(int button_mask);
+ static MouseButton _button_index_from_mask(MouseButton button_mask);
- static int _android_button_mask_to_godot_button_mask(int android_button_mask);
+ static MouseButton _android_button_mask_to_godot_button_mask(int android_button_mask);
- void _wheel_button_click(int event_buttons_mask, const Ref<InputEventMouseButton> &ev, int wheel_button, float factor);
+ void _wheel_button_click(MouseButton event_buttons_mask, const Ref<InputEventMouseButton> &ev, MouseButton wheel_button, float factor);
public:
static DisplayServerAndroid *get_singleton();
@@ -219,7 +219,7 @@ public:
void notify_surface_changed(int p_width, int p_height);
virtual Point2i mouse_get_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
~DisplayServerAndroid();
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index 8831d26190..f1b92264e2 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -229,8 +229,8 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
}
Input *input = Input::get_singleton();
- int mask = input->get_mouse_button_mask();
- int button_flag = 1 << (ev->get_button_index() - 1);
+ MouseButton mask = input->get_mouse_button_mask();
+ MouseButton button_flag = MouseButton(1 << (ev->get_button_index() - 1));
if (ev->is_pressed()) {
// Since the event is consumed, focus manually. The containing iframe,
// if exists, may not have focus yet, so focus even if already focused.
@@ -478,11 +478,11 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
int button_flag = 1 << (ev->get_button_index() - 1);
ev->set_pressed(true);
- ev->set_button_mask(input->get_mouse_button_mask() | button_flag);
+ ev->set_button_mask(MouseButton(input->get_mouse_button_mask() | button_flag));
input->parse_input_event(ev);
ev->set_pressed(false);
- ev->set_button_mask(input->get_mouse_button_mask() & ~button_flag);
+ ev->set_button_mask(MouseButton(input->get_mouse_button_mask() & ~button_flag));
input->parse_input_event(ev);
return true;
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index b1bb064274..d2531cbe50 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -450,7 +450,7 @@ Point2i DisplayServerX11::mouse_get_absolute_position() const {
return Vector2i();
}
-int DisplayServerX11::mouse_get_button_state() const {
+MouseButton DisplayServerX11::mouse_get_button_state() const {
return last_button_state;
}
@@ -2172,13 +2172,13 @@ void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<Inp
state->set_meta_pressed((p_x11_state & Mod4Mask));
}
-unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
- unsigned int mask = 1 << (p_x11_button - 1);
+MouseButton DisplayServerX11::_get_mouse_button_state(MouseButton p_x11_button, int p_x11_type) {
+ MouseButton mask = MouseButton(1 << (p_x11_button - 1));
if (p_x11_type == ButtonPress) {
last_button_state |= mask;
} else {
- last_button_state &= ~mask;
+ last_button_state &= MouseButton(~mask);
}
return last_button_state;
@@ -3130,11 +3130,11 @@ void DisplayServerX11::process_events() {
mb->set_window_id(window_id);
_get_key_modifier_state(event.xbutton.state, mb);
- mb->set_button_index(event.xbutton.button);
- if (mb->get_button_index() == 2) {
- mb->set_button_index(3);
- } else if (mb->get_button_index() == 3) {
- mb->set_button_index(2);
+ mb->set_button_index((MouseButton)event.xbutton.button);
+ if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
+ } else if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE) {
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
}
mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
@@ -3297,7 +3297,7 @@ void DisplayServerX11::process_events() {
if (xi.pressure_supported) {
mm->set_pressure(xi.pressure);
} else {
- mm->set_pressure((mouse_get_button_state() & (1 << (MOUSE_BUTTON_LEFT - 1))) ? 1.0f : 0.0f);
+ mm->set_pressure((mouse_get_button_state() & MOUSE_BUTTON_MASK_LEFT) ? 1.0f : 0.0f);
}
mm->set_tilt(xi.tilt);
@@ -3855,8 +3855,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
img[i] = nullptr;
}
- last_button_state = 0;
-
xmbstring = nullptr;
last_click_ms = 0;
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 10686d8424..594a38d39e 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -162,7 +162,7 @@ class DisplayServerX11 : public DisplayServer {
Point2i last_click_pos;
uint64_t last_click_ms;
int last_click_button_index;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool app_focused = false;
uint64_t time_since_no_focus = 0;
@@ -187,7 +187,7 @@ class DisplayServerX11 : public DisplayServer {
bool _refresh_device_info();
- unsigned int _get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
+ MouseButton _get_mouse_button_state(MouseButton p_x11_button, int p_x11_type);
void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
void _flush_mouse_motion();
@@ -279,7 +279,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to);
virtual Point2i mouse_get_position() const;
virtual Point2i mouse_get_absolute_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index 56ff91571d..8b6dbc4c20 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -475,7 +475,7 @@ void JoypadLinux::process_joypads() {
switch (ev.type) {
case EV_KEY:
- input->joy_button(i, joy->key_map[ev.code], ev.value);
+ input->joy_button(i, (JoyButton)joy->key_map[ev.code], ev.value);
break;
case EV_ABS:
@@ -484,29 +484,29 @@ void JoypadLinux::process_joypads() {
case ABS_HAT0X:
if (ev.value != 0) {
if (ev.value < 0) {
- joy->dpad = (joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT);
} else {
- joy->dpad = (joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT);
}
} else {
joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT);
}
- input->joy_hat(i, joy->dpad);
+ input->joy_hat(i, (HatMask)joy->dpad);
break;
case ABS_HAT0Y:
if (ev.value != 0) {
if (ev.value < 0) {
- joy->dpad = (joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN);
} else {
- joy->dpad = (joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP;
+ joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP);
}
} else {
joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN);
}
- input->joy_hat(i, joy->dpad);
+ input->joy_hat(i, (HatMask)joy->dpad);
break;
default:
@@ -526,7 +526,7 @@ void JoypadLinux::process_joypads() {
for (int j = 0; j < MAX_ABS; j++) {
int index = joy->abs_map[j];
if (index != -1) {
- input->joy_axis(i, index, joy->curr_axis[index]);
+ input->joy_axis(i, (JoyAxis)index, joy->curr_axis[index]);
}
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 9fac99810b..5f7f5f84a2 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -173,7 +173,7 @@ public:
MouseMode mouse_mode;
Point2i last_mouse_pos;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool window_focused;
bool drop_events;
@@ -217,7 +217,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to) override;
virtual Point2i mouse_get_position() const override;
virtual Point2i mouse_get_absolute_position() const override;
- virtual int mouse_get_button_state() const override;
+ virtual MouseButton mouse_get_button_state() const override;
virtual void clipboard_set(const String &p_text) override;
virtual String clipboard_get() const override;
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 84e8770043..ec51ec78d3 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -813,14 +813,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
DS_OSX->cursor_set_shape(p_shape);
}
-static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, int index, int mask, bool pressed) {
+static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, MouseButton index, MouseButton mask, bool pressed) {
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
if (pressed) {
DS_OSX->last_button_state |= mask;
} else {
- DS_OSX->last_button_state &= ~mask;
+ DS_OSX->last_button_state &= (MouseButton)~mask;
}
Ref<InputEventMouseButton> mb;
@@ -1485,11 +1485,11 @@ static int remapKey(unsigned int key, unsigned int state) {
}
}
-inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, double factor, int modifierFlags) {
+inline void sendScrollEvent(DisplayServer::WindowID window_id, MouseButton button, double factor, int modifierFlags) {
ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
- unsigned int mask = 1 << (button - 1);
+ MouseButton mask = MouseButton(1 << (button - 1));
Ref<InputEventMouseButton> sc;
sc.instantiate();
@@ -1501,7 +1501,7 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, doubl
sc->set_pressed(true);
sc->set_position(wd.mouse_pos);
sc->set_global_position(wd.mouse_pos);
- DS_OSX->last_button_state |= mask;
+ DS_OSX->last_button_state |= (MouseButton)mask;
sc->set_button_mask(DS_OSX->last_button_state);
Input::get_singleton()->accumulate_input_event(sc);
@@ -1513,7 +1513,7 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, doubl
sc->set_pressed(false);
sc->set_position(wd.mouse_pos);
sc->set_global_position(wd.mouse_pos);
- DS_OSX->last_button_state &= ~mask;
+ DS_OSX->last_button_state &= (MouseButton)~mask;
sc->set_button_mask(DS_OSX->last_button_state);
Input::get_singleton()->accumulate_input_event(sc);
@@ -2173,7 +2173,7 @@ Point2i DisplayServerOSX::mouse_get_absolute_position() const {
return Vector2i();
}
-int DisplayServerOSX::mouse_get_button_state() const {
+MouseButton DisplayServerOSX::mouse_get_button_state() const {
return last_button_state;
}
@@ -3755,7 +3755,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
key_event_pos = 0;
mouse_mode = MOUSE_MODE_VISIBLE;
- last_button_state = 0;
autoreleasePool = [[NSAutoreleasePool alloc] init];
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index 9bf41d0423..126ebc1908 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -458,17 +458,17 @@ void JoypadOSX::process_joypads() {
for (int j = 0; j < joy.axis_elements.size(); j++) {
rec_element &elem = joy.axis_elements.write[j];
int value = joy.get_hid_element_state(&elem);
- input->joy_axis(joy.id, j, axis_correct(value, elem.min, elem.max));
+ input->joy_axis(joy.id, (JoyAxis)j, axis_correct(value, elem.min, elem.max));
}
for (int j = 0; j < joy.button_elements.size(); j++) {
int value = joy.get_hid_element_state(&joy.button_elements.write[j]);
- input->joy_button(joy.id, j, (value >= 1));
+ input->joy_button(joy.id, (JoyButton)j, (value >= 1));
}
for (int j = 0; j < joy.hat_elements.size(); j++) {
rec_element &elem = joy.hat_elements.write[j];
int value = joy.get_hid_element_state(&elem);
int hat_value = process_hat_value(elem.min, elem.max, value);
- input->joy_hat(joy.id, hat_value);
+ input->joy_hat(joy.id, (HatMask)hat_value);
}
if (joy.ffservice) {
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 570c41a8b3..1da17ffc5d 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -145,7 +145,7 @@ void App::SetWindow(CoreWindow ^ p_window) {
Main::setup2();
}
-static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
+static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) {
using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
@@ -177,7 +177,7 @@ static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
}
#endif
- return 0;
+ return MOUSE_BUTTON_NONE;
};
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
@@ -241,7 +241,7 @@ static int _get_finger(uint32_t p_touch_id) {
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
- int but = _get_button(point);
+ MouseButton but = _get_button(point);
if (_is_touch(point)) {
Ref<InputEventScreenTouch> screen_touch;
screen_touch.instantiate();
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index b0f6bbd330..e26e204f5f 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -126,8 +126,6 @@ void OS_UWP::set_keep_screen_on(bool p_enabled) {
}
void OS_UWP::initialize_core() {
- last_button_state = 0;
-
//RedirectIOToConsole();
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
@@ -423,7 +421,7 @@ Point2 OS_UWP::get_mouse_position() const {
return Point2(old_x, old_y);
}
-int OS_UWP::get_mouse_button_state() const {
+MouseButton OS_UWP::get_mouse_button_state() const {
return last_button_state;
}
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index a4d3d6d52a..3a735889b0 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -106,7 +106,7 @@ private:
bool control_mem;
bool meta_mem;
bool force_quit;
- uint32_t last_button_state;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
CursorShape cursor_shape;
@@ -173,7 +173,7 @@ public:
MouseMode get_mouse_mode() const;
virtual Point2 get_mouse_position() const;
- virtual int get_mouse_button_state() const;
+ virtual MouseButton get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 5a2bb354d7..f7172598ec 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -161,7 +161,7 @@ Point2i DisplayServerWindows::mouse_get_position() const {
//return Point2(old_x, old_y);
}
-int DisplayServerWindows::mouse_get_button_state() const {
+MouseButton DisplayServerWindows::mouse_get_button_state() const {
return last_button_state;
}
@@ -2391,41 +2391,41 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg) {
case WM_LBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
} break;
case WM_LBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
} break;
case WM_MBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
} break;
case WM_MBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
} break;
case WM_RBUTTONDOWN: {
mb->set_pressed(true);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
} break;
case WM_RBUTTONUP: {
mb->set_pressed(false);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
} break;
case WM_LBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(1);
+ mb->set_button_index(MOUSE_BUTTON_LEFT);
mb->set_double_click(true);
} break;
case WM_RBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(2);
+ mb->set_button_index(MOUSE_BUTTON_RIGHT);
mb->set_double_click(true);
} break;
case WM_MBUTTONDBLCLK: {
mb->set_pressed(true);
- mb->set_button_index(3);
+ mb->set_button_index(MOUSE_BUTTON_MIDDLE);
mb->set_double_click(true);
} break;
case WM_MOUSEWHEEL: {
@@ -2492,9 +2492,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_alt_pressed(alt_mem);
//mb->is_alt_pressed()=(wParam&MK_MENU)!=0;
if (mb->is_pressed()) {
- last_button_state |= (1 << (mb->get_button_index() - 1));
+ last_button_state |= MouseButton(1 << (mb->get_button_index() - 1));
} else {
- last_button_state &= ~(1 << (mb->get_button_index() - 1));
+ last_button_state &= (MouseButton) ~(1 << (mb->get_button_index() - 1));
}
mb->set_button_mask(last_button_state);
@@ -2534,7 +2534,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
//send release for mouse wheel
Ref<InputEventMouseButton> mbd = mb->duplicate();
mbd->set_window_id(window_id);
- last_button_state &= ~(1 << (mbd->get_button_index() - 1));
+ last_button_state &= (MouseButton) ~(1 << (mbd->get_button_index() - 1));
mbd->set_button_mask(last_button_state);
mbd->set_pressed(false);
Input::get_singleton()->accumulate_input_event(mbd);
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index a734077e59..d71e579c67 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -408,7 +408,7 @@ class DisplayServerWindows : public DisplayServer {
bool shift_mem = false;
bool control_mem = false;
bool meta_mem = false;
- uint32_t last_button_state = 0;
+ MouseButton last_button_state = MOUSE_BUTTON_NONE;
bool use_raw_input = false;
bool drop_events = false;
bool in_dispatch_input_event = false;
@@ -449,7 +449,7 @@ public:
virtual void mouse_warp_to_position(const Point2i &p_to);
virtual Point2i mouse_get_position() const;
- virtual int mouse_get_button_state() const;
+ virtual MouseButton mouse_get_button_state() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 4b6f0ccaeb..94da63e49d 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -330,7 +330,7 @@ void JoypadWindows::process_joypads() {
if (joy.state.dwPacketNumber != joy.last_packet) {
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int j = 0; j <= 16; j++) {
- input->joy_button(joy.id, j, joy.state.Gamepad.wButtons & button_mask);
+ input->joy_button(joy.id, (JoyButton)j, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2;
}
@@ -381,12 +381,12 @@ void JoypadWindows::process_joypads() {
for (int j = 0; j < 128; j++) {
if (js.rgbButtons[j] & 0x80) {
if (!joy->last_buttons[j]) {
- input->joy_button(joy->id, j, true);
+ input->joy_button(joy->id, (JoyButton)j, true);
joy->last_buttons[j] = true;
}
} else {
if (joy->last_buttons[j]) {
- input->joy_button(joy->id, j, false);
+ input->joy_button(joy->id, (JoyButton)j, false);
joy->last_buttons[j] = false;
}
}
@@ -400,7 +400,7 @@ void JoypadWindows::process_joypads() {
for (int j = 0; j < joy->joy_axis.size(); j++) {
for (int k = 0; k < count; k++) {
if (joy->joy_axis[j] == axes[k]) {
- input->joy_axis(joy->id, j, axis_correct(values[k]));
+ input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k]));
break;
};
};
@@ -410,7 +410,7 @@ void JoypadWindows::process_joypads() {
}
void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
- int dpad_val = 0;
+ HatMask dpad_val = (HatMask)0;
// Should be -1 when centered, but according to docs:
// "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows: