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: ppapi/shared_impl/ppb_gamepad_shared.cc

Issue 1548993002: Switch to standard integer types in base/strings/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/base/zap.cc ('k') | ppapi/shared_impl/private/ppb_char_set_shared.cc » ('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) 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>
8
7 #include <algorithm> 9 #include <algorithm>
8 10
9
10 namespace ppapi { 11 namespace ppapi {
11 12
12 const size_t WebKitGamepads::kItemsLengthCap; 13 const size_t WebKitGamepads::kItemsLengthCap;
13 14
14 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data, 15 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data,
15 PP_GamepadsSampleData* output_data) { 16 PP_GamepadsSampleData* output_data) {
16 size_t length = std::min(WebKitGamepads::kItemsLengthCap, 17 size_t length = std::min(WebKitGamepads::kItemsLengthCap,
17 static_cast<const size_t>(webkit_data.length)); 18 static_cast<const size_t>(webkit_data.length));
18 output_data->length = static_cast<unsigned>(length); 19 output_data->length = static_cast<unsigned>(length);
19 for (unsigned i = 0; i < length; ++i) { 20 for (unsigned i = 0; i < length; ++i) {
20 PP_GamepadSampleData& output_pad = output_data->items[i]; 21 PP_GamepadSampleData& output_pad = output_data->items[i];
21 const WebKitGamepad& webkit_pad = webkit_data.items[i]; 22 const WebKitGamepad& webkit_pad = webkit_data.items[i];
22 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; 23 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE;
23 if (webkit_pad.connected) { 24 if (webkit_pad.connected) {
24 static_assert(sizeof(output_pad.id) == sizeof(webkit_pad.id), 25 static_assert(sizeof(output_pad.id) == sizeof(webkit_pad.id),
25 "id size does not match"); 26 "id size does not match");
26 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); 27 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id));
27 output_pad.timestamp = static_cast<double>(webkit_pad.timestamp); 28 output_pad.timestamp = static_cast<double>(webkit_pad.timestamp);
28 output_pad.axes_length = webkit_pad.axes_length; 29 output_pad.axes_length = webkit_pad.axes_length;
29 for (unsigned j = 0; j < webkit_pad.axes_length; ++j) 30 for (unsigned j = 0; j < webkit_pad.axes_length; ++j)
30 output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]); 31 output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]);
31 output_pad.buttons_length = webkit_pad.buttons_length; 32 output_pad.buttons_length = webkit_pad.buttons_length;
32 for (unsigned j = 0; j < webkit_pad.buttons_length; ++j) 33 for (unsigned j = 0; j < webkit_pad.buttons_length; ++j)
33 output_pad.buttons[j] = static_cast<float>(webkit_pad.buttons[j].value); 34 output_pad.buttons[j] = static_cast<float>(webkit_pad.buttons[j].value);
34 } 35 }
35 } 36 }
36 } 37 }
37 38
38 } // namespace ppapi 39 } // namespace ppapi
OLDNEW
« no previous file with comments | « net/base/zap.cc ('k') | ppapi/shared_impl/private/ppb_char_set_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698