Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: ppapi/c/ppb_gamepad.h

Issue 165983005: Updating Gamepad API to match latest spec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ifdef-gaurds Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /* From ppb_gamepad.idl modified Tue Apr 16 09:04:34 2013. */ 6 /* From ppb_gamepad.idl modified Sun Feb 9 16:16:26 2014. */
7 7
8 #ifndef PPAPI_C_PPB_GAMEPAD_H_ 8 #ifndef PPAPI_C_PPB_GAMEPAD_H_
9 #define PPAPI_C_PPB_GAMEPAD_H_ 9 #define PPAPI_C_PPB_GAMEPAD_H_
10 10
11 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h" 13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_stdint.h" 14 #include "ppapi/c/pp_stdint.h"
15 15
16 #define PPB_GAMEPAD_INTERFACE_1_0 "PPB_Gamepad;1.0" 16 #define PPB_GAMEPAD_INTERFACE_1_0 "PPB_Gamepad;1.0"
17 #define PPB_GAMEPAD_INTERFACE PPB_GAMEPAD_INTERFACE_1_0 17 #define PPB_GAMEPAD_INTERFACE PPB_GAMEPAD_INTERFACE_1_0
18 18
19 /** 19 /**
20 * @file 20 * @file
21 * This file defines the <code>PPB_Gamepad</code> interface, which 21 * This file defines the <code>PPB_Gamepad</code> interface, which
22 * provides access to gamepad devices. 22 * provides access to gamepad devices.
23 */ 23 */
24 24
25 25
26 /** 26 /**
27 * @addtogroup Structs 27 * @addtogroup Structs
28 * @{ 28 * @{
29 */ 29 */
30 /** 30 /**
31 * The data for one gamepad button.
32 */
33 struct PP_GamepadButtonSampleData {
34 /**
35 * Is the button pressed?
36 */
37 PP_Bool pressed;
38 /**
39 * Normalized button value, in the range [0..1].
40 */
41 float value;
42 };
43 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadButtonSampleData, 8);
44
45 /**
31 * The data for one gamepad device. 46 * The data for one gamepad device.
32 */ 47 */
33 struct PP_GamepadSampleData { 48 struct PP_GamepadSampleData {
34 /** 49 /**
35 * Number of valid elements in the |axes| array. 50 * Number of valid elements in the |axes| array.
36 */ 51 */
37 uint32_t axes_length; 52 uint32_t axes_length;
38 /** 53 /**
39 * Normalized values for the axes, indices valid up to |axes_length|-1. Axis 54 * Normalized values for the axes, indices valid up to |axes_length|-1. Axis
40 * values range from -1..1, and are in order of "importance". 55 * values range from -1..1, and are in order of "importance".
41 */ 56 */
42 float axes[16]; 57 float axes[16];
43 /** 58 /**
44 * Number of valid elements in the |buttons| array. 59 * Number of valid elements in the |buttons| array.
45 */ 60 */
46 uint32_t buttons_length; 61 uint32_t buttons_length;
47 /** 62 /**
48 * Normalized values for the buttons, indices valid up to |buttons_length| 63 * Normalized values for the buttons, indices valid up to |buttons_length|
49 * - 1. Button values range from 0..1, and are in order of importance. 64 * - 1. Button values range from 0..1, and are in order of importance.
50 */ 65 */
51 float buttons[32]; 66 struct PP_GamepadButtonSampleData buttons[32];
52 /** 67 /**
53 * Monotonically increasing value that is incremented when the data have 68 * Monotonically increasing value that is incremented when the data have
54 * been updated. 69 * been updated.
55 */ 70 */
56 double timestamp; 71 double timestamp;
57 /** 72 /**
58 * Identifier for the type of device/manufacturer. 73 * Identifier for the type of device/manufacturer.
59 */ 74 */
60 uint16_t id[128]; 75 uint16_t id[128];
61 /** 76 /**
77 * Mapping type (for example "standard")
78 */
79 uint16_t mapping[16];
80 /**
62 * Is there a gamepad connected at this index? If this is false, no other 81 * Is there a gamepad connected at this index? If this is false, no other
63 * data in this structure is valid. 82 * data in this structure is valid.
64 */ 83 */
65 PP_Bool connected; 84 PP_Bool connected;
66 /* Padding to make the struct the same size between 64 and 32. */ 85 /* Padding to make the struct the same size between 64 and 32. */
67 char unused_pad_[4]; 86 char unused_pad_[4];
68 }; 87 };
69 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadSampleData, 472); 88 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadSampleData, 632);
70 89
71 /** 90 /**
72 * The data for all gamepads connected to the system. 91 * The data for all gamepads connected to the system.
73 */ 92 */
74 struct PP_GamepadsSampleData { 93 struct PP_GamepadsSampleData {
75 /** 94 /**
76 * Number of valid elements in the |items| array. 95 * Number of valid elements in the |items| array.
77 */ 96 */
78 uint32_t length; 97 uint32_t length;
79 /* Padding to make the struct the same size between 64 and 32. */ 98 /* Padding to make the struct the same size between 64 and 32. */
80 char unused_pad_[4]; 99 char unused_pad_[4];
81 /** 100 /**
82 * Data for an individual gamepad device connected to the system. 101 * Data for an individual gamepad device connected to the system.
83 */ 102 */
84 struct PP_GamepadSampleData items[4]; 103 struct PP_GamepadSampleData items[4];
85 }; 104 };
86 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadsSampleData, 1896); 105 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadsSampleData, 2536);
87 /** 106 /**
88 * @} 107 * @}
89 */ 108 */
90 109
91 /** 110 /**
92 * @addtogroup Interfaces 111 * @addtogroup Interfaces
93 * @{ 112 * @{
94 */ 113 */
95 /** 114 /**
96 * The <code>PPB_Gamepad</code> interface allows retrieving data from 115 * The <code>PPB_Gamepad</code> interface allows retrieving data from
97 * gamepad/joystick devices that are connected to the system. 116 * gamepad/joystick devices that are connected to the system.
98 */ 117 */
99 struct PPB_Gamepad_1_0 { 118 struct PPB_Gamepad_1_0 {
100 /** 119 /**
101 * Samples the current state of the available gamepads. 120 * Samples the current state of the available gamepads.
102 */ 121 */
103 void (*Sample)(PP_Instance instance, struct PP_GamepadsSampleData* data); 122 void (*Sample)(PP_Instance instance, struct PP_GamepadsSampleData* data);
104 }; 123 };
105 124
106 typedef struct PPB_Gamepad_1_0 PPB_Gamepad; 125 typedef struct PPB_Gamepad_1_0 PPB_Gamepad;
107 /** 126 /**
108 * @} 127 * @}
109 */ 128 */
110 129
111 #endif /* PPAPI_C_PPB_GAMEPAD_H_ */ 130 #endif /* PPAPI_C_PPB_GAMEPAD_H_ */
112 131
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698