diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-26 00:17:53 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-26 00:20:47 +0530 |
| commit | 6ad789149036a9e97a9c66860828892efa432bd4 (patch) | |
| tree | b509812fc69f1af890c1c4ddbcda79f81bc9ab43 /src/Chelleport/Control.hs | |
| parent | d9b2256047669b5a5dbac4baec7140f18a5b6eff (diff) | |
| download | chelleport-6ad789149036a9e97a9c66860828892efa432bd4.tar.gz chelleport-6ad789149036a9e97a9c66860828892efa432bd4.zip | |
Add c-hjkl for movement keys
Diffstat (limited to 'src/Chelleport/Control.hs')
| -rw-r--r-- | src/Chelleport/Control.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs index 48bdcb2..e7bd418 100644 --- a/src/Chelleport/Control.hs +++ b/src/Chelleport/Control.hs @@ -94,10 +94,17 @@ anyDigit = isKeycodeDigit . eventToKeycode anyAlphanumeric :: SDL.KeyboardEventData -> Bool anyAlphanumeric = isValidKey . eventToKeycode -directionalIncrement :: (CInt, CInt) -> Char -> (Int, Int) +hjklDirection :: Char -> Direction +hjklDirection = \case + 'H' -> DirLeft + 'L' -> DirRight + 'K' -> DirUp + 'J' -> DirDown + _ -> DirUp + +directionalIncrement :: (CInt, CInt) -> Direction -> (Int, Int) directionalIncrement (incX, incY) = \case - 'H' -> (-cIntToInt incX, 0) - 'L' -> (cIntToInt incX, 0) - 'K' -> (0, -cIntToInt incY) - 'J' -> (0, cIntToInt incY) - _ -> undefined + DirLeft -> (-cIntToInt incX, 0) + DirRight -> (cIntToInt incX, 0) + DirUp -> (0, -cIntToInt incY) + DirDown -> (0, cIntToInt incY) |
