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

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

Issue 165983005: Updating Gamepad API to match latest spec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests Created 6 years, 10 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 #include "ppapi/shared_impl/ppb_gamepad_shared.h" 5 #include "ppapi/shared_impl/ppb_gamepad_shared.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 8
9 namespace ppapi { 9 namespace ppapi {
10 10
11 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data, 11 void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data,
12 PP_GamepadsSampleData* output_data) { 12 PP_GamepadsSampleData* output_data) {
13 output_data->length = webkit_data.length; 13 output_data->length = webkit_data.length;
14 for (unsigned i = 0; i < webkit_data.length; ++i) { 14 for (unsigned i = 0; i < webkit_data.length; ++i) {
15 PP_GamepadSampleData& output_pad = output_data->items[i]; 15 PP_GamepadSampleData& output_pad = output_data->items[i];
16 const WebKitGamepad& webkit_pad = webkit_data.items[i]; 16 const WebKitGamepad& webkit_pad = webkit_data.items[i];
17 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; 17 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE;
18 if (webkit_pad.connected) { 18 if (webkit_pad.connected) {
19 COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id), 19 COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id),
20 id_size_does_not_match); 20 id_size_does_not_match);
21 COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes), 21 COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes),
22 axes_size_does_not_match); 22 axes_size_does_not_match);
23 COMPILE_ASSERT(sizeof(output_pad.buttons) == sizeof(webkit_pad.buttons),
24 buttons_size_does_not_match);
25 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); 23 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id));
26 output_pad.timestamp = webkit_pad.timestamp; 24 output_pad.timestamp = webkit_pad.timestamp;
27 output_pad.axes_length = webkit_pad.axes_length; 25 output_pad.axes_length = webkit_pad.axes_length;
28 memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes)); 26 memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes));
29 output_pad.buttons_length = webkit_pad.buttons_length; 27 output_pad.buttons_length = webkit_pad.buttons_length;
30 memcpy( 28
31 output_pad.buttons, webkit_pad.buttons, sizeof(output_pad.buttons)); 29 // Can't memcpy because buttons are different types
bbudge 2014/02/24 23:11:06 nit: this comment doesn't seem necessary to me whe
30 for (unsigned j = 0; j < webkit_pad.buttons_length; ++j)
31 output_pad.buttons[j] = webkit_pad.buttons[j].value;
32 } 32 }
bbudge 2014/02/24 23:14:51 I don't understand how mapping data is converted.
bajones 2014/02/24 23:25:56 I assume you're referring to the string "mapping"
33 } 33 }
34 } 34 }
35 35
36 } // namespace ppapi 36 } // namespace ppapi
OLDNEW
« ppapi/shared_impl/ppb_gamepad_shared.h ('K') | « ppapi/shared_impl/ppb_gamepad_shared.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698