Change keycode input to scancode

This commit is contained in:
jgk
2021-03-25 13:28:28 +01:00
parent e32c6082c5
commit 45e02d0752
5 changed files with 35 additions and 32 deletions
+6 -6
View File
@@ -1933,14 +1933,14 @@ wasdWithAiming w speed aimSpeed i cr
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
wasdM :: SDL.Keycode -> Point2
wasdM SDL.KeycodeW = (0,1)
wasdM SDL.KeycodeS = (0,-1)
wasdM SDL.KeycodeD = (1,0)
wasdM SDL.KeycodeA = (-1,0)
wasdM :: SDL.Scancode -> Point2
wasdM SDL.ScancodeW = (0,1)
wasdM SDL.ScancodeS = (0,-1)
wasdM SDL.ScancodeD = (1,0)
wasdM SDL.ScancodeA = (-1,0)
wasdM _ = (0,0)
wasdComp :: S.Set SDL.Keycode -> (Point2,Maybe Float)
wasdComp :: S.Set SDL.Scancode -> (Point2,Maybe Float)
wasdComp ks = f $ foldr ( (+.+) . wasdM ) (0,0) ks
where f (0,0) = ((0,0), Nothing)
f p = (errorNormalizeV 46 p, Just $ argV p)