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