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

Side by Side Diff: ppapi/c/dev/ppb_gamepad_dev.h

Issue 9405033: Revise gamepad interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 dev/ppb_gamepad_dev.idl modified Tue Feb 7 12:49:02 2012. */ 6 /* From dev/ppb_gamepad_dev.idl modified Mon Feb 27 13:23:13 2012. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_ 8 #ifndef PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_
9 #define PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_ 9 #define PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_
10 10
11 #include "ppapi/c/pp_bool.h"
11 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/c/pp_macros.h" 13 #include "ppapi/c/pp_macros.h"
13 #include "ppapi/c/pp_stdint.h" 14 #include "ppapi/c/pp_stdint.h"
14 15
15 #define PPB_GAMEPAD_DEV_INTERFACE_0_1 "PPB_Gamepad(Dev);0.1" 16 #define PPB_GAMEPAD_DEV_INTERFACE_0_2 "PPB_Gamepad(Dev);0.2"
16 #define PPB_GAMEPAD_DEV_INTERFACE PPB_GAMEPAD_DEV_INTERFACE_0_1 17 #define PPB_GAMEPAD_DEV_INTERFACE PPB_GAMEPAD_DEV_INTERFACE_0_2
17 18
18 /** 19 /**
19 * @file 20 * @file
20 * This file defines the <code>PPB_Gamepad_Dev</code> interface, which 21 * This file defines the <code>PPB_Gamepad_Dev</code> interface, which
21 * provides access to gamepad devices. 22 * provides access to gamepad devices.
22 */ 23 */
23 24
24 25
25 #pragma pack(push, 1)
26
27 /** 26 /**
28 * @addtogroup Structs 27 * @addtogroup Structs
29 * @{ 28 * @{
30 */ 29 */
31 /** 30 /**
32 * The data for one gamepad device. 31 * The data for one gamepad device.
33 */ 32 */
34 struct PP_GamepadData_Dev { 33 struct PP_GamepadSampleData_Dev {
35 /**
36 * Is there a gamepad connected at this index? If this is false, no other
37 * data in this structure is valid.
38 */
39 char connected;
40 /**
41 * String identifier for the type of device/manufacturer.
42 */
43 uint16_t id[128];
44 /**
45 * Monotonically increasing value that is incremented when the data have
46 * been updated.
47 */
48 uint64_t timestamp;
49 /** 34 /**
50 * Number of valid elements in the |axes| array. 35 * Number of valid elements in the |axes| array.
51 */ 36 */
52 uint32_t axes_length; 37 uint32_t axes_length;
53 /** 38 /**
54 * Normalized values for the axes, indices valid up to |axesLength|-1. Axis 39 * Normalized values for the axes, indices valid up to |axes_length|-1. Axis
55 * values range from -1..1, and are in order of "importance". 40 * values range from -1..1, and are in order of "importance".
56 */ 41 */
57 float axes[16]; 42 float axes[16];
58 /** 43 /**
59 * Number of valid elements in the |buttons| array. 44 * Number of valid elements in the |buttons| array.
60 */ 45 */
61 uint32_t buttons_length; 46 uint32_t buttons_length;
62 /** 47 /**
63 * Normalized values for the buttons, indices valid up to |buttonsLength| 48 * Normalized values for the buttons, indices valid up to |buttons_length|
64 * - 1. Button values range from 0..1, and are in order of importance. 49 * - 1. Button values range from 0..1, and are in order of importance.
65 */ 50 */
66 float buttons[32]; 51 float buttons[32];
52 /**
53 * Monotonically increasing value that is incremented when the data have
54 * been updated.
55 */
56 double timestamp;
57 /**
58 * Identifier for the type of device/manufacturer.
59 */
60 uint16_t id[128];
61 /**
62 * Is there a gamepad connected at this index? If this is false, no other
63 * data in this structure is valid.
64 */
65 PP_Bool connected;
66 /* Padding to make the struct the same size between 64 and 32. */
67 char unused_pad_[4];
67 }; 68 };
69 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadSampleData_Dev, 472);
68 70
69 /** 71 /**
70 * The data for all gamepads connected to the system. 72 * The data for all gamepads connected to the system.
71 */ 73 */
72 struct PP_GamepadsData_Dev { 74 struct PP_GamepadsSampleData_Dev {
73 /** 75 /**
74 * Number of valid elements in the |items| array. 76 * Number of valid elements in the |items| array.
75 */ 77 */
76 uint32_t length; 78 uint32_t length;
79 /* Padding to make the struct the same size between 64 and 32. */
80 char unused_pad_[4];
77 /** 81 /**
78 * Data for an individual gamepad device connected to the system. 82 * Data for an individual gamepad device connected to the system.
79 */ 83 */
80 struct PP_GamepadData_Dev items[4]; 84 struct PP_GamepadSampleData_Dev items[4];
81 }; 85 };
86 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadsSampleData_Dev, 1896);
82 /** 87 /**
83 * @} 88 * @}
84 */ 89 */
85 90
86 #pragma pack(pop)
87
88 /** 91 /**
89 * @addtogroup Interfaces 92 * @addtogroup Interfaces
90 * @{ 93 * @{
91 */ 94 */
92 /** 95 /**
93 * The <code>PPB_Gamepad_Dev</code> interface allows retrieving data from 96 * The <code>PPB_Gamepad_Dev</code> interface allows retrieving data from
94 * gamepad/joystick devices that are connected to the system. 97 * gamepad/joystick devices that are connected to the system.
95 */ 98 */
96 struct PPB_Gamepad_Dev_0_1 { 99 struct PPB_Gamepad_Dev_0_2 {
97 /** 100 /**
98 * Samples the current state of the connected gamepads. 101 * Samples the current state of the connected gamepads.
99 */ 102 */
100 void (*SampleGamepads)(PP_Instance instance, 103 void (*Sample)(PP_Instance instance, struct PP_GamepadsSampleData_Dev* data);
101 struct PP_GamepadsData_Dev* data);
102 }; 104 };
103 105
104 typedef struct PPB_Gamepad_Dev_0_1 PPB_Gamepad_Dev; 106 typedef struct PPB_Gamepad_Dev_0_2 PPB_Gamepad_Dev;
105 /** 107 /**
106 * @} 108 * @}
107 */ 109 */
108 110
109 #endif /* PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_ */ 111 #endif /* PPAPI_C_DEV_PPB_GAMEPAD_DEV_H_ */
110 112
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698