Start to unify selection lists

This commit is contained in:
2022-11-02 09:36:16 +00:00
parent 7d358fde29
commit 7c8958cea7
7 changed files with 122 additions and 24 deletions
+9 -9
View File
@@ -8,8 +8,8 @@ module Dodge.Event.Input (
) where
import qualified Data.Text as T
import Dodge.Data.Input
import Dodge.Data.Config
import Dodge.Data.Input
import LensHelp
import SDL
@@ -18,23 +18,23 @@ import SDL
handleTextInput :: T.Text -> Input -> Input
handleTextInput text = textInput %~ (`T.append` text)
{- | Handles keyboard press and release.
-}
-- | Handles keyboard press and release.
handleKeyboardEvent :: KeyboardEventData -> Input -> Input
handleKeyboardEvent kev = case keyboardEventKeyMotion kev of
Released -> pressedKeys . at scode .~ Nothing
Pressed -> pressedKeys . at scode ?~ val
where
val | keyboardEventRepeat kev = LongPress
val
| keyboardEventRepeat kev = LongPress
| otherwise = InitialPress
scode = (keysymScancode . keyboardEventKeysym) kev
handleMouseMotionEvent :: MouseMotionEventData -> Configuration -> Input -> Input
handleMouseMotionEvent mmev cfig inp =
inp & mousePos
.~ V2
(fromIntegral x - 0.5 * _windowX cfig)
(0.5 * _windowY cfig - fromIntegral y)
handleMouseMotionEvent mmev cfig =
mousePos
.~ V2
(fromIntegral x - 0.5 * _windowX cfig)
(0.5 * _windowY cfig - fromIntegral y)
where
P (V2 x y) = mouseMotionEventPos mmev