入力のディスパッチと衝突判定。ポインター / タッチ / キーのイベントを、それを必要とするコンポーネントに送り、アナログスティックの向きを読み取ります。
リポジトリ: github.com/dekiengine/deki-input · 最新リリース: 0.40.0 · エンジン 0.40.0 以降が必要
DekiEditor --packages-add deki-input <project> か、パッケージマネージャーからインストールします。エンジン自身のコンポーネントと C++ API は Deki のドキュメントにあります。
エディターでは Input と表示されます。
コンポーネント
| コンポーネント | カテゴリ | 説明 |
| I2CKeyboardComponent | 入力 | I2C で 1 回読むごとに入力された文字を 1 つ返すキーボードを読み取ります。LilyGO T-Deck のキーボードや M5Stack CardKB が該当します。 |
| InputCollider | 入力 | ポインターとタッチの当たり判定の領域です。ボタンやスクロールはここで入力を受け取ります。 |
| TrackballComponent | 入力 | GPIO ピンにつないだトラックボールです。矢印キーと Enter として、またはポインターとして使えます。 |
機能フラグ
ビルドから外せる部分です。define を持つ機能はその define で切り替わり、それ以外はコンポーネントと一緒に取り除かれます。
| 機能 | define | デフォルト |
| Colliders | DEKI_FEATURE_INPUT | オン |
| I2C Keyboard | DEKI_FEATURE_INPUT_I2C_KEYBOARD | オン |
| Trackball | DEKI_FEATURE_INPUT_TRACKBALL | オン |
コンポーネントリファレンス
I2CKeyboardComponent
I2C で 1 回読むごとに入力された文字を 1 つ返すキーボードを読み取ります。LilyGO T-Deck のキーボードや M5Stack CardKB が該当します。
インスペクターでの名前: I2C キーボード · カテゴリ: 入力 · 型: DekiInput::I2CKeyboardComponent
| プロパティ | 型 | デフォルト | 制約 | 説明 |
| i2cPort | int32 | 0 | 0 から 3 | キーボードがつながっている I2C バスです。そのポートを設定した I2C Bus コンポーネントと一致させてください。 |
| i2cAddress | int32 | 85 | 0 から 127 | バス上のキーボードのアドレスです。LilyGO T-Deck は 0x55 (85)、M5Stack CardKB は 0x5F (95) です。 |
| hasBacklight | bool | false | | キーボード自身が制御するバックライトがあり、バス経由で設定します (LilyGO T-Deck の場合はレジスタ 0x01 の明るさ)。ゲームのコードからは I2CKeyboard::SetBacklight で設定します。 |
| reportHeldKeys | bool | false | | LilyGO T-Deck のキーボードのキーマトリクス全体を読み取り、デスクトップのキーボードと同じように、押している間ずっとキーが押された状態になります。これでキーを押している間ゲームのキャラクターを歩かせられます。マトリクスモード (register 0x03) のあるキーボードファームウェアが必要です。オフのときは、打ったキーが 1 フレームだけ押された状態になります。 |
InputCollider
ポインターとタッチの当たり判定の領域です。ボタンやスクロールはここで入力を受け取ります。
インスペクターでの名前: 入力コライダー · カテゴリ: 入力 · 型: DekiInput::InputCollider
| プロパティ | 型 | デフォルト | 制約 | 説明 |
| width | float | 0 | 単位 m | 当たり判定の幅 (メートル) です。描かれているものと一致させる必要はありません。 |
| height | float | 0 | 単位 m | 当たり判定の高さ (メートル) です。 |
| paddingLeft | float | 0 | 単位 m | 左端の外側に広げる当たり判定 (メートル) です。小さな操作部品を、見た目を大きくせずに指で押しやすくするのに便利です。 |
| paddingRight | float | 0 | 単位 m | 右端の外側に広げる当たり判定 (メートル) です。 |
| paddingTop | float | 0 | 単位 m | 上端の外側に広げる当たり判定 (メートル) です。 |
| paddingBottom | float | 0 | 単位 m | 下端の外側に広げる当たり判定 (メートル) です。 |
| consumeInput | bool | true | | 押下をここで止め、下にあるオブジェクトへ届かないようにします。後ろにあるものを妨げないオーバーレイではオフにしてください。 |
TrackballComponent
GPIO ピンにつないだトラックボールです。矢印キーと Enter として、またはポインターとして使えます。
インスペクターでの名前: トラックボール · カテゴリ: 入力 · 型: DekiInput::TrackballComponent
| プロパティ | 型 | デフォルト | 制約 | 説明 |
| mode | enum | "Keys" | Keys, Pointer | キー: 転がすと矢印キーを押し、クリックは Enter になります。ポインター: 転がすとポインターが動き、クリックはマウスボタンになります。 |
| pixelsPerStep | int32 | 4 | 1 から 64 | ポインターモード: ボールの 1 ステップでポインターが動くピクセル数です |
| glideMs | float | 0 | 0 から 1000 | ポインターモード: ボールが止まった後もポインターが滑り続ける時間 (ミリ秒) で、ThinkPad の TrackPoint のような動きになります。0 にすると転がしたステップ分だけ正確に動きます。 |
| acceleration | float | 1 | 1 から 8 | 滑走ありのポインターモード: ボールを速く回したとき、ゆっくり転がしたときに比べて 1 ステップでポインターが何倍遠くまで進むかです。1: 加速なし。 |
| upPin | int32 | -1 | -1 から 48 | ボールが上に転がるとパルスを出す線です |
| downPin | int32 | -1 | -1 から 48 | ボールが下に転がるとパルスを出す線です |
| leftPin | int32 | -1 | -1 から 48 | ボールが左に転がるとパルスを出す線です |
| rightPin | int32 | -1 | -1 から 48 | ボールが右に転がるとパルスを出す線です |
| clickPin | int32 | -1 | -1 から 48 | クリックスイッチです (-1 = なし) |
| clickActiveLow | bool | true | | 押したときにクリックがピンを Low にする (オン) か、High にする (オフ) かです |
変更履歴
変更履歴は英語です。
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.
それ以前のリリース: CHANGELOG.md
パッケージのリフレクションデータから生成しています (エンジン 0.40.1)。プロパティ名はシーンファイルで使われるキーです。名前を変えても別名が残ります (互換性)。