• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6/**
7 * This file defines the <code>PPB_Gamepad</code> interface, which
8 * provides access to gamepad devices.
9 */
10
11[generate_thunk]
12
13label Chrome {
14  M19 = 1.0
15};
16
17/**
18 * The data for one gamepad device.
19 */
20[assert_size(472)]
21struct PP_GamepadSampleData {
22    /**
23     * Number of valid elements in the |axes| array.
24     */
25    uint32_t axes_length;
26
27    /**
28     * Normalized values for the axes, indices valid up to |axes_length|-1. Axis
29     * values range from -1..1, and are in order of "importance".
30     */
31    float_t[16] axes;
32
33    /**
34     * Number of valid elements in the |buttons| array.
35     */
36    uint32_t buttons_length;
37
38    /**
39     * Normalized values for the buttons, indices valid up to |buttons_length|
40     * - 1. Button values range from 0..1, and are in order of importance.
41     */
42    float_t[32] buttons;
43
44    /**
45     * Monotonically increasing value that is incremented when the data have
46     * been updated.
47     */
48    double_t timestamp;
49
50    /**
51     * Identifier for the type of device/manufacturer.
52     */
53    uint16_t[128] id;
54
55    /**
56     * Is there a gamepad connected at this index? If this is false, no other
57     * data in this structure is valid.
58     */
59    PP_Bool connected;
60
61    /* Padding to make the struct the same size between 64 and 32. */
62    char[4] unused_pad_;
63};
64
65/**
66 * The data for all gamepads connected to the system.
67 */
68[assert_size(1896)]
69struct PP_GamepadsSampleData {
70    /**
71     * Number of valid elements in the |items| array.
72     */
73    uint32_t length;
74
75    /* Padding to make the struct the same size between 64 and 32. */
76    char[4] unused_pad_;
77
78    /**
79     * Data for an individual gamepad device connected to the system.
80     */
81    PP_GamepadSampleData[4] items;
82};
83
84/**
85 * The <code>PPB_Gamepad</code> interface allows retrieving data from
86 * gamepad/joystick devices that are connected to the system.
87 */
88[version=1.0, macro="PPB_GAMEPAD_INTERFACE", singleton]
89interface PPB_Gamepad {
90  /**
91   * Samples the current state of the available gamepads.
92   */
93  [always_set_output_parameters]
94  void Sample(
95      [in] PP_Instance instance,
96      [out] PP_GamepadsSampleData data);
97};
98