aboutsummaryrefslogtreecommitdiff
path: root/src/rumble.c
diff options
context:
space:
mode:
authorUneven Prankster <unevenprankster@protonmail.com>2023-10-15 21:28:29 -0300
committerUneven Prankster <unevenprankster@protonmail.com>2023-10-15 21:28:29 -0300
commit1c0cc775732201f4c4d3ee0d6772be786b3b4aa1 (patch)
treef5d692d046868261275c7430a624c3ea9ed75d3d /src/rumble.c
parenta89f892640cf12f75c7ce18e6e88c70a8d3965ed (diff)
A lot has certainly happened!
Diffstat (limited to 'src/rumble.c')
-rw-r--r--src/rumble.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/rumble.c b/src/rumble.c
deleted file mode 100644
index b2da191..0000000
--- a/src/rumble.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-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"
-#include <stdio.h>
-
-// Windows stuff starts //
-typedef struct _XINPUT_VIBRATION {
- unsigned wLeftMotorSpeed;
- unsigned wRightMotorSpeed;
-} XINPUT_VIBRATION;
-unsigned int XInputSetState(unsigned int dwUserIndex, XINPUT_VIBRATION *pVibration);
-// Windows stuff ends //
-
-static fx32 timer = 0;
-
-void set_rumble(f32 duration, f32 strength)
-{
- // If game code is surpassing this something is wrong!!
- assert(strength >= 0.f && strength <= 1.f);
-
- XINPUT_VIBRATION state = {};
- state.wLeftMotorSpeed = (unsigned)(strength * 65535.0f);
- state.wRightMotorSpeed = (unsigned)(strength * 65535.0f);
-
- if (XInputSetState(0, &state) == 0){
- timer = FP_TO_FIXED(duration);
- }
-}
-
-void poll_rumble(f32 dt)
-{
- // Early return
- if(timer <= 0)
- return;
-
- fx32 delta = FP_TO_FIXED(dt);
-
- timer -= delta;
- if(timer <= 0){
- stop_rumble();
- }
-}
-
-void stop_rumble(void)
-{
- timer = 0;
-
- XINPUT_VIBRATION state = {};
- state.wLeftMotorSpeed = 0;
- state.wRightMotorSpeed = 0;
- XInputSetState(0, &state);
-} \ No newline at end of file