rebase keyconfig changes
This commit is contained in:
+15
-29
@@ -9,6 +9,7 @@ import SDL
|
||||
import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
import Control.Lens
|
||||
import LoadConfig
|
||||
|
||||
handleKeyboardEvent :: KeyboardEventData -> World -> Maybe World
|
||||
handleKeyboardEvent kev w = case keyboardEventKeyMotion kev of
|
||||
@@ -22,18 +23,19 @@ handleKeyboardEvent kev w = case keyboardEventKeyMotion kev of
|
||||
|
||||
handlePressedKey :: Bool -> Scancode -> World -> Maybe World
|
||||
handlePressedKey True _ w = Just w
|
||||
handlePressedKey _ keycode w = case keycode of
|
||||
ScancodeEscape -> Nothing
|
||||
ScancodeC -> Just $ pauseGame $ escapeMap w
|
||||
ScancodeF -> Just $ dropItem w
|
||||
ScancodeM -> Just $ toggleMap w
|
||||
ScancodeP -> Just $ pauseGame $ escapeMap w
|
||||
ScancodeR -> Just $ fromMaybe w $ reloadWeapon (_yourID w) w
|
||||
ScancodeT -> Just $ testEvent w
|
||||
ScancodeSpace -> Just $ spaceAction w
|
||||
ScancodeQ -> Just $ w & cameraRot +~ 0.01
|
||||
ScancodeE -> Just $ w & cameraRot -~ 0.01
|
||||
_ -> Just w
|
||||
handlePressedKey _ scancode w
|
||||
| scancode == escapeKey (_keyConfig w) = Nothing
|
||||
| scancode == pauseKey (_keyConfig w) = Just $ pauseGame $ escapeMap w
|
||||
| scancode == dropItemKey (_keyConfig w) = Just $ dropItem w
|
||||
| scancode == toggleMapKey (_keyConfig w) = Just $ toggleMap w
|
||||
| scancode == reloadKey (_keyConfig w) = Just $ fromMaybe w $ reloadWeapon (_yourID w) w
|
||||
| scancode == testEventKey (_keyConfig w) = Just $ testEvent w
|
||||
| scancode == spaceActionKey (_keyConfig w) = Just $ spaceAction w
|
||||
-- Rotation seems to be duplicated here and in Camera.hs ? why
|
||||
| scancode == rotateCameraPlusKey (_keyConfig w) = Just $ w {_cameraRot = _cameraRot w + 0.01}
|
||||
| scancode == rotateCameraMinusKey (_keyConfig w) = Just $ w {_cameraRot = _cameraRot w - 0.01}
|
||||
handlePressedKey _ _ w = Just w
|
||||
|
||||
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case listToMaybe $ _closeActiveObjects w of
|
||||
@@ -48,20 +50,4 @@ pauseGame :: World -> World
|
||||
pauseGame w = w {_menuState = PauseMenu}
|
||||
|
||||
toggleMap w = w & carteDisplay %~ not
|
||||
escapeMap w = w & carteDisplay .~ False
|
||||
|
||||
-- Basic key remapping for a dvorak key layout
|
||||
keyremap :: Keycode -> Keycode
|
||||
keyremap KeycodeComma = KeycodeW
|
||||
keyremap KeycodeA = KeycodeA
|
||||
keyremap KeycodeE = KeycodeD
|
||||
keyremap KeycodeO = KeycodeS
|
||||
keyremap KeycodeSlash = KeycodeQ
|
||||
keyremap KeycodePeriod = KeycodeE
|
||||
keyremap KeycodeP = KeycodeR
|
||||
keyremap KeycodeU = KeycodeF
|
||||
keyremap k = k
|
||||
|
||||
keyremapDefault :: Keycode -> Keycode
|
||||
keyremapDefault k = k
|
||||
|
||||
escapeMap w = w & carteDisplay .~ False
|
||||
Reference in New Issue
Block a user