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

Side by Side Diff: public/platform/WebGamepad.h

Issue 280393004: Update Gamepad.axes / GamepadButton.value to match the latest specification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 7 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
« no previous file with comments | « Source/modules/gamepad/GamepadCommon.cpp ('k') | public/platform/WebGamepads.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (C) 2011, Google Inc. All rights reserved. 1 // Copyright (C) 2011, Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met: 4 // modification, are permitted provided that the following conditions are met:
5 // 5 //
6 // 1. Redistributions of source code must retain the above copyright 6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright 8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the 9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution. 10 // documentation and/or other materials provided with the distribution.
(...skipping 12 matching lines...) Expand all
23 23
24 #ifndef WebGamepad_h 24 #ifndef WebGamepad_h
25 #define WebGamepad_h 25 #define WebGamepad_h
26 26
27 #include "WebCommon.h" 27 #include "WebCommon.h"
28 28
29 #if BLINK_IMPLEMENTATION 29 #if BLINK_IMPLEMENTATION
30 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
31 #endif 31 #endif
32 32
33 // FIXME(cdumez): Remove once the Chromium side has been updated.
34 #define ENABLE_NEW_GAMEPAD_API 1
dmichael (off chromium) 2014/05/21 16:49:31 I don't think this is safe. You have Chromium code
35
33 namespace blink { 36 namespace blink {
34 37
35 #pragma pack(push, 1) 38 #pragma pack(push, 1)
36 39
37 class WebGamepadButton { 40 class WebGamepadButton {
38 public: 41 public:
39 WebGamepadButton() 42 WebGamepadButton()
40 : pressed(false) 43 : pressed(false)
41 , value(0.f) 44 , value(0.)
42 { 45 {
43 } 46 }
44 WebGamepadButton(bool pressed, float value) 47 WebGamepadButton(bool pressed, double value)
45 : pressed(pressed) 48 : pressed(pressed)
46 , value(value) 49 , value(value)
47 { 50 {
48 } 51 }
49 bool pressed; 52 bool pressed;
50 float value; 53 double value;
51 }; 54 };
52 55
53 // This structure is intentionally POD and fixed size so that it can be shared 56 // This structure is intentionally POD and fixed size so that it can be shared
54 // memory between hardware polling threads and the rest of the browser. See 57 // memory between hardware polling threads and the rest of the browser. See
55 // also WebGamepads.h. 58 // also WebGamepads.h.
56 class WebGamepad { 59 class WebGamepad {
57 public: 60 public:
58 static const size_t idLengthCap = 128; 61 static const size_t idLengthCap = 128;
59 static const size_t mappingLengthCap = 16; 62 static const size_t mappingLengthCap = 16;
60 static const size_t axesLengthCap = 16; 63 static const size_t axesLengthCap = 16;
(...skipping 16 matching lines...) Expand all
77 WebUChar id[idLengthCap]; 80 WebUChar id[idLengthCap];
78 81
79 // Monotonically increasing value referring to when the data were last 82 // Monotonically increasing value referring to when the data were last
80 // updated. 83 // updated.
81 unsigned long long timestamp; 84 unsigned long long timestamp;
82 85
83 // Number of valid entries in the axes array. 86 // Number of valid entries in the axes array.
84 unsigned axesLength; 87 unsigned axesLength;
85 88
86 // Normalized values representing axes, in the range [-1..1]. 89 // Normalized values representing axes, in the range [-1..1].
87 float axes[axesLengthCap]; 90 double axes[axesLengthCap];
88 91
89 // Number of valid entries in the buttons array. 92 // Number of valid entries in the buttons array.
90 unsigned buttonsLength; 93 unsigned buttonsLength;
91 94
92 // Button states 95 // Button states
93 WebGamepadButton buttons[buttonsLengthCap]; 96 WebGamepadButton buttons[buttonsLengthCap];
94 97
95 // Mapping type (for example "standard") 98 // Mapping type (for example "standard")
96 WebUChar mapping[mappingLengthCap]; 99 WebUChar mapping[mappingLengthCap];
97 }; 100 };
98 101
99 #if BLINK_IMPLEMENTATION 102 #if BLINK_IMPLEMENTATION
100 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size); 103 COMPILE_ASSERT(sizeof(WebGamepad) == 721, WebGamepad_has_wrong_size);
101 #endif 104 #endif
102 105
103 #pragma pack(pop) 106 #pragma pack(pop)
104 107
105 } 108 }
106 109
107 #endif // WebGamepad_h 110 #endif // WebGamepad_h
OLDNEW
« no previous file with comments | « Source/modules/gamepad/GamepadCommon.cpp ('k') | public/platform/WebGamepads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698