summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/display_server_windows.cpp3
-rw-r--r--platform/windows/joypad_windows.cpp42
-rw-r--r--platform/windows/joypad_windows.h2
3 files changed, 22 insertions, 25 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 091bed36ea..9160371b5f 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2819,6 +2819,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_DEVICECHANGE: {
joypad->probe_joypads();
} break;
+ case WM_DESTROY: {
+ Input::get_singleton()->flush_buffered_events();
+ } break;
case WM_SETCURSOR: {
if (LOWORD(lParam) == HTCLIENT) {
if (windows[window_id].window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN)) {
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 8b6081d606..b0dd86a4b7 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -448,33 +448,27 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
input->joy_hat(p_device, dpad_val);
};
-Input::JoyAxisValue JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
- Input::JoyAxisValue jx;
+float JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
if (Math::abs(p_val) < MIN_JOY_AXIS) {
- jx.min = p_trigger ? 0 : -1;
- jx.value = 0.0f;
- return jx;
+ return p_trigger ? -1.0f : 0.0f;
}
- if (p_xinput) {
- if (p_trigger) {
- jx.min = 0;
- jx.value = (float)p_val / MAX_TRIGGER;
- return jx;
- }
- jx.min = -1;
- if (p_val < 0) {
- jx.value = (float)p_val / MAX_JOY_AXIS;
- } else {
- jx.value = (float)p_val / (MAX_JOY_AXIS - 1);
- }
- if (p_negate) {
- jx.value = -jx.value;
- }
- return jx;
+ if (!p_xinput) {
+ return (float)p_val / MAX_JOY_AXIS;
+ }
+ if (p_trigger) {
+ // Convert to a value between -1.0f and 1.0f.
+ return 2.0f * p_val / MAX_TRIGGER - 1.0f;
+ }
+ float value;
+ if (p_val < 0) {
+ value = (float)p_val / MAX_JOY_AXIS;
+ } else {
+ value = (float)p_val / (MAX_JOY_AXIS - 1);
+ }
+ if (p_negate) {
+ value = -value;
}
- jx.min = -1;
- jx.value = (float)p_val / MAX_JOY_AXIS;
- return jx;
+ return value;
}
void JoypadWindows::joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) {
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index 4faefe932f..0e3d03fa52 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -132,7 +132,7 @@ private:
void joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp);
- Input::JoyAxisValue axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
+ float axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
XInputGetState_t xinput_get_state;
XInputSetState_t xinput_set_state;
};