Plugin: Input Device

This plugin makes input devices (keyboard, mouse, gamepad, remote control...) available as entities using linux evdev.

Use cases

  • Global Hotkeys
    • Running basic functions (server list, chat, ...) in background
    • No window have to be open or minimized
  • Home Automation
    • Use a real keyboard (for example a wireless numpad keyboards) as interface to control flows
  • Robotics
    • Control your robot with keys or a 3d mouse

Event Types

  • Key (List)
    • Keyboard Key
    • Mouse Button
  • Led (List)
    • Keyboard Led
  • Relative Axis (List)
    • Mouse Position XY
    • Mouse Wheels
    • Volume Wheels on Keyboards
  • Absolute Axis (List)
    • Joysticks
  • Switch (List)
    • Lid shut
    • Microphone Jack inserted
    • Camera lens covered
    • Front proximity sensor active
    • Cover closed

Entity Instances

Entity instances represents a key/led/... and each can be addressed using a stable UUID (by device name and key/led/... id) or a stable human-readable label.

query getKeyStateF7 {
  instances {
    entities(label: "/org/inexor/input/any_device/key/key_f7") {
      label
      properties(name: "key_down") {
        value
      }
    }
  }
}

"Specific Device" and "Any Device"

Each event is forwarded twice:

DeviceEventEntity Instance Label
keyboard1key_f7
  • /org/inexor/input/keyboard1/key/key_f7
  • /org/inexor/input/any_device/key/key_f7
keyboard2key_f7
  • /org/inexor/input/keyboard1/key/key_f7
  • /org/inexor/input/any_device/key/key_f7

This allows you to address a key/led/... event on a specific device or the key/led/... event on all devices.

Type System

Inexor

Entity Types

NamePropertyData TypeSocket Type
InputDevicenamestringoutput
eventobjectoutput
physical_pathstringoutput
driver_versionstringoutput
vendornumberoutput
productnumberoutput
versionnumberoutput
InputDeviceKeykeystringnone
key_codenumbernone
key_downbooloutput
InputDeviceLedledstringnone
led_typenumbernone
statebooloutput
InputDeviceRelativeAxisrelative_axisstringnone
relative_axis_typenumbernone
statenumberoutput
InputDeviceAbsoluteAxisabsolute_axisstringnone
absolute_axis_typenumbernone
statenumberoutput
InputDeviceSwitchswitchstringnone
switch_typenumbernone
statenumberoutput

Relation Types

NameOutbound Entity TypeInbound Entity Type
KeyEventInputDeviceInputDeviceKey
LedEventInputDeviceInputDeviceLed
RelativeAxisEventInputDeviceInputDeviceRelativeAxis
AbsoluteAxisEventInputDeviceInputDeviceAbsoluteAxis
SwitchEventInputDeviceInputDeviceSwitch

Entity Behaviours

NameDescription
InputDeviceStreams input events from evdev and sets the entity instance property event

Relation Behaviours

NameDescription
KeyEventPropagates input events and filters by event type (key event) and key code defined by the inbound entity instance
LedEventPropagates input events and filters by event type (led event) and led type defined by the inbound entity instance
RelativeAxisEventPropagates input events and filters by event type (relative axis event) and relative axis type defined by the inbound entity instance
AbsoluteAxisEventPropagates input events and filters by event type (absolute axis event) and absolute axis type defined by the inbound entity instance
SwitchEventPropagates input events and filters by event type (switch event) and switch type defined by the inbound entity instance

Rust Crate / Rust Reference

  • https://github.com/emberian/evdev/ (Linux only)
  • https://www.freedesktop.org/software/libevdev/doc/latest/

Platform Compatibility

PlatformCompatibility
Linux
MacOSx
Windowsx

Repository

NameRepository
inexor-rgf-plugin-input-devicehttps://github.com/inexorgame/inexor-rgf-plugin-input-device

Appendix: Input Device Types

Keys

A key changed state. A key, or button, is usually a momentary switch (in the circuit sense). It has two states: down, or up. There are events for when keys are pressed (become down) and released (become up). There are also “key repeats”, where multiple events are sent while a key is down.

NameDescription
KEY_RESERVED
KEY_ESC
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_0
KEY_MINUS
KEY_EQUAL
KEY_BACKSPACE
KEY_TAB
KEY_Q
KEY_W
KEY_E
KEY_R
KEY_T
KEY_Y
KEY_U
KEY_I
KEY_O
KEY_P
KEY_LEFTBRACE
KEY_RIGHTBRACE
KEY_ENTER
KEY_LEFTCTRL
KEY_A
KEY_S
KEY_D
KEY_F
KEY_G
KEY_H
KEY_J
KEY_K
KEY_L
KEY_SEMICOLON
KEY_APOSTROPHE
KEY_GRAVE
KEY_LEFTSHIFT
KEY_BACKSLASH
KEY_Z
KEY_X
KEY_C
KEY_V
KEY_B
KEY_N
KEY_M
KEY_COMMA
KEY_DOT
KEY_S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APPY28
BTN_TRIGGER_HAPPY29
BTN_TRIGGER_HAPPY30
BTN_TRIGGER_HAPPY31
BTN_TRIGGER_HAPPY32
BTN_TRIGGER_HAPPY33
BTN_TRIGGER_HAPPY34
BTN_TRIGGER_HAPPY35
BTN_TRIGGER_HAPPY36
BTN_TRIGGER_HAPPY37
BTN_TRIGGER_HAPPY38
BTN_TRIGGER_HAPPY39
BTN_TRIGGER_HAPPY40

LEDs

An LED was toggled.

NameDescription
LED_NUML
LED_CAPSL
LED_SCROLLL
LED_COMPOSE
LED_KANA
LED_SLEEPStand-by
LED_SUSPEND
LED_MUTE
LED_MISCGeneric indicator
LED_MAILMessage waiting
LED_CHARGINGExternal power connected

Relative Axes

Movement on a relative axis. There is no absolute coordinate frame, just the fact that there was a change of a certain amount of units. Used for things like mouse movement or scroll wheels.

NameDescription
REL_X
REL_Y
REL_Z
REL_RX
REL_RY
REL_RZ
REL_HWHEEL
REL_DIAL
REL_WHEEL
REL_MISC
REL_RESERVED
REL_WHEEL_HI_RES
REL_HWHEEL_HI_RES

Absolute Axes

Movement on an absolute axis. Used for things such as touch events and joysticks.

NameDescription
ABS_X
ABS_Y
ABS_Z
ABS_RX
ABS_RY
ABS_RZ
ABS_THROTTLE
ABS_RUDDER
ABS_WHEEL
ABS_GAS
ABS_BRAKE
ABS_HAT0X
ABS_HAT0Y
ABS_HAT1X
ABS_HAT1Y
ABS_HAT2X
ABS_HAT2Y
ABS_HAT3X
ABS_HAT3Y
ABS_PRESSURE
ABS_DISTANCE
ABS_TILT_X
ABS_TILT_Y
ABS_TOOL_WIDTH
ABS_VOLUME
ABS_MISC
ABS_MT_SLOTMT slot being modified
ABS_MT_TOUCH_MAJORMajor axis of touching ellipse
ABS_MT_TOUCH_MINORMinor axis (omit if circular)
ABS_MT_WIDTH_MAJORMajor axis of approaching ellipse
ABS_MT_WIDTH_MINORMinor axis (omit if circular)
ABS_MT_ORIENTATIONEllipse orientation
ABS_MT_POSITION_XCenter X touch position
ABS_MT_POSITION_YCenter Y touch position
ABS_MT_TOOL_TYPEType of touching device
ABS_MT_BLOB_IDGroup a set of packets as a blob
ABS_MT_TRACKING_IDUnique ID of the initiated contact
ABS_MT_PRESSUREPressure on contact area
ABS_MT_DISTANCEContact over distance
ABS_MT_TOOL_XCenter X tool position
ABS_MT_TOOL_YCenter Y tool position

Switches

Change in a switch value. Switches are boolean conditions and usually correspond to a toggle switch of some kind in hardware.

NameDescription
SW_LIDset = lid shut
SW_TABLET_MODEset = tablet mode
SW_HEADPHONE_INSERTset = inserted
SW_RFKILL_ALLrfkill master switch, type ‘any’
SW_MICROPHONE_INSERTset = inserted
SW_DOCKset = plugged into doc
SW_LINEOUT_INSERTset = inserted
SW_JACK_PHYSICAL_INSERTset = mechanical switch set
SW_VIDEOOUT_INSERTset = inserted
SW_CAMERA_LENS_COVERset = lens covered
SW_KEYPAD_SLIDEset = keypad slide out
SW_FRONT_PROXIMITYset = front proximity sensor active
SW_ROTATE_LOCKset = rotate locked/disabled
SW_LINEIN_INSERTset = inserted
SW_MUTE_DEVICEset = device disabled
SW_PEN_INSERTEDset = pen inserted
SW_MACHINE_COVERset = cover closed

Appendix: Shared Keys

Inexor

Inexor