From 9534c490c5c318e6c29ebf881ac5350545f479e5 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 7 Feb 2023 16:08:13 +0000 Subject: Using OverloadedRecordDot --- src/Game/Controller.hs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/Game/Controller.hs') diff --git a/src/Game/Controller.hs b/src/Game/Controller.hs index ec1cdf3..b5cd685 100644 --- a/src/Game/Controller.hs +++ b/src/Game/Controller.hs @@ -9,14 +9,14 @@ import qualified SDL.Raw import Prelude hiding (init) data Controls = Controls - { cUp :: Bool, - cDown :: Bool, - cLeft :: Bool, - cRight :: Bool, - cA :: Bool, - cB :: Bool, - cMenu :: Bool, - cJoy :: Maybe SDL.Raw.Joystick + { up :: Bool, + down :: Bool, + left :: Bool, + right :: Bool, + a :: Bool, + b :: Bool, + menu :: Bool, + joy :: Maybe SDL.Raw.Joystick } deriving (Show) @@ -39,29 +39,29 @@ init = do updateGamepad :: [SDL.EventPayload] -> Controls -> Controls updateGamepad events controls - | isNothing $ cJoy controls = controls + | isNothing $ controls.joy = controls -- XXX: deal with disconnection/reconnection | otherwise = controls - { cUp = fromMaybe (cUp controls) $ isPressedGamepad SDL.ControllerButtonDpadUp events, - cDown = fromMaybe (cDown controls) $ isPressedGamepad SDL.ControllerButtonDpadDown events, - cLeft = fromMaybe (cLeft controls) $ isPressedGamepad SDL.ControllerButtonDpadLeft events, - cRight = fromMaybe (cRight controls) $ isPressedGamepad SDL.ControllerButtonDpadRight events, - cA = fromMaybe (cA controls) $ isPressedGamepad SDL.ControllerButtonA events, - cB = fromMaybe (cB controls) $ isPressedGamepad SDL.ControllerButtonB events, - cMenu = fromMaybe (cMenu controls) $ isPressedGamepad SDL.ControllerButtonStart events + { up = fromMaybe controls.up $ isPressedGamepad SDL.ControllerButtonDpadUp events, + down = fromMaybe controls.down $ isPressedGamepad SDL.ControllerButtonDpadDown events, + left = fromMaybe controls.left $ isPressedGamepad SDL.ControllerButtonDpadLeft events, + right = fromMaybe controls.right $ isPressedGamepad SDL.ControllerButtonDpadRight events, + a = fromMaybe controls.a $ isPressedGamepad SDL.ControllerButtonA events, + b = fromMaybe controls.b $ isPressedGamepad SDL.ControllerButtonB events, + menu = fromMaybe controls.menu $ isPressedGamepad SDL.ControllerButtonStart events } updateKeyboard :: [SDL.EventPayload] -> Controls -> Controls updateKeyboard events controls = controls - { cUp = fromMaybe (cUp controls) $ isPressed SDL.KeycodeUp events, - cDown = fromMaybe (cDown controls) $ isPressed SDL.KeycodeDown events, - cLeft = fromMaybe (cLeft controls) $ isPressed SDL.KeycodeLeft events, - cRight = fromMaybe (cRight controls) $ isPressed SDL.KeycodeRight events, - cA = fromMaybe (cA controls) $ isPressed SDL.KeycodeZ events, - cB = fromMaybe (cB controls) $ isPressed SDL.KeycodeX events, - cMenu = fromMaybe (cMenu controls) $ isPressed SDL.KeycodeReturn events + { up = fromMaybe controls.up $ isPressed SDL.KeycodeUp events, + down = fromMaybe controls.down $ isPressed SDL.KeycodeDown events, + left = fromMaybe controls.left $ isPressed SDL.KeycodeLeft events, + right = fromMaybe controls.right $ isPressed SDL.KeycodeRight events, + a = fromMaybe controls.a $ isPressed SDL.KeycodeZ events, + b = fromMaybe controls.b $ isPressed SDL.KeycodeX events, + menu = fromMaybe controls.menu $ isPressed SDL.KeycodeReturn events } update :: [SDL.EventPayload] -> Controls -> Controls -- cgit v1.2.3