diff options
| author | Uneven Prankster <unevenprankster@protonmail.com> | 2023-07-25 17:37:40 -0300 |
|---|---|---|
| committer | Uneven Prankster <unevenprankster@protonmail.com> | 2023-07-25 17:37:40 -0300 |
| commit | 593e8163a2442546a459d98d8febcaa9c2cbceb9 (patch) | |
| tree | 713cf2bc250a358ac7ff480ae4aeb443a0c5b837 /src/rumble.c | |
| parent | 6f4930e920b3f368d0fcb9acfd2824095b101681 (diff) | |
Added explanation for Fixed-point usage, + a useful macro
Diffstat (limited to 'src/rumble.c')
| -rw-r--r-- | src/rumble.c | 7 |
1 files changed, 5 insertions, 2 deletions
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){ |
