{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} module Dodge.Data.Input where import Dodge.Data.Terminal.Status import Control.Lens import qualified Data.Map.Strict as M import Geometry.Data import SDL (MouseButton, Scancode) data MouseContext = NoMouseContext | MouseAiming | MouseInGame | MouseMenuClick {_mcoMenuClick :: Int} | MouseMenuCursor | OverInvDrag {_mcoDragSection :: Int , _mcoMaybeSelect :: Maybe (Int,Int) , _mcoAboveSelect :: Maybe (Int,Int) , _mcoBelowSelect :: Maybe (Int,Int) } -- | OverInvDragSelect { _mcoSecSelStart :: (Int,Int), _mcoSelEnd :: Maybe Int } | OverInvDragSelect { _mcoSecSelStart :: Maybe (Int,Int), _mcoSelEnd :: Maybe Int } | OverInvSelect { _mcoInvSelect :: (Int,Int)} | OverCombFiltInv { _mcoInvFilt :: (Int,Int)} | OverCombSelect { _mcoCombSelect :: (Int,Int)} | OverCombCombine { _mcoCombCombine :: (Int,Int)} | OverCombFilter | OverCombEscape | OverTerminal {_mcoTermID :: Int, _mcoTermStatus :: TerminalStatus} | OutsideTerminal | MouseGameRotate deriving (Show) data Input = Input { _mousePos :: Point2 -- in pixels, from the center of the screen , _mouseContext :: MouseContext , _mouseMoving :: Bool , _pressedKeys :: M.Map Scancode Int , _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