Copyright (c) David Janssen 2019 MIT janssen.dhj@gmail.com experimental non-portable (MPTC with FD, FFI to Linux-only c-code) None Haskell2010

Description

Synopsis

# 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

Constructors

 LinuxKeyEvent (CInt, CInt, CInt, CInt, CInt)

#### Instances

Instances details
 Source # Instance detailsDefined in KMonad.Keyboard.IO.Linux.Types MethodsshowList :: [LinuxKeyEvent] -> ShowS # Source # Instance detailsDefined in KMonad.Keyboard.IO.Linux.Types Methods

Arguments

 :: (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

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

Translate kmonad KeyEvent along with a SystemTime to LinuxKeyEvents for writing.

Translate a LinuxKeyEvent to a kmonad KeyEvent