summaryrefslogtreecommitdiff
path: root/platform/uwp
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2021-12-25 09:29:08 +0000
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2022-01-14 15:36:20 +0000
commitf41c72c5384ff9ce34f60380d4f27b9af0904298 (patch)
treeb7c218ab98ea31284e85edecc543986fbae94e06 /platform/uwp
parent6689a9360c2dae0ca940e4e470c4d0a0e0a9bef4 (diff)
Fix Actions mapped to triggers not using the full range
Diffstat (limited to 'platform/uwp')
-rw-r--r--platform/uwp/joypad_uwp.cpp13
-rw-r--r--platform/uwp/joypad_uwp.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index ef44f0b14d..e48016919b 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -134,13 +134,12 @@ void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Inp
input->joy_connection_changed(idx, false, "Xbox Controller");
}
-InputDefault::JoyAxisValue JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const {
- InputDefault::JoyAxisValue jx;
-
- jx.min = p_trigger ? 0 : -1;
- jx.value = (float)(p_negate ? -p_val : p_val);
-
- return jx;
+float JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const {
+ if (p_trigger) {
+ // Convert to a value between -1.0f and 1.0f.
+ return 2.0f * p_val - 1.0f;
+ }
+ return (float)(p_negate ? -p_val : p_val);
}
void JoypadUWP::joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) {
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 1d68996358..29f5109056 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -73,7 +73,7 @@ private:
void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
- InputDefault::JoyAxisValue axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const;
+ float axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const;
void joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop(int p_device, uint64_t p_timestamp);
};