This commit is contained in:
2022-12-28 01:12:10 +00:00
parent c71af99ff7
commit 2d4a55dee0
8 changed files with 35 additions and 21 deletions
+9 -8
View File
@@ -31,13 +31,14 @@ handleKeyboardEvent kev = case keyboardEventKeyMotion kev of
handleMouseMotionEvent :: MouseMotionEventData -> Configuration -> Input -> Input
handleMouseMotionEvent mmev cfig =
(mousePos
.~ V2
(fromIntegral x - 0.5 * _windowX cfig)
(0.5 * _windowY cfig - fromIntegral y)
) . (mouseMoving .~ True)
set mousePos themousepos
. set mouseMoving True
where
P (V2 x y) = mouseMotionEventPos mmev
themousepos =
V2
(fromIntegral x - 0.5 * _windowX cfig)
(0.5 * _windowY cfig - fromIntegral y)
handleMouseWheelEvent :: MouseWheelEventData -> Input -> Input
handleMouseWheelEvent mwev = scrollAmount +~ fromIntegral y
@@ -46,7 +47,7 @@ handleMouseWheelEvent mwev = scrollAmount +~ fromIntegral y
handleMouseButtonEvent :: MouseButtonEventData -> Input -> Input
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
Released -> mouseButtons . at thebutton .~ Nothing
Pressed -> mouseButtons . at thebutton ?~ False
Released -> pointtothebutton .~ Nothing
Pressed -> pointtothebutton ?~ False
where
thebutton = mouseButtonEventButton mbev
pointtothebutton = mouseButtons . at (mouseButtonEventButton mbev)