aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Chelleport.hs11
-rw-r--r--src/Chelleport/Context.hs5
-rw-r--r--src/Chelleport/KeySequence.hs2
3 files changed, 13 insertions, 5 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs
index 9b96bbc..fe58259 100644
--- a/src/Chelleport.hs
+++ b/src/Chelleport.hs
@@ -59,26 +59,35 @@ eventHandler event =
case SDL.eventPayload event of
SDL.QuitEvent -> Just ShutdownApp
SDL.KeyboardEvent ev
+ -- Escape
| isKeyPressWith ev SDL.KeycodeEscape ->
Just ShutdownApp
+ -- minus / underscore
| isKeyPressWith ev SDL.KeycodeMinus || isKeyPressWith ev SDL.KeycodeUnderscore ->
if withShift ev
then Just $ ChainMouseClick RightClick
else Just $ TriggerMouseClick RightClick
+ -- 0-9
| isKeycodeDigit (eventToKeycode ev) ->
Just $ UpdateRepetition (fromMaybe 0 $ keycodeToInt $ eventToKeycode ev)
+ -- Space / Shift+Space
| isKeyPressWith ev SDL.KeycodeSpace ->
if withShift ev
then Just $ ChainMouseClick LeftClick
else Just $ TriggerMouseClick LeftClick
+ -- Tab / Backspace
| isKeyPressWith ev SDL.KeycodeTab || isKeyPressWith ev SDL.KeycodeBackspace ->
Just ResetKeys
+ -- Ctrl + V
| withCtrl ev && isKeyPressWith ev SDL.KeycodeV ->
Just MouseDragToggle
+ -- A-Z
| isKeyPressed ev && isValidKey (eventToKeycode ev) ->
Just $ HandleKeyInput $ eventToKeycode ev
+ -- Shift press
| isKeyPressWith ev SDL.KeycodeLShift || isKeyPressWith ev SDL.KeycodeRShift ->
Just $ UpdateShiftState True
+ -- Shift release
| isKeyReleaseWith ev SDL.KeycodeLShift || isKeyReleaseWith ev SDL.KeycodeRShift ->
Just $ UpdateShiftState False
_ -> Nothing
@@ -171,7 +180,7 @@ update state MouseDragEnd = do
showWindow
pure (state {stateRepetition = 1}, Nothing)
--- Set/unset whether shift is pressed
+-- Set repetition count
update state (UpdateRepetition count) = do
pure (state {stateRepetition = count}, Nothing)
diff --git a/src/Chelleport/Context.hs b/src/Chelleport/Context.hs
index 45c90d4..6452e86 100644
--- a/src/Chelleport/Context.hs
+++ b/src/Chelleport/Context.hs
@@ -1,11 +1,10 @@
module Chelleport.Context (initializeContext) where
--- import Data.Time.Clock.System
--- import qualified Debug.Trace as Debug
-
import Chelleport.Config
import Chelleport.Types
import Data.ByteString (ByteString)
+-- import Data.Time.Clock.System
+-- import qualified Debug.Trace as Debug
import Data.FileEmbed (embedFileRelative)
import qualified Graphics.X11 as X11
import SDL (($=))
diff --git a/src/Chelleport/KeySequence.hs b/src/Chelleport/KeySequence.hs
index 9f1f26a..fd8eaa7 100644
--- a/src/Chelleport/KeySequence.hs
+++ b/src/Chelleport/KeySequence.hs
@@ -5,7 +5,7 @@ import Chelleport.Utils (findWithIndex, uniq)
import Control.Monad (guard)
import Data.List (elemIndex, isPrefixOf)
import qualified Data.Map as Map
-import Data.Maybe (fromMaybe, isJust)
+import Data.Maybe (isJust)
import qualified SDL
nextChars :: KeySequence -> KeyGrid -> Maybe [Char]