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

Side by Side Diff: device/gamepad/gamepad_platform_data_fetcher_android.cc

Issue 2350573002: Fix gamepad connected status on Android (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/gamepad/gamepad_platform_data_fetcher_android.h" 5 #include "device/gamepad/gamepad_platform_data_fetcher_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 pad.id[name_to_copy] = 0; 110 pad.id[name_to_copy] = 0;
111 111
112 base::string16 mapping_name = base::UTF8ToUTF16(mapping ? "standard" : ""); 112 base::string16 mapping_name = base::UTF8ToUTF16(mapping ? "standard" : "");
113 const size_t mapping_to_copy = 113 const size_t mapping_to_copy =
114 std::min(mapping_name.size(), WebGamepad::mappingLengthCap - 1); 114 std::min(mapping_name.size(), WebGamepad::mappingLengthCap - 1);
115 memcpy(pad.mapping, mapping_name.data(), 115 memcpy(pad.mapping, mapping_name.data(),
116 mapping_to_copy * sizeof(base::string16::value_type)); 116 mapping_to_copy * sizeof(base::string16::value_type));
117 pad.mapping[mapping_to_copy] = 0; 117 pad.mapping[mapping_to_copy] = 0;
118 } 118 }
119 119
120 pad.connected = true;
120 pad.timestamp = timestamp; 121 pad.timestamp = timestamp;
121 122
122 std::vector<float> axes; 123 std::vector<float> axes;
123 base::android::JavaFloatArrayToFloatVector(env, jaxes, &axes); 124 base::android::JavaFloatArrayToFloatVector(env, jaxes, &axes);
124 125
125 // Set WebGamepad axeslength to total number of axes on the gamepad device. 126 // Set WebGamepad axeslength to total number of axes on the gamepad device.
126 // Only return the first axesLengthCap if axeslength captured by GamepadList 127 // Only return the first axesLengthCap if axeslength captured by GamepadList
127 // is larger than axesLengthCap. 128 // is larger than axesLengthCap.
128 pad.axesLength = std::min(static_cast<int>(axes.size()), 129 pad.axesLength = std::min(static_cast<int>(axes.size()),
129 static_cast<int>(WebGamepad::axesLengthCap)); 130 static_cast<int>(WebGamepad::axesLengthCap));
(...skipping 13 matching lines...) Expand all
143 static_cast<int>(WebGamepad::buttonsLengthCap)); 144 static_cast<int>(WebGamepad::buttonsLengthCap));
144 145
145 // Copy buttons state to the WebGamepad buttons[]. 146 // Copy buttons state to the WebGamepad buttons[].
146 for (unsigned int j = 0; j < pad.buttonsLength; j++) { 147 for (unsigned int j = 0; j < pad.buttonsLength; j++) {
147 pad.buttons[j].pressed = buttons[j]; 148 pad.buttons[j].pressed = buttons[j];
148 pad.buttons[j].value = buttons[j]; 149 pad.buttons[j].value = buttons[j];
149 } 150 }
150 } 151 }
151 152
152 } // namespace device 153 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698