aboutsummaryrefslogtreecommitdiff
path: root/sdl2/gamecontroller.ha
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2022-02-05 09:41:17 +0100
committerDrew DeVault <sir@cmpwn.com>2022-02-05 09:41:17 +0100
commit0fdfa823b404fff3d18d72bf2dccfe0ce444cfd5 (patch)
treebaea256e596312905159b8d860a07ebc553ef2fd /sdl2/gamecontroller.ha
parentadd gl.ha (diff)
downloadhare-chip8-0fdfa823b404fff3d18d72bf2dccfe0ce444cfd5.tar.gz
Add controller rumble support
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat (limited to 'sdl2/gamecontroller.ha')
-rw-r--r--sdl2/gamecontroller.ha26
1 files changed, 26 insertions, 0 deletions
diff --git a/sdl2/gamecontroller.ha b/sdl2/gamecontroller.ha
index 46b5f5c..4af8677 100644
--- a/sdl2/gamecontroller.ha
+++ b/sdl2/gamecontroller.ha
@@ -71,3 +71,29 @@ export fn game_controller_open(
// Close a game controller previously opened with [[game_controller_open]].
export @symbol("SDL_GameControllerClose") fn game_controller_close(
gamecontroller: *gamecontroller) void;
+
+@symbol("SDL_GameControllerRumble") fn _game_controller_rumble(
+ gamecontroller: *gamecontroller,
+ low_frequency_rumble: u16,
+ high_frequency_rumble: u16,
+ duration_ms: u32) int;
+
+// Start a rumble effect on a game controller.
+//
+// Each call to this function cancels any previous rumble effect, and calling
+// it with 0 intensity stops any rumbling.
+//
+// The low-frequency motor is generally on the left, and the high-frequency
+// motor is generally on the right.
+export fn game_controller_rumble(
+ gamecontroller: *gamecontroller,
+ low_frequency_rumble: u16,
+ high_frequency_rumble: u16,
+ duration_ms: u32,
+) (void | error) = {
+ return wrapvoid(_game_controller_rumble(
+ gamecontroller,
+ low_frequency_rumble,
+ high_frequency_rumble,
+ duration_ms));
+};