aboutsummaryrefslogtreecommitdiff
path: root/src/rumble.c
diff options
context:
space:
mode:
authorUneven Prankster <unevenprankster@protonmail.com>2023-08-06 20:11:52 -0300
committerUneven Prankster <unevenprankster@protonmail.com>2023-08-06 20:11:52 -0300
commit5baf08556afa833d609a1ea667e7bbdeee7f1f8f (patch)
tree72198fd7b9590f3f1643758110966c6a765439b6 /src/rumble.c
parent3b22db944d843ba831ae28e93c1d6d9acdfd319e (diff)
Added range check to rumble func
Diffstat (limited to 'src/rumble.c')
-rw-r--r--src/rumble.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/rumble.c b/src/rumble.c
index 21a6a73..5e782b7 100644
--- a/src/rumble.c
+++ b/src/rumble.c
@@ -20,6 +20,12 @@ static fx32 timer = 0;
void set_rumble(f32 duration, f32 strength)
{
+ // Sanity check
+ if(strength > 1.0f)
+ strength = 1.0f;
+ else if(strength < 0.0f)
+ strength = 0.0f;
+
XINPUT_VIBRATION state = {};
state.wLeftMotorSpeed = (unsigned)(strength * 65535.0f);
state.wRightMotorSpeed = (unsigned)(strength * 65535.0f);