Visitar URL original
Control.Keymapp.Client
keymapp
Safe HaskellNone
LanguageHaskell2010

Control.Keymapp.Client

Description

This module provides a monad for interacting with the Keymapp API, and functions for calling its endpoints via gRPC.

Synopsis

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

Instances details
MonadCatch m => MonadCatch (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

catch :: (HasCallStack, Exception e) => KeymappClient m a -> (e -> KeymappClient m a) -> KeymappClient m a #

MonadMask m => MonadMask (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

mask :: HasCallStack => ((forall a. KeymappClient m a -> KeymappClient m a) -> KeymappClient m b) -> KeymappClient m b #

uninterruptibleMask :: HasCallStack => ((forall a. KeymappClient m a -> KeymappClient m a) -> KeymappClient m b) -> KeymappClient m b #

generalBracket :: HasCallStack => KeymappClient m a -> (a -> ExitCase b -> KeymappClient m c) -> (a -> KeymappClient m b) -> KeymappClient m (b, c) #

MonadThrow m => MonadThrow (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

throwM :: (HasCallStack, Exception e) => e -> KeymappClient m a #

Applicative m => Applicative (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

pure :: a -> KeymappClient m a #

(<*>) :: KeymappClient m (a -> b) -> KeymappClient m a -> KeymappClient m b #

liftA2 :: (a -> b -> c) -> KeymappClient m a -> KeymappClient m b -> KeymappClient m c #

(*>) :: KeymappClient m a -> KeymappClient m b -> KeymappClient m b #

(<*) :: KeymappClient m a -> KeymappClient m b -> KeymappClient m a #

Functor m => Functor (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

fmap :: (a -> b) -> KeymappClient m a -> KeymappClient m b #

(<$) :: a -> KeymappClient m b -> KeymappClient m a #

Monad m => Monad (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(>>=) :: KeymappClient m a -> (a -> KeymappClient m b) -> KeymappClient m b #

(>>) :: KeymappClient m a -> KeymappClient m b -> KeymappClient m b #

return :: a -> KeymappClient m a #

MonadFail m => MonadFail (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

fail :: String -> KeymappClient m a #

MonadIO m => MonadIO (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

liftIO :: IO a -> KeymappClient m a #

(MonadIO m, MonadMask m) => CanCallRPC (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

MonadUnliftIO m => MonadUnliftIO (KeymappClient m) Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

withRunInIO :: ((forall a. KeymappClient m a -> IO a) -> IO b) -> KeymappClient m b #

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

data Keyboard Source #

Details of a keyboard as returned by the getKeyboards endpoint.

Constructors

Keyboard 

Instances

Instances details
Show Keyboard Source # 
Instance details

Defined in Control.Keymapp.Client

Eq Keyboard Source # 
Instance details

Defined in Control.Keymapp.Client

data ConnectedKeyboard Source #

Details of the connected keyboard as returned by the getStatus endpoint.

data Status Source #

Status of the API as returned by the getStatus endpoint.

Instances

Instances details
Show Status Source # 
Instance details

Defined in Control.Keymapp.Client

Eq Status Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(==) :: Status -> Status -> Bool #

(/=) :: Status -> Status -> Bool #

newtype Success Source #

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.

Constructors

Success 

Fields

Instances

Instances details
Monoid Success Source # 
Instance details

Defined in Control.Keymapp.Client

Semigroup Success Source # 
Instance details

Defined in Control.Keymapp.Client

Show Success Source # 
Instance details

Defined in Control.Keymapp.Client

Eq Success Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(==) :: Success -> Success -> Bool #

(/=) :: Success -> Success -> Bool #

newtype On Source #

Boolean newtype used by the setStatusLed* functions. Indicates whether a status LED should be turned on or off.

Constructors

On 

Fields

Instances

Instances details
Show On Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

showsPrec :: Int -> On -> ShowS #

show :: On -> String #

showList :: [On] -> ShowS #

Eq On Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(==) :: On -> On -> Bool #

(/=) :: On -> On -> Bool #

newtype KeyboardId Source #

The ID of a keyboard, as returned by the list endpoints (getKeyboards).

Constructors

KeyboardId 

Fields

Instances

Instances details
Enum KeyboardId Source # 
Instance details

Defined in Control.Keymapp.Client

Num KeyboardId Source # 
Instance details

Defined in Control.Keymapp.Client

Show KeyboardId Source # 
Instance details

Defined in Control.Keymapp.Client

Eq KeyboardId Source # 
Instance details

Defined in Control.Keymapp.Client

Ord KeyboardId Source # 
Instance details

Defined in Control.Keymapp.Client

newtype LED Source #

The index of an LED.

Mapping on a ZSA Moonlander MK1:

012345636373839404142
7891011121343444546474849
1415161718192050515253545556
212223242526575859606162
27282930316364656667
3268
333435697071

Constructors

LED 

Fields

Instances

Instances details
Enum LED Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

succ :: LED -> LED #

pred :: LED -> LED #

toEnum :: Int -> LED #

fromEnum :: LED -> Int #

enumFrom :: LED -> [LED] #

enumFromThen :: LED -> LED -> [LED] #

enumFromTo :: LED -> LED -> [LED] #

enumFromThenTo :: LED -> LED -> LED -> [LED] #

Num LED Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(+) :: LED -> LED -> LED #

(-) :: LED -> LED -> LED #

(*) :: LED -> LED -> LED #

negate :: LED -> LED #

abs :: LED -> LED #

signum :: LED -> LED #

fromInteger :: Integer -> LED #

Show LED Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

showsPrec :: Int -> LED -> ShowS #

show :: LED -> String #

showList :: [LED] -> ShowS #

Eq LED Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(==) :: LED -> LED -> Bool #

(/=) :: LED -> LED -> Bool #

Ord LED Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

compare :: LED -> LED -> Ordering #

(<) :: LED -> LED -> Bool #

(<=) :: LED -> LED -> Bool #

(>) :: LED -> LED -> Bool #

(>=) :: LED -> LED -> Bool #

max :: LED -> LED -> LED #

min :: LED -> LED -> LED #

newtype Layer Source #

The index of a layer.

Constructors

Layer 

Fields

Instances

Instances details
Enum Layer Source # 
Instance details

Defined in Control.Keymapp.Client

Num Layer Source # 
Instance details

Defined in Control.Keymapp.Client

Show Layer Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

showsPrec :: Int -> Layer -> ShowS #

show :: Layer -> String #

showList :: [Layer] -> ShowS #

Eq Layer Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

(==) :: Layer -> Layer -> Bool #

(/=) :: Layer -> Layer -> Bool #

Ord Layer Source # 
Instance details

Defined in Control.Keymapp.Client

Methods

compare :: Layer -> Layer -> Ordering #

(<) :: Layer -> Layer -> Bool #

(<=) :: Layer -> Layer -> Bool #

(>) :: Layer -> Layer -> Bool #

(>=) :: Layer -> Layer -> Bool #

max :: Layer -> Layer -> Layer #

min :: Layer -> Layer -> Layer #

newtype Sustain Source #

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.

Constructors

Sustain 

Fields

Utils

defaultKeymappSocket :: MonadIO m => m Server Source #

The default Keymapp server runs at ~.configkeymapp/keymapp.socket