From ac056ba43192bd3c2cbe90d8c8c3d903985a52dd Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 22 Dec 2024 12:54:22 +0530 Subject: Updates docs --- README.md | 25 ++++++++++++++++++++++++- TODO.norg | 3 ++- src/Chelleport.hs | 11 ++++++++++- src/Chelleport/Context.hs | 5 ++--- src/Chelleport/KeySequence.hs | 2 +- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ecd37a9..2fc1a49 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,27 @@ # Chelleport +Control your mouse pointer with your keyboard -Use your mouse with your keyboard. +> Note: Only supports Linux running X11 display server currently because that's what I use. Might support more if there's interest. + +https://github.com/user-attachments/assets/93ddc1ff-6cbe-4be4-9507-d68de880212a + + +## Install +- Clone the repo and build it yourself: `cabal build chelleport` +- Nix flakes users can try it out by running: `nix run github:phenax/chelleport#chelleport` + + +## Usage +- Use [sxhkd](https://github.com/baskerville/sxhkd), [shotkey](https://github.com/phenax/shotkey), your window manager or any other key binding manager to set up a keybinding for `chelleport` +- With the grid open, type any of the key sequences shown on the grid to move the pointer there +- Once there, you can now use `hjkl` keys to make smaller movements. Hold `shift` to move in bigger increments. +- Press `space` to click + + +## Features +- **Click**: Pressing `space` left clicks at current mouse position. Holding `shift` key left clicks and show the grid again. +- **Select text/Drag-n-drop**: Pressing `Ctrl+V` starts dragging/selecting/holding down left mouse button. Press `space` to stop dragging. Or press `Ctrl+V` again to stop dragging and show the grid again. +- **Double click**: Pressing `2` followed by `space` will click twice. Any digit key followed by `space` will click that many times. +- **Right click**: Pressing `minus` key right clicks at current mouse position. Holding `shift` key right clicks and shows the grid again. +- **Granular movement**: Once you match with a label on the screen, you can use `hjkl` keys to move your cursor. Holding `shift` key will use bigger steps for movements. You can also repeat movement by pressing a digit before the movement. Eg: `5k` moves 5 small steps up. `5K` moves 5 big steps up. diff --git a/TODO.norg b/TODO.norg index 0d326d1..7e3ce15 100644 --- a/TODO.norg +++ b/TODO.norg @@ -3,7 +3,8 @@ * Later - ( ) Look into making controls cross-platform (remove x11?) - - ( ) Switch to {test-fixture}[https://hackage.haskell.org/package/test-fixture] + - ( ) Switch to [test-fixture]{https://hackage.haskell.org/package/test-fixture} * Maybe - ( ) Scroll + - ( ) Process mode? Run in bg and handle key binding to toggle 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] -- cgit v1.3.1