Copyright | (c) David Janssen 2019 |
---|---|
License | MIT |
Maintainer | janssen.dhj@gmail.com |
Stability | experimental |
Portability | non-portable (MPTC with FD, FFI to Linux-only c-code) |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype LinuxKeyEvent = LinuxKeyEvent (CInt, CInt, CInt, CInt, CInt)
- linuxKeyEvent :: (Integral a, Integral b, Integral c, Integral d, Integral e) => (a, b, c, d, e) -> LinuxKeyEvent
- sync :: SystemTime -> LinuxKeyEvent
- toLinuxKeyEvent :: KeyEvent -> SystemTime -> LinuxKeyEvent
- fromLinuxKeyEvent :: LinuxKeyEvent -> Maybe KeyEvent
- module KMonad.Keyboard
- module KMonad.Keyboard.IO
The LinuxKeyEvent datatype, its constructors, and instances
Linux produces a stream of binary data representing all its input events through the /dev/input files. Each event is represented by 5 numbers: seconds, microseconds, event-type, event-code, and event-value. For more explanation look at: https://www.kernel.org/doc/Documentation/input/input.txt
newtype LinuxKeyEvent Source #
The LinuxKeyEvent datatype
Instances
Show LinuxKeyEvent Source # | |
Defined in KMonad.Keyboard.IO.Linux.Types showsPrec :: Int -> LinuxKeyEvent -> ShowS # show :: LinuxKeyEvent -> String # showList :: [LinuxKeyEvent] -> ShowS # | |
Display LinuxKeyEvent Source # | |
Defined in KMonad.Keyboard.IO.Linux.Types display :: LinuxKeyEvent -> Utf8Builder # textDisplay :: LinuxKeyEvent -> Text # |
:: (Integral a, Integral b, Integral c, Integral d, Integral e) | |
=> (a, b, c, d, e) | The tuple representing the event |
-> LinuxKeyEvent | The LinuxKeyEvent |
A smart constructor that casts from any integral
sync :: SystemTime -> LinuxKeyEvent Source #
Constructor for linux sync events. Whenever you write an event to linux,
you need to emit a sync
to signal to linux that it should sync all queued
updates.
Casting between KeyEvent
and LinuxKeyEvent
We only represent a subset of all the possible input events produced by Linux. First of all, we disregard all event types that are not key events, so we quietly ignore all sync and scan events. There other other events that are there to do things like toggle LEDs on your keyboard that we also ignore.
Furthermore, within the category of KeyEvents, we only register presses and releases, and completely ignore repeat events.
The correspondence between LinuxKeyEvents and core KeyEvents can best be read
in the above-mentioned documentation, but the quick version is this:
Typ: 1 = KeyEvent (see below)
4 = scancode
event (we neither read nor write)
0 = sync
event (we don't read, but do generate for writing)
Val: for keys: 0 = Release, 1 = Press, 2 = Repeat
for sync: always 0
Code: for keys: an Int value corresponding to a keycode
see: https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h
for sync: always 0
toLinuxKeyEvent :: KeyEvent -> SystemTime -> LinuxKeyEvent Source #
Translate kmonad KeyEvent
along with a SystemTime
to LinuxKeyEvent
s
for writing.
fromLinuxKeyEvent :: LinuxKeyEvent -> Maybe KeyEvent Source #
Translate a LinuxKeyEvent
to a kmonad KeyEvent
Reexport common modules
module KMonad.Keyboard
module KMonad.Keyboard.IO