Separate out input datatype

This commit is contained in:
2022-10-29 11:36:57 +01:00
parent 82e2a5a234
commit af6cdff063
19 changed files with 160 additions and 112 deletions
+4 -4
View File
@@ -35,7 +35,7 @@ handleEvent e = case eventPayload e of
handleMouseMotionEvent :: MouseMotionEventData -> Universe -> Maybe Universe
handleMouseMotionEvent mmev u =
Just $
u & uvWorld . mousePos
u & uvWorld . input . mousePos
.~ V2
(fromIntegral x - 0.5 * _windowX cfig)
(0.5 * _windowY cfig - fromIntegral y)
@@ -45,8 +45,8 @@ handleMouseMotionEvent mmev u =
handleMouseButtonEvent :: MouseButtonEventData -> World -> World
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
Released -> mouseButtons . at thebutton .~ Nothing
Pressed -> mouseButtons . at thebutton ?~ False
Released -> input . mouseButtons . at thebutton .~ Nothing
Pressed -> input . mouseButtons . at thebutton ?~ False
where
thebutton = mouseButtonEventButton mbev
@@ -80,5 +80,5 @@ handleMouseWheelEvent :: MouseWheelEventData -> Universe -> Maybe Universe
handleMouseWheelEvent mwev w = case _uvScreenLayers w of
[] -> case mouseWheelEventPos mwev of
V2 _ y -> Just $ w -- & uvWorld %~ wheelEvent (fromIntegral y)
& uvWorld . scrollAmount +~ fromIntegral y
& uvWorld . input . scrollAmount +~ fromIntegral y
_ -> Just w