DEKI/ENGINE docs
manual api reference
deki-input 0.40.1
Deki package reference
deki-input

Input handling and collision detection

Repository: github.com/dekiengine/deki-input · Latest release: 0.40.0 · Needs engine 0.40.0+

Install with DekiEditor --packages-add deki-input <project>, or from the Package Manager. The engine's own components and C++ API are in the Deki docs.

Shown in the editor as Input.

Components

Component Category Description
I2CKeyboardComponent Input Reads a keyboard that hands over one typed character per I2C read: the LilyGO T-Deck's, the M5Stack CardKB.
InputCollider Input Hit area for pointer and touch. Buttons and scrolls listen to it.
TrackballComponent Input A trackball on GPIO pins, as arrow keys and Enter or as a pointer.

Feature flags

Parts you can leave out of a build. A feature with a define is switched there; the rest are stripped with their components.

Feature Define Default
Colliders DEKI_FEATURE_INPUT on
I2C Keyboard DEKI_FEATURE_INPUT_I2C_KEYBOARD on
Trackball DEKI_FEATURE_INPUT_TRACKBALL on

Component reference

I2CKeyboardComponent

Reads a keyboard that hands over one typed character per I2C read: the LilyGO T-Deck's, the M5Stack CardKB.

Inspector name: I2C Keyboard · Category: Input · Type: DekiInput::I2CKeyboardComponent

Property Type Default Constraints Description
i2cPort int32 0 0 to 3 Which I2C bus the keyboard is on. Must match the I2C Bus component that set that port up.
i2cAddress int32 85 0 to 127 The keyboard's address on the bus: 0x55 (85) for the LilyGO T-Deck, 0x5F (95) for the M5Stack CardKB.
hasBacklight bool false The keyboard has a backlight it controls itself, set over the bus (the LilyGO T-Deck's: brightness in register 0x01). Game code then sets it with I2CKeyboard::SetBacklight.
reportHeldKeys bool false The LilyGO T-Deck's keyboard: read its whole key matrix, so a key is down for as long as it is held, as a desktop keyboard's is. A game can then walk while a key is held. Needs keyboard firmware with the matrix mode (register 0x03); off, each typed key is down for one frame.

InputCollider

Hit area for pointer and touch. Buttons and scrolls listen to it.

Inspector name: Input Collider · Category: Input · Type: DekiInput::InputCollider

Property Type Default Constraints Description
width float 0 in m Width of the hit area in meters. It does not have to match what is drawn.
height float 0 in m Height of the hit area in meters.
paddingLeft float 0 in m Extra hit area beyond the left edge, in meters. Useful for making a small control comfortable to hit with a finger without making it look bigger.
paddingRight float 0 in m Extra hit area beyond the right edge, in meters.
paddingTop float 0 in m Extra hit area above the top edge, in meters.
paddingBottom float 0 in m Extra hit area below the bottom edge, in meters.
consumeInput bool true Stop the press here instead of letting it reach objects underneath. Turn it off for an overlay that should not block what is behind it.

TrackballComponent

A trackball on GPIO pins, as arrow keys and Enter or as a pointer.

Inspector name: Trackball · Category: Input · Type: DekiInput::TrackballComponent

Property Type Default Constraints Description
mode enum "Keys" Keys, Pointer Keys: rolling presses the arrow keys and the click is Enter. Pointer: rolling moves a pointer and the click is a mouse button.
pixelsPerStep int32 4 1 to 64 Pointer mode: how many pixels one step of the ball moves the pointer
glideMs float 0 0 to 1000 Pointer mode: how long the pointer keeps gliding after the ball stops, in milliseconds, like a ThinkPad TrackPoint. 0 moves it exactly by the steps rolled.
acceleration float 1 1 to 8 Pointer mode with a glide: how many times further each step carries the pointer when the ball is spun fast than when it is rolled slowly. 1: no acceleration.
upPin int32 -1 -1 to 48 The line that pulses when the ball rolls up
downPin int32 -1 -1 to 48 The line that pulses when the ball rolls down
leftPin int32 -1 -1 to 48 The line that pulses when the ball rolls left
rightPin int32 -1 -1 to 48 The line that pulses when the ball rolls right
clickPin int32 -1 -1 to 48 The click switch (-1 = none)
clickActiveLow bool true The click pulls its pin low when pressed (on), or high (off)

Changelog

0.40.0

Changed

  • minEngine 0.40.0: built against engine 0.40.0. A build of this package from before does not load and is rebuilt.

Added

  • Sticks. DekiInput::GetStick(stick, &x, &y) says where an analog stick points (0 the left, 1 the right): x and y from -1 to 1, right and up positive, from the input source that has it pushed furthest. A driver reports its sticks with IDekiInput::GetStick, which reports none by default, so drivers without sticks need no change; a host feeds one through IInputSystem::DispatchStick. Sticks still send the arrow keys too, for games that only read keys.
  • DekiInput::RemoveInput(name), which shuts down and removes one input source.
  • DekiInput::BeginSession and EndSession. Everything registered after a session begins, sources and event callbacks, is removed when it ends. The editor brackets Play mode with them, so what a game adds goes when it stops.
  • Trackball::TakeRoll: how far the ball rolled since the last call, in either mode, so a game can steer with it while it moves the pointer. Trackball::Find() gets the one a TrackballComponent set up.
  • Report Held Keys on the I2C Keyboard: the LilyGO T-Deck's keyboard hands over its key matrix, so a key is down for as long as it is held and comes up when it is let go, as a desktop keyboard's does. Off by default: it needs keyboard firmware with the matrix mode (register 0x03).
  • DispatchPointer (Deki::IInputSystem): a host's pointer, in the game screen's pixels, sent as an input event from a source named "Injected pointer".

Fixed

  • A component that never started no longer silences every collider. Callback ids from RegisterEventCallback are counted from 1, and UnregisterEventCallback(0) removes nothing. Ids were positions from 0, and 0 was the input system's own callback, the one that sends pointer events to Input Colliders: a component keeping its id in a member that starts at 0, destroyed before Start (the editor does that each time it loads a scene to edit), removed it, and no collider got a tap until the editor was restarted.
  • Stopping the game and rebuilding no longer crashes the next run in IsKeyPressed. An input source the game added stayed registered after Play, and the rebuild unloaded its code.
  • In the editor, pointer events from an input source reach colliders. They were dropped because the editor runs games without Engine::Initialize.
  • A click in the editor's Play view is an input event, as a touch is on a device: RegisterEventCallback listeners hear MouseButtonDown. It used to go to the colliders only.
  • A TouchDown, TouchMove or TouchUp event reaches colliders as the matching Mouse event. No driver in the engine sends them (touch panels send Mouse events, as IDekiInput.h now says), but one of your own may.
  • UnregisterEventCallback's comment named an OnDestroy that components do not have; a listener stops in its destructor.

0.22.0

Changed

  • Translations are keyed by the editor's names with their acronyms ("I2C Port", "SPI Host" rather than "I 2c Port", "Spi Host"), which the 0.22 editor shows.
  • minEngine 0.22.0: built against engine 0.22.0. A build of this package from before does not load and is rebuilt.

Earlier releases: CHANGELOG.md.


Generated from the package's reflection data (engine 0.40.1). Property names are the keys used in scene files. Renames keep an alias (compatibility).