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

Side by Side Diff: ppapi/shared_impl/ppb_gamepad_shared.cc

Issue 2572323002: Delete WebGamepads::length. (Closed)
Patch Set: Bring back active_state clearing in exo Created 4 years 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
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 #include "ppapi/shared_impl/ppb_gamepad_shared.h" 5 #include "ppapi/shared_impl/ppb_gamepad_shared.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 namespace ppapi { 11 namespace ppapi {
12 12
13 const size_t WebKitGamepads::kItemsLengthCap; 13 const size_t WebKitGamepads::kItemsLengthCap;
14 14
15 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data, 15 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data,
16 PP_GamepadsSampleData* output_data) { 16 PP_GamepadsSampleData* output_data) {
17 size_t length = std::min(WebKitGamepads::kItemsLengthCap, 17 output_data->length = WebKitGamepads::kItemsLengthCap;
18 static_cast<const size_t>(webkit_data.length)); 18 for (unsigned i = 0; i < WebKitGamepads::kItemsLengthCap; ++i) {
19 output_data->length = static_cast<unsigned>(length);
20 for (unsigned i = 0; i < length; ++i) {
21 PP_GamepadSampleData& output_pad = output_data->items[i]; 19 PP_GamepadSampleData& output_pad = output_data->items[i];
raymes 2016/12/15 04:14:48 Just to check - will output_data->items and webkit
aelias_OOO_until_Jul13 2016/12/15 04:19:06 Yes. The data structures have always been statica
22 const WebKitGamepad& webkit_pad = webkit_data.items[i]; 20 const WebKitGamepad& webkit_pad = webkit_data.items[i];
23 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; 21 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE;
24 if (webkit_pad.connected) { 22 if (webkit_pad.connected) {
25 static_assert(sizeof(output_pad.id) == sizeof(webkit_pad.id), 23 static_assert(sizeof(output_pad.id) == sizeof(webkit_pad.id),
26 "id size does not match"); 24 "id size does not match");
27 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); 25 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id));
28 output_pad.timestamp = static_cast<double>(webkit_pad.timestamp); 26 output_pad.timestamp = static_cast<double>(webkit_pad.timestamp);
29 output_pad.axes_length = webkit_pad.axes_length; 27 output_pad.axes_length = webkit_pad.axes_length;
30 for (unsigned j = 0; j < webkit_pad.axes_length; ++j) 28 for (unsigned j = 0; j < webkit_pad.axes_length; ++j)
31 output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]); 29 output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]);
32 output_pad.buttons_length = webkit_pad.buttons_length; 30 output_pad.buttons_length = webkit_pad.buttons_length;
33 for (unsigned j = 0; j < webkit_pad.buttons_length; ++j) 31 for (unsigned j = 0; j < webkit_pad.buttons_length; ++j)
34 output_pad.buttons[j] = static_cast<float>(webkit_pad.buttons[j].value); 32 output_pad.buttons[j] = static_cast<float>(webkit_pad.buttons[j].value);
35 } 33 }
36 } 34 }
37 } 35 }
38 36
39 } // namespace ppapi 37 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_gamepad_shared.h ('k') | third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698