Start to generalise text input to "terminal signal" input

This commit is contained in:
2023-03-26 13:57:26 +01:00
parent cfb0a49059
commit 082ce9c9a1
39 changed files with 171 additions and 165 deletions
+19 -5
View File
@@ -1,24 +1,27 @@
{-# LANGUAGE DeriveGeneric #-}
{-# 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
data PressType
= InitialPress
| ShortPress
| LongPress
deriving (Eq,Show)
deriving (Eq, Show)
data Input = Input
{ _mousePos :: Point2 -- in pixels, from the center of the screen
, _mouseMoving :: Bool
, _pressedKeys :: M.Map Scancode PressType
, _mouseButtons :: M.Map MouseButton Bool -- shortpress False, repeatpress True
, _scrollAmount :: Int
, _scrollAmount :: Int
, _previousScrollAmount :: Int
, _lLine :: (Point2, Point2)
, _rLine :: (Point2, Point2)
@@ -26,9 +29,20 @@ data Input = Input
, _lSelect :: Point2
, _rSelect :: Point2
, _clickMousePos :: Point2
, _textInput :: String
, _textInput :: [Either TermSignal Char]
, _scrollTestFloat :: Float
, _scrollTestInt :: Int
}
data TermSignal
= TSescape
| TSreturn
| TSbackspace
| TSdelete
| TStab
| TSleft
| TSright
| TSup
| TSdown
makeLenses ''Input