naiveproxy/device/gamepad/public/mojom/gamepad.mojom
2018-12-09 21:59:24 -05:00

122 lines
3.1 KiB
Plaintext

// Copyright 2016 The Chromium Authors. All rights reserved.
// 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;
};
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
};
enum GamepadHapticEffectType {
GamepadHapticEffectTypeDualRumble = 0
};
struct GamepadHapticActuator {
GamepadHapticActuatorType type;
};
struct Gamepad {
bool connected;
array<uint16> id;
int64 timestamp;
array<double> axes;
array<GamepadButton> buttons;
GamepadHapticActuator? vibration_actuator;
array<uint16> mapping;
GamepadPose? pose;
GamepadHand hand;
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 button or axis is changed on a connected gamepad. |index| is
// the index of the gamepad in the gamepad array, and |gamepad| is a reference
// to the gamepad.
GamepadButtonOrAxisChanged(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(GamepadObserver gamepad_observer);
};
struct GamepadEffectParameters {
double duration;
double start_delay;
double strong_magnitude;
double weak_magnitude;
};
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);
};