From 0fdfa823b404fff3d18d72bf2dccfe0ce444cfd5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 5 Feb 2022 09:41:17 +0100 Subject: Add controller rumble support Signed-off-by: Drew DeVault --- sdl2/gamecontroller.ha | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sdl2/gamecontroller.ha') 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)); +}; -- cgit v1.2.3