| 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 #ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
| 6 #define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "ppapi/c/ppb_gamepad.h" | 12 #include "ppapi/c/ppb_gamepad.h" |
| 13 #include "ppapi/shared_impl/ppapi_shared_export.h" | 13 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 14 | 14 |
| 15 namespace ppapi { | 15 namespace ppapi { |
| 16 | 16 |
| 17 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this | 17 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this |
| 18 // code should all move into the GamepadResource. | 18 // code should all move into the GamepadResource. |
| 19 | 19 |
| 20 #pragma pack(push, 1) | 20 #pragma pack(push, 1) |
| 21 | 21 |
| 22 struct WebKitGamepadButton { | 22 struct WebKitGamepadButton { |
| 23 bool pressed; | 23 bool pressed; |
| 24 bool touched; | 24 bool touched; |
| 25 double value; | 25 double value; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 struct WebKitGamepadVector { |
| 29 bool notNull; |
| 30 float x, y, z; |
| 31 }; |
| 32 |
| 33 struct WebKitGamepadQuaternion { |
| 34 bool notNull; |
| 35 float x, y, z, w; |
| 36 }; |
| 37 |
| 38 struct WebKitGamepadPose { |
| 39 bool notNull; |
| 40 |
| 41 bool hasOrientation; |
| 42 bool hasPosition; |
| 43 |
| 44 WebKitGamepadQuaternion orientation; |
| 45 WebKitGamepadVector position; |
| 46 WebKitGamepadVector angularVelocity; |
| 47 WebKitGamepadVector linearVelocity; |
| 48 WebKitGamepadVector angularAcceleration; |
| 49 WebKitGamepadVector linearAcceleration; |
| 50 }; |
| 51 |
| 28 // This must match the definition of blink::Gamepad. The GamepadHost unit test | 52 // This must match the definition of blink::Gamepad. The GamepadHost unit test |
| 29 // has some compile asserts to validate this. | 53 // has some compile asserts to validate this. |
| 30 struct WebKitGamepad { | 54 struct WebKitGamepad { |
| 31 static const size_t kIdLengthCap = 128; | 55 static const size_t kIdLengthCap = 128; |
| 32 static const size_t kMappingLengthCap = 16; | 56 static const size_t kMappingLengthCap = 16; |
| 33 static const size_t kAxesLengthCap = 16; | 57 static const size_t kAxesLengthCap = 16; |
| 34 static const size_t kButtonsLengthCap = 32; | 58 static const size_t kButtonsLengthCap = 32; |
| 35 | 59 |
| 36 // Is there a gamepad connected at this index? | 60 // Is there a gamepad connected at this index? |
| 37 bool connected; | 61 bool connected; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 double axes[kAxesLengthCap]; | 74 double axes[kAxesLengthCap]; |
| 51 | 75 |
| 52 // Number of valid entries in the buttons array. | 76 // Number of valid entries in the buttons array. |
| 53 unsigned buttons_length; | 77 unsigned buttons_length; |
| 54 | 78 |
| 55 // Normalized values representing buttons, in the range [0..1]. | 79 // Normalized values representing buttons, in the range [0..1]. |
| 56 WebKitGamepadButton buttons[kButtonsLengthCap]; | 80 WebKitGamepadButton buttons[kButtonsLengthCap]; |
| 57 | 81 |
| 58 // Mapping type (for example "standard") | 82 // Mapping type (for example "standard") |
| 59 base::char16 mapping[kMappingLengthCap]; | 83 base::char16 mapping[kMappingLengthCap]; |
| 84 |
| 85 WebKitGamepadPose pose; |
| 60 }; | 86 }; |
| 61 | 87 |
| 62 // This must match the definition of blink::Gamepads. The GamepadHost unit | 88 // This must match the definition of blink::Gamepads. The GamepadHost unit |
| 63 // test has some compile asserts to validate this. | 89 // test has some compile asserts to validate this. |
| 64 struct WebKitGamepads { | 90 struct WebKitGamepads { |
| 65 static const size_t kItemsLengthCap = 4; | 91 static const size_t kItemsLengthCap = 4; |
| 66 | 92 |
| 67 // Number of valid entries in the items array. | 93 // Number of valid entries in the items array. |
| 68 unsigned length; | 94 unsigned length; |
| 69 | 95 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 | 107 |
| 82 #pragma pack(pop) | 108 #pragma pack(pop) |
| 83 | 109 |
| 84 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData( | 110 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData( |
| 85 const WebKitGamepads& webkit_data, | 111 const WebKitGamepads& webkit_data, |
| 86 PP_GamepadsSampleData* output_data); | 112 PP_GamepadsSampleData* output_data); |
| 87 | 113 |
| 88 } // namespace ppapi | 114 } // namespace ppapi |
| 89 | 115 |
| 90 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 116 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
| OLD | NEW |