// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module device.mojom;
import "mojo/public/mojom/base/shared_memory.mojom";
struct GamepadQuaternion {
float x;
float y;
float z;
float w;
};
struct GamepadVector {
float x;
float y;
float z;
};
struct GamepadButton {
bool pressed;
bool touched;
double value;
};
enum GamepadMapping {
GamepadMappingNone = 0,
GamepadMappingStandard = 1,
GamepadMappingXRStandard = 2
};
struct GamepadTouch {
uint32 touch_id;
uint8 surface_id;
double x;
double y;
uint32 surface_height;
uint32 surface_width;
bool has_surface_dimensions;
};
struct GamepadPose {
GamepadQuaternion? orientation;
GamepadVector? position;
GamepadVector? angular_velocity;
GamepadVector? linear_velocity;
GamepadVector? angular_acceleration;
GamepadVector? linear_acceleration;
};
enum GamepadHand {
GamepadHandNone = 0,
GamepadHandLeft = 1,
GamepadHandRight = 2
};
enum GamepadHapticActuatorType {
GamepadHapticActuatorTypeVibration = 0,
GamepadHapticActuatorTypeDualRumble = 1,
GamepadHapticActuatorTypeTriggerRumble = 2
};
enum GamepadHapticEffectType {
GamepadHapticEffectTypeDualRumble = 0,
GamepadHapticEffectTypeTriggerRumble = 1
};
struct GamepadHapticActuator {
GamepadHapticActuatorType type;
};
struct Gamepad {
bool connected;
array<uint16> id;
int64 timestamp;
array<double> axes;
array<GamepadButton> buttons;
GamepadHapticActuator? vibration_actuator;
GamepadMapping mapping;
GamepadPose? pose;
GamepadHand hand;
array<GamepadTouch> touch_events;
uint32 display_id;
};
interface GamepadObserver {
// Called when a gamepad is connected. |index| is the index of the gamepad in
// the gamepad array, and |gamepad| is a reference to the connected gamepad.
GamepadConnected(uint32 index, Gamepad gamepad);
// Called when a gamepad is disconnected. |index| is the former index of the
// gamepad in the gamepad array, and |gamepad| is a reference to the
// connected gamepad.
GamepadDisconnected(uint32 index, Gamepad gamepad);
// Called when a gamepad's input state changes, such as button presses,
// axis movements, or touch events, but not connection or disconnection.
// |index| is the index of the gamepad in the gamepad array, and |gamepad|
// is a reference to the gamepad with updated input data.
GamepadRawInputChanged(uint32 index, Gamepad gamepad);
};
// Asks the browser process to start polling, and return a shared memory
// region that will hold the data from the hardware. See
// gamepad_shared_buffer.h for a description of how synchronization is
// handled. The number of Starts should match the number of Stops.
interface GamepadMonitor {
[Sync]
GamepadStartPolling()
=> (mojo_base.mojom.ReadOnlySharedMemoryRegion memory_region);
[Sync]
GamepadStopPolling() => ();
SetObserver(pending_remote<GamepadObserver> gamepad_observer);
};
struct GamepadEffectParameters {
double duration;
double start_delay;
double strong_magnitude;
double weak_magnitude;
double left_trigger;
double right_trigger;
};
enum GamepadHapticsResult {
GamepadHapticsResultError = 0,
GamepadHapticsResultComplete = 1,
GamepadHapticsResultPreempted = 2,
GamepadHapticsResultInvalidParameter = 3,
GamepadHapticsResultNotSupported = 4
};
interface GamepadHapticsManager {
PlayVibrationEffectOnce(uint32 pad_index,
GamepadHapticEffectType type,
GamepadEffectParameters params)
=> (GamepadHapticsResult result);
ResetVibrationActuator(uint32 pad_index) => (GamepadHapticsResult result);
};