| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Keymapp.Client
Description
This module provides a monad for interacting with the Keymapp API, and functions for calling its endpoints via gRPC.
Synopsis
- data KeymappClient (m :: Type -> Type) a
- runClient :: MonadUnliftIO m => ConnParams -> Server -> KeymappClient m a -> m a
- getStatus :: CanCallRPC m => m Status
- getKeyboards :: CanCallRPC m => m [Keyboard]
- connectKeyboard :: CanCallRPC m => KeyboardId -> m Success
- connectAnyKeyboard :: CanCallRPC m => m Success
- disconnectKeyboard :: CanCallRPC m => m Success
- setLayer :: CanCallRPC m => Layer -> m Success
- unsetLayer :: CanCallRPC m => Layer -> m Success
- setRGBLed :: CanCallRPC m => LED -> Colour Double -> Sustain -> m Success
- setRGBAll :: CanCallRPC m => Colour Double -> Sustain -> m Success
- setStatusLed :: CanCallRPC m => LED -> On -> Sustain -> m Success
- increaseBrightness :: CanCallRPC m => m Success
- decreaseBrightness :: CanCallRPC m => m Success
- restoreRGBLeds :: CanCallRPC m => m Success
- restoreStatusLeds :: CanCallRPC m => m Success
- setStatusLedAll :: CanCallRPC m => On -> Sustain -> m Success
- data Keyboard = Keyboard {
- id :: !KeyboardId
- friendlyName :: !Text
- isConnected :: !Bool
- data ConnectedKeyboard = ConnectedKeyboard {
- friendlyName :: !Text
- firmwareVersion :: !Text
- currentLayer :: !Layer
- data Status = Status {}
- newtype Success = Success {}
- newtype On = On {}
- newtype KeyboardId = KeyboardId {}
- newtype LED = LED {}
- newtype Layer = Layer {}
- newtype Sustain = Sustain {}
- defaultKeymappSocket :: MonadIO m => m Server
Monad transformer
data KeymappClient (m :: Type -> Type) a Source #
A monad transformer for calling the Keymapp API. Basically just hides the details of the connection to the gRPC server.
TODO: catch errors?
Instances
runClient :: MonadUnliftIO m => ConnParams -> Server -> KeymappClient m a -> m a Source #
Run a KeymappClient action using gRPC connection details (see the grapesy documentation for more details).
To get the standard Server details, see defaultKeymappSocket.
Core commands
These functions are more or less a one-to-one-translation from the protobuf specification of the API.
getStatus :: CanCallRPC m => m Status Source #
Get the status of the Keymapp API, including the connected keyboard.
getKeyboards :: CanCallRPC m => m [Keyboard] Source #
List all the keyboards connected to your computer that the Keymapp server can talk to.
connectKeyboard :: CanCallRPC m => KeyboardId -> m Success Source #
Connect to a specific keyboard. The KeyboardId is an index from the list that getKeyboards returns.
connectAnyKeyboard :: CanCallRPC m => m Success Source #
Connect to the first keyboard detected by the Keymapp server.
disconnectKeyboard :: CanCallRPC m => m Success Source #
Disconnect from the currently connected keyboard.
setLayer :: CanCallRPC m => Layer -> m Success Source #
Set the layer of the currently connected keyboard.
unsetLayer :: CanCallRPC m => Layer -> m Success Source #
Unset the layer of the currently connected keyboard.
setRGBLed :: CanCallRPC m => LED -> Colour Double -> Sustain -> m Success Source #
Sets the RGB color of a LED.
setRGBAll :: CanCallRPC m => Colour Double -> Sustain -> m Success Source #
Sets the RGB color of all LEDs.
setStatusLed :: CanCallRPC m => LED -> On -> Sustain -> m Success Source #
Set / unset a status LED.
increaseBrightness :: CanCallRPC m => m Success Source #
Increase the brightness of the keyboard's LEDs.
decreaseBrightness :: CanCallRPC m => m Success Source #
Decrease the brightness of the keyboard's LEDs.
Derived commands
These operations aren't defined by the Keymapp API, but are provided for convenience and mostly inspired by functions in Kontroll.
restoreRGBLeds :: CanCallRPC m => m Success Source #
Restores the RGB color of all LEDs to their default.
restoreStatusLeds :: CanCallRPC m => m Success Source #
Restores all status LEDs to their default.
setStatusLedAll :: CanCallRPC m => On -> Sustain -> m Success Source #
Set / unset all status LEDs.
Types
Details of a keyboard as returned by the getKeyboards endpoint.
Constructors
| Keyboard | |
Fields
| |
data ConnectedKeyboard Source #
Details of the connected keyboard as returned by the getStatus endpoint.
Constructors
| ConnectedKeyboard | |
Fields
| |
Instances
| Show ConnectedKeyboard Source # | |
Defined in Control.Keymapp.Client Methods showsPrec :: Int -> ConnectedKeyboard -> ShowS # show :: ConnectedKeyboard -> String # showList :: [ConnectedKeyboard] -> ShowS # | |
| Eq ConnectedKeyboard Source # | |
Defined in Control.Keymapp.Client Methods (==) :: ConnectedKeyboard -> ConnectedKeyboard -> Bool # (/=) :: ConnectedKeyboard -> ConnectedKeyboard -> Bool # | |
Most of the Keymapp server endpoints return a boolean success value without any additional information.
We derive Semigroup and Monoid instances via All. In other words if we do a bunch of operations,
we define the overall operation to be a success only if all of the operations succeeded.
Boolean newtype used by the setStatusLed* functions. Indicates whether a status LED should be turned on or off.
newtype KeyboardId Source #
The ID of a keyboard, as returned by the list endpoints (getKeyboards).
Constructors
| KeyboardId | |
Instances
The index of an LED.
Mapping on a ZSA Moonlander MK1:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | |
| 21 | 22 | 23 | 24 | 25 | 26 | 57 | 58 | 59 | 60 | 61 | 62 | |||
| 27 | 28 | 29 | 30 | 31 | 63 | 64 | 65 | 66 | 67 | |||||
| 32 | 68 | |||||||||||||
| 33 | 34 | 35 | 69 | 70 | 71 |
The index of a layer.
Delay in milliseconds. This is used for most of the endpoints that change lights and colours - if the sustain is set to 0, the change is permanent; otherwise, a sustain of X means the change will last for X milliseconds and then revert.
Instances
| Enum Sustain Source # | |
| Num Sustain Source # | |
| Show Sustain Source # | |
| Eq Sustain Source # | |
| Ord Sustain Source # | |
Defined in Control.Keymapp.Client | |
Utils
defaultKeymappSocket :: MonadIO m => m Server Source #
The default Keymapp server runs at ~.configkeymapp/keymapp.socket