Copyright | (c) David Janssen 2019 |
---|---|
License | MIT |
Maintainer | janssen.dhj@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
A button contains 2 actions, one to perform on press, and another to perform on release. This module contains that definition, and some helper code that helps combine buttons. It is here that most of the complicated` buttons are implemented (like TapHold).
Synopsis
- data Button
- class HasButton c where
- button :: Lens' c Button
- pressAction :: Lens' c Action
- releaseAction :: Lens' c Action
- onPress :: AnyK () -> Button
- mkButton :: AnyK () -> AnyK () -> Button
- around :: Button -> Button -> Button
- tapOn :: Switch -> Button -> Button
- emitB :: Keycode -> Button
- modded :: Keycode -> Button -> Button
- layerToggle :: LayerTag -> Button
- layerSwitch :: LayerTag -> Button
- layerAdd :: LayerTag -> Button
- layerRem :: LayerTag -> Button
- pass :: Button
- cmdButton :: Text -> Button
- aroundNext :: Button -> Button
- layerDelay :: Milliseconds -> LayerTag -> Button
- layerNext :: LayerTag -> Button
- tapHold :: Milliseconds -> Button -> Button -> Button
- multiTap :: Button -> [(Milliseconds, Button)] -> Button
- tapNext :: Button -> Button -> Button
- tapHoldNext :: Milliseconds -> Button -> Button -> Button
- tapNextRelease :: Button -> Button -> Button
- tapHoldNextRelease :: Milliseconds -> Button -> Button -> Button
- tapMacro :: [Button] -> Button
Button basics
This section contains the basic definition of KMonad's Button
datatype. A
Button
is essentially a collection of 2 different actions, 1 to perform on
Press
and another on Release
.
class HasButton c where Source #
button :: Lens' c Button Source #
pressAction :: Lens' c Action Source #
releaseAction :: Lens' c Action Source #
Create a new button from 2 buttons, an inner and an outer. When the new button is pressed, first the outer is pressed, then the inner. On release, the inner is released first, and then the outer.
Create a new button that performs both a press and release of the input button on just a press or release
Simple buttons
A collection of simple buttons. These are basically almost direct wrappings
around MonadK
functionality.
emitB :: Keycode -> Button Source #
A button that emits a Press of a keycode when pressed, and a release when released.
layerToggle :: LayerTag -> Button Source #
Create a button that toggles a layer on and off
layerSwitch :: LayerTag -> Button Source #
Create a button that switches the base-layer on a press
layerRem :: LayerTag -> Button Source #
Create a button that removes the top instance of a layer on a press
Button combinators
layerDelay :: Milliseconds -> LayerTag -> Button Source #
Switch to a layer for a period of time, then automatically switch back
layerNext :: LayerTag -> Button Source #
Switch to a layer for the next button-press and switch back automaically.
NOTE: liable to change, this is essentially just aroundNext
and
layerToggle
combined.
tapHold :: Milliseconds -> Button -> Button -> Button Source #
Create a Button
that performs a tap of one button if it is released
within an interval. If the interval is exceeded, press the other button (and
release it when a release is detected).
tapNext :: Button -> Button -> Button Source #
Create a Button
that performs a tap of 1 button if the next event is its
own release, or else switches to holding some other button if the next event
is a different keypress.
tapHoldNext :: Milliseconds -> Button -> Button -> Button Source #
Like tapNext
, except that after some interval it switches anyways
tapNextRelease :: Button -> Button -> Button Source #
Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.
It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.
tapHoldNextRelease :: Milliseconds -> Button -> Button -> Button Source #
Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.
If we encounter the timeout before any other release, we switch to holding mode.
It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.