Files
loop/src/Dodge/Data/Input.hs
T

68 lines
2.1 KiB
Haskell

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.Input where
import Control.Lens
import qualified Data.Map.Strict as M
import Geometry.Data
import SDL (MouseButton, Scancode)
data PressType
= InitialPress
| ShortPress
| LongPress
deriving (Eq, Show)
data MouseContext
= NoMouseContext
| MouseAiming
| MouseInGame
| MouseMenuClick {_mcoMenuClick :: Int}
| MouseMenuCursor
| OverInvDrag {_mcoDragSection :: Int, _mcoMaybeSelect :: Maybe (Int,Int)}
| OverInvDragSelect { _mcoSelStart :: (Int,Int), _mcoSelEnd :: Maybe (Int,Int) }
| OverInvSelect { _mcoInvSelect :: (Int,Int)}
| OverInvFilt { _mcoInvFilt :: (Int,Int)}
| OverCombSelect { _mcoCombSelect :: (Int,Int)}
| OverCombCombine { _mcoCombCombine :: (Int,Int)}
| OverCombFilter
| OverCombEscape
| OverTerminalReturn {_mcoTermID :: Int}
| OverTerminalEscape
deriving (Show)
data Input = Input
{ _mousePos :: Point2 -- in pixels, from the center of the screen
, _mouseContext :: MouseContext
, _mouseMoving :: Bool
, _pressedKeys :: M.Map Scancode PressType
, _mouseButtons :: M.Map MouseButton Int -- counts number of frames held down
, _mouseButtonsReleased :: M.Map MouseButton Int -- counts number of frames released
, _scrollAmount :: Int
, _smoothScrollAmount :: Int
, _clickPos :: M.Map MouseButton Point2 -- updates on initial mouse button press
, _heldPos :: M.Map MouseButton Point2 -- updates while mouse button is held, lags one frame
, _clickWorldPos :: M.Map MouseButton Point2 -- updates on initial mouse button press
, _heldWorldPos :: M.Map MouseButton Point2 -- updates while mouse button is held, lags one frame
, _textInput :: [Either TermSignal Char]
, _scrollTestFloat :: Float
, _scrollTestInt :: Int
}
data TermSignal
= TSescape
| TSreturn
| TSbackspace
| TSdelete
| TStab
| TSleft
| TSright
| TSup
| TSdown
makeLenses ''Input
makeLenses ''MouseContext