pituicat/src/Affection/MessageBus/Message/MouseMessage.hs

52 lines
1.9 KiB
Haskell
Raw Normal View History

2018-09-25 05:02:33 +00:00
module Affection.MessageBus.Message.MouseMessage
( MouseMessage(..)
-- | SDL reexports
, SDL.Window
, SDL.MouseDevice
, SDL.MouseButton
, SDL.InputMotion
, SDL.MouseScrollDirection
) where
2017-12-13 03:37:16 +00:00
import Affection.MessageBus.Message.Class
2017-12-13 14:19:53 +00:00
import Data.Word (Word8(..))
2017-12-13 03:37:16 +00:00
import Data.Int (Int32(..))
import qualified SDL
import Linear (V2(..))
2018-09-25 05:02:33 +00:00
-- Datatype for handling mouse events handed down from SDL2
2017-12-13 03:37:16 +00:00
data MouseMessage
2018-09-25 05:02:33 +00:00
= MsgMouseMotion -- ^ Mouse motion event
{ msgMMWhen :: Double -- ^ Message time
, msgMMWindow :: Maybe SDL.Window -- ^ Focused window (if any)
, msgMMWhich :: SDL.MouseDevice -- ^ Mouse device identifier
, msgMMState :: [SDL.MouseButton] -- ^ List of pressed mouse buttons
, msgMMPos :: V2 Int32 -- ^ Absolute mouse positiom
, msgMMRelMotion :: V2 Int32 -- ^ Mouse movement relative to previous position
2017-12-13 03:37:16 +00:00
}
2018-09-25 05:02:33 +00:00
| MsgMouseButton -- ^ Mouse button event
{ msgMBWhen :: Double -- ^ Message time
, msgMBWindow :: Maybe SDL.Window -- ^ Focused window (if any)
, msgMBMotion :: SDL.InputMotion -- ^ Button's input motion
, msgMBWhich :: SDL.MouseDevice -- ^ Mouse device identifier
, msgMBButton :: SDL.MouseButton -- ^ Affected mouse button
, msgMBClicks :: Word8 -- ^ Number of clicks
, msgMBPos :: V2 Int32 -- ^ Absolute mouse position
2017-12-13 03:37:16 +00:00
}
2018-09-25 05:02:33 +00:00
| MsgMouseWheel -- ^ Mouse wheel event
{ msgMWWhen :: Double -- ^ Message time
, msgMWWhindow :: Maybe SDL.Window -- ^ Focused window (if any)
, msgMWWhich :: SDL.MouseDevice -- ^ Mouse device identifier
, msgMWPos :: V2 Int32 -- ^ Absolute mouse position
, msgMWDIrection :: SDL.MouseScrollDirection -- ^ Scroll direction
2017-12-13 03:37:16 +00:00
}
2017-12-13 04:05:18 +00:00
deriving (Show)
2017-12-13 03:37:16 +00:00
instance Message MouseMessage where
msgTime (MsgMouseMotion t _ _ _ _ _) = t
2018-02-18 03:30:53 +00:00
msgTime (MsgMouseButton t _ _ _ _ _ _) = t
2017-12-13 03:37:16 +00:00
msgTime (MsgMouseWheel t _ _ _ _) = t