Add general smooth scrolling, move camera into world
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
-- | Capture input events, store them in structures for later use.
|
||||
-- Should not update the world other than this.
|
||||
{- | Capture input events, store them in structures for later use.
|
||||
Should not update the world other than this.
|
||||
-}
|
||||
module Dodge.Event.Input (
|
||||
handleKeyboardEvent,
|
||||
handleTextInput,
|
||||
@@ -12,6 +13,7 @@ import Dodge.Data.Config
|
||||
import Dodge.Data.Input
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
--import qualified Data.Map.Strict as M
|
||||
|
||||
-- annoyingly, the text input event doesn't register backspace, so deletion has to be
|
||||
@@ -23,8 +25,9 @@ handleTextInput text = textInput %~ (++ map Right text)
|
||||
handleKeyboardEvent :: KeyboardEventData -> Input -> Input
|
||||
handleKeyboardEvent kev = case keyboardEventKeyMotion kev of
|
||||
Released -> pressedKeys . at scode .~ Nothing
|
||||
Pressed -> (pressedKeys . at scode ?~ val)
|
||||
. addTermSignal scode
|
||||
Pressed ->
|
||||
(pressedKeys . at scode ?~ val)
|
||||
. addTermSignal scode
|
||||
where
|
||||
val
|
||||
| keyboardEventRepeat kev = LongPress
|
||||
@@ -50,14 +53,16 @@ handleMouseMotionEvent mmev cfig =
|
||||
(0.5 * windowYFloat cfig - fromIntegral y)
|
||||
|
||||
handleMouseWheelEvent :: MouseWheelEventData -> Input -> Input
|
||||
handleMouseWheelEvent mwev = scrollAmount +~ fromIntegral y
|
||||
handleMouseWheelEvent mwev =
|
||||
(scrollAmount +~ fromIntegral y)
|
||||
where
|
||||
V2 _ y = mouseWheelEventPos mwev
|
||||
|
||||
|
||||
handleMouseButtonEvent :: MouseButtonEventData -> Input -> Input
|
||||
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
|
||||
Released -> mouseButtons . at thebutton .~ Nothing
|
||||
Pressed -> mouseButtons . at thebutton ?~ 1 -- note that mouse button events are NOT repeating
|
||||
where
|
||||
-- pointtothebutton = mouseButtons . at thebutton
|
||||
-- pointtothebutton = mouseButtons . at thebutton
|
||||
thebutton = mouseButtonEventButton mbev
|
||||
|
||||
Reference in New Issue
Block a user