diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-09 12:20:46 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-09 12:20:46 +0000 |
commit | ee50719de81145b5859d957da722cf183e0c8c60 (patch) | |
tree | e6806d074aaab10103716e632332e02bb4390159 /src/Game | |
parent | 677f9396a30754c4030707a8d88009516a20758f (diff) | |
download | space-plat-hs-ee50719de81145b5859d957da722cf183e0c8c60.tar.gz space-plat-hs-ee50719de81145b5859d957da722cf183e0c8c60.zip |
Use ALT + Enter to toggle fullscreen
Diffstat (limited to 'src/Game')
-rw-r--r-- | src/Game/Controller.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Game/Controller.hs b/src/Game/Controller.hs index 01dfd1b..d47963e 100644 --- a/src/Game/Controller.hs +++ b/src/Game/Controller.hs @@ -1,4 +1,4 @@ -module Game.Controller (Controls (..), init, update, isPressed) where +module Game.Controller (Controls (..), init, update, isPressed, isModKey, altMod) where import Control.Monad import Data.Int (Int32) @@ -48,6 +48,9 @@ processControllerEvents controls [] = pure controls init :: Controls init = Controls False False False False False False False Nothing Nothing +altMod :: SDL.KeyModifier +altMod = SDL.KeyModifier False False False False True False False False False False False + updateGamepad :: Controls -> [SDL.EventPayload] -> Controls updateGamepad controls events = case controls.joyId of @@ -92,6 +95,12 @@ isPressed code events isEventKey expected keycode (SDL.KeyboardEvent (SDL.KeyboardEventData _ motion False ksym)) = expected == motion && SDL.keysymKeycode ksym == keycode isEventKey _ _ _ = False +isModKey :: SDL.KeyModifier -> [SDL.EventPayload] -> Bool +isModKey kmod = any (isModKeyOne kmod) + where + isModKeyOne m (SDL.KeyboardEvent (SDL.KeyboardEventData _ _ _ ksym)) = SDL.keysymModifier ksym == m + isModKeyOne _ _ = False + isPressedGamepad :: Int32 -> SDL.ControllerButton -> [SDL.EventPayload] -> Maybe Bool isPressedGamepad joyId button events | any (isEventButton SDL.ControllerButtonPressed button) events = Just True |