Skip to content

Commit 6a4362a

Browse files
authored
feat: add TouchscreenInputControls and UiInputBinding components (#426)
* feat: adding mobile_input_controls and ui_input_binding * rename PBMobileInputControls to PBTouchscreenInputControls * adding touch_button for control customization * simplifying specification * adding hide_crosshair * using TextureUnio, properly referencing PBTouchScreenControls * added import public, documented release semantics + multi-touch behavior, documented accepted actions + invalid-value fallback
1 parent 0010e70 commit 6a4362a

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
syntax = "proto3";
2+
package decentraland.sdk.components;
3+
import "decentraland/sdk/components/common/id.proto";
4+
import "decentraland/sdk/components/common/input_action.proto";
5+
import "decentraland/common/texture.proto";
6+
option (common.ecs_component_id) = 1218;
7+
8+
// The TouchScreenControls component lets a scene configure the native on-screen touch
9+
// controls (the mobile joystick + gamepad). It must be set on the RootEntity.
10+
//
11+
// By default every on-screen button is shown; list a button in `touch_inputs` with
12+
// `hide = true` to remove it (declutter). `main_action` picks which action the large
13+
// central button triggers, and `hide_joystick` removes the native virtual joystick. It is
14+
// a no-op on platforms without native on-screen controls (e.g. desktop).
15+
//
16+
// Accepted actions: only the on-screen gamepad actions map to a button — `IA_POINTER`,
17+
// `IA_PRIMARY`, `IA_SECONDARY`, `IA_JUMP`, and `IA_ACTION_3`..`IA_ACTION_6`. Any other
18+
// `InputAction` (movement actions, `IA_ANY`, `IA_MODIFIER`, or unknown/future values) is
19+
// ignored: a `TouchInput` entry naming a non-button action has no effect, and a `main_action`
20+
// that isn't a valid gamepad action falls back to the default central button (`IA_JUMP`).
21+
message PBTouchScreenControls {
22+
// Per-button configuration. A button not listed here keeps its default (shown).
23+
message TouchInput {
24+
common.InputAction input_action = 1; // which on-screen button this configures
25+
bool hide = 2; // hide this button (default: shown)
26+
// Override the button glyph with this texture. For the jump button it replaces all
27+
// of its dynamic states (jump / double-jump / glide).
28+
optional decentraland.common.TextureUnion icon = 3;
29+
}
30+
31+
repeated TouchInput touch_inputs = 1;
32+
// The large central button's action. Only the gamepad actions are valid:
33+
// jump / pointer / primary (E) / secondary (F) / action_3..action_6 (1/2/3/4).
34+
// When unset, the default central button (jump) is kept.
35+
optional common.InputAction main_action = 2;
36+
bool hide_joystick = 3; // hide the native virtual joystick
37+
bool hide_crosshair = 4; // hide the on-screen crosshair / reticle
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
syntax = "proto3";
2+
package decentraland.sdk.components;
3+
import "decentraland/sdk/components/common/id.proto";
4+
import "decentraland/sdk/components/common/input_action.proto";
5+
option (common.ecs_component_id) = 1219;
6+
7+
// The UiInputBinding component binds a UI entity to one or more InputActions. While the
8+
// element is pressed (touch or pointer) the listed actions are held down, driving both
9+
// the local player input and scene InputAction listeners, just like the native on-screen
10+
// buttons. It is typically combined with PBTouchScreenControls to replace the native
11+
// controls with a custom touch UI.
12+
//
13+
// Release semantics: the held actions are released as soon as the press that started them
14+
// ends. A renderer MUST release all actions held by this binding when any of the following
15+
// happens: the press/touch is lifted or cancelled, the pointer/touch leaves the element
16+
// (loses press ownership), the actions list changes (the previous set is released before
17+
// the new set is applied), the component is removed or its actions list becomes empty, the
18+
// UI element is hidden, disabled or removed from the tree, or the scene unloads. In short,
19+
// no action may remain held once the element is no longer both present and actively pressed.
20+
//
21+
// Multi-touch: the binding is a single held state, not reference-counted per pointer. The
22+
// actions are held while the element is pressed and released when that press ends; a second
23+
// simultaneous press on the same element does not stack, and does not extend the hold past
24+
// the first release.
25+
message PBUiInputBinding {
26+
repeated common.InputAction actions = 1; // the input actions fired while this element is pressed
27+
}

public/sdk-components.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import public "decentraland/sdk/components/raycast_result.proto";
2929
import public "decentraland/sdk/components/raycast.proto";
3030
import public "decentraland/sdk/components/realm_info.proto";
3131
import public "decentraland/sdk/components/text_shape.proto";
32+
import public "decentraland/sdk/components/touch_screen_controls.proto";
3233
import public "decentraland/sdk/components/tween.proto";
3334
import public "decentraland/sdk/components/tween_state.proto";
3435
import public "decentraland/sdk/components/tween_sequence.proto";
@@ -37,6 +38,7 @@ import public "decentraland/sdk/components/ui_dropdown_result.proto";
3738
import public "decentraland/sdk/components/ui_dropdown.proto";
3839
import public "decentraland/sdk/components/ui_input_result.proto";
3940
import public "decentraland/sdk/components/ui_input.proto";
41+
import public "decentraland/sdk/components/ui_input_binding.proto";
4042
import public "decentraland/sdk/components/ui_text.proto";
4143
import public "decentraland/sdk/components/ui_transform.proto";
4244
import public "decentraland/sdk/components/video_player.proto";

0 commit comments

Comments
 (0)