From ded222becf7d238158c92ce3facb5d1521b00f68 Mon Sep 17 00:00:00 2001 From: Axis Sivitz Date: Fri, 16 May 2025 15:23:30 -0400 Subject: [PATCH 1/2] Expose game controller rumble functionality --- src/SDL/Raw/Event.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SDL/Raw/Event.hs b/src/SDL/Raw/Event.hs index 5de95fa..8736735 100644 --- a/src/SDL/Raw/Event.hs +++ b/src/SDL/Raw/Event.hs @@ -112,6 +112,7 @@ module SDL.Raw.Event ( gameControllerNameForIndex, gameControllerOpen, gameControllerUpdate, + gameControllerRumble, isGameController, eventBuffer, eventBufferSize @@ -235,6 +236,7 @@ foreign import ccall "SDL.h SDL_GameControllerName" gameControllerNameFFI :: Gam foreign import ccall "SDL.h SDL_GameControllerNameForIndex" gameControllerNameForIndexFFI :: CInt -> IO CString foreign import ccall "SDL.h SDL_GameControllerOpen" gameControllerOpenFFI :: CInt -> IO GameController foreign import ccall "SDL.h SDL_GameControllerUpdate" gameControllerUpdateFFI :: IO () +foreign import ccall "SDL.h SDL_GameControllerRumble" gameControllerRumbleFFI :: GameController -> CUShort -> CUShort -> CUInt -> IO CInt foreign import ccall "SDL.h SDL_IsGameController" isGameControllerFFI :: CInt -> IO Bool foreign import ccall "sdlhelper.c SDLHelper_GetEventBufferSize" eventBufferSize :: CInt @@ -675,6 +677,10 @@ gameControllerUpdate :: MonadIO m => m () gameControllerUpdate = liftIO gameControllerUpdateFFI {-# INLINE gameControllerUpdate #-} +gameControllerRumble :: MonadIO m => GameController -> CUShort -> CUShort -> CUInt -> m CInt +gameControllerRumble v1 v2 v3 v4 = liftIO $ gameControllerRumbleFFI v1 v2 v3 v4 +{-# INLINE gameControllerRumble #-} + isGameController :: MonadIO m => CInt -> m Bool isGameController v1 = liftIO $ isGameControllerFFI v1 {-# INLINE isGameController #-} From 0c78116f98343199664671ee18eef4bd86557003 Mon Sep 17 00:00:00 2001 From: Axis Sivitz Date: Mon, 19 May 2025 13:24:48 -0400 Subject: [PATCH 2/2] Bump SDL2 version for SDL_GameControllerRumble --- sdl2.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdl2.cabal b/sdl2.cabal index 1560f9c..558eae3 100644 --- a/sdl2.cabal +++ b/sdl2.cabal @@ -141,7 +141,7 @@ library else if flag(pkgconfig) pkgconfig-depends: - sdl2 >= 2.0.6 + sdl2 >= 2.0.9 build-depends: base >= 4.7 && < 5,