From 593e8163a2442546a459d98d8febcaa9c2cbceb9 Mon Sep 17 00:00:00 2001 From: Uneven Prankster Date: Tue, 25 Jul 2023 17:37:40 -0300 Subject: Added explanation for Fixed-point usage, + a useful macro --- src/rumble.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/rumble.c') diff --git a/src/rumble.c b/src/rumble.c index 2313d68..2212761 100644 --- a/src/rumble.c +++ b/src/rumble.c @@ -2,6 +2,8 @@ I made this a separate source file because Raylib has some quirks regarding Windows compilation. And I also suppose because it has some state of its own. + +NOTE FOR SPELUNKERS: this requires linking to xinput1_4 AFAIK */ #include "controller.h" @@ -23,16 +25,17 @@ void set_rumble(f32 duration, f32 strength) state.wRightMotorSpeed = (unsigned)(strength * 65535.0f); if (XInputSetState(0, &state) == 0){ - timer = FIXED_POINT_ONE * duration; + timer = FP_TO_FIXED(duration); } } void poll_rumble(f32 dt) { + // Early return if(timer <= 0) return; - fx32 delta = FIXED_POINT_ONE * dt; + fx32 delta = FP_TO_FIXED(dt); timer -= delta; if(timer <= 0){ -- cgit v1.2.3