Appearance
traits/press.proto
Table of Contents
traits/press.proto
GetPressedStateRequest
Field | Type | Label | Description |
---|---|---|---|
name | string | ||
read_mask | google.protobuf.FieldMask |
PressedState
Field | Type | Label | Description |
---|---|---|---|
state | PressedState.Press | ||
state_change_time | google.protobuf.Timestamp | The time that state changed to its present value. | |
most_recent_gesture | PressedState.Gesture | The gesture that is currently in progress, or finished most recently. May be absent, if there is no gesture recorded for this input. |
PressedState.Gesture
A representation of user intent, deduced from a pattern of presses. The way that the device converts presses into gestures is implementation-defined. There may be a delay between the presses and the registration of a gesture.
Field | Type | Label | Description |
---|---|---|---|
id | string | Opaque identifier changes each time a new gesture begins. The gesture will remain in the PressedState even when the client has already seen it; the client can use the id to detect when a new gesture has begun. | |
kind | PressedState.Gesture.Kind | ||
count | int32 | A counter for sub-events that occur within a single gesture. See the Kind for details of meaning. | |
start_time | google.protobuf.Timestamp | The time when the gesture was first recognised. | |
end_time | google.protobuf.Timestamp | The time when the gesture was recognised as completed. For HOLD gestures, this remains unset until the input is released. |
PullPressedStateRequest
Field | Type | Label | Description |
---|---|---|---|
name | string | ||
read_mask | google.protobuf.FieldMask | ||
updates_only | bool | By default, PullPressedState sends the initial PressedState when the stream opens, followed by changes. Setting updates_only true will disable this behaviour, sending only when the PressedState changes. |
PullPressedStateResponse
Field | Type | Label | Description |
---|---|---|---|
changes | PullPressedStateResponse.Change | repeated |
PullPressedStateResponse.Change
Field | Type | Label | Description |
---|---|---|---|
name | string | ||
change_time | google.protobuf.Timestamp | ||
pressed_state | PressedState |
UpdatePressedStateRequest
Field | Type | Label | Description |
---|---|---|---|
name | string | ||
update_mask | google.protobuf.FieldMask | ||
pressed_state | PressedState |
PressedState.Gesture.Kind
Name | Number | Description |
---|---|---|
KIND_UNSPECIFIED | 0 | |
CLICK | 1 | One or more short press-and-release actions. Presses in short succession may be fused into double-clicks, triple-clicks etc. - in this case, the number of fused clicks is stored in the count field. When clicks are fused in this way, the gesture will not appear at all until the final click has finished - it's not possible for a single gesture to be first reported as a single click, and then modified to a double click. |
HOLD | 2 | The input is kept in the pressed state for an extended period. The input may support repeat events, in which case the count will increment for each repeat event, keeping id the same because it's part of the same gesture. For HOLD gestures, the end_time is not set until the input has been released, allowing the client to determine when the gesture has ended. |
PressedState.Press
Instantaneous pressed state.
Name | Number | Description |
---|---|---|
PRESS_UNSPECIFIED | 0 | |
UNPRESSED | 1 | The input is not pressed. |
PRESSED | 2 | The input is being pressed. |
PressApi
The state and events from an input that can be pressed, e.g. a momentary push-button input. This trait facilitates reactions to basic user input. Both the basic pressed state (pressed or not) as well as higher-level input events like "double click" are supported.
Method Name | Request Type | Response Type | Description |
---|---|---|---|
GetPressedState | GetPressedStateRequest | PressedState | Gets the current state of the input. Contain the most recent gesture, so clients using polling can still detect and respond to gestures. However, to reduce latency, PullPressedState is recommended for this use case. |
PullPressedState | PullPressedStateRequest | PullPressedStateResponse stream | Fetches changes to the pressed state and gestures, and optionally the initial state. |
UpdatePressedState | UpdatePressedStateRequest | PressedState | Updates the input state according to the write mask. Real (physical) inputs are not expected to implement this method - it is intended for virtual or mock inputs |