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

Side by Side Diff: content/browser/gamepad/platform_data_fetcher_linux.cc

Issue 9270015: Add Mac gamepad input remapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux Created 8 years, 11 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 "content/browser/gamepad/platform_data_fetcher_linux.h" 5 #include "content/browser/gamepad/platform_data_fetcher_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <libudev.h> 9 #include <libudev.h>
10 #include <linux/joystick.h> 10 #include <linux/joystick.h>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 const char* vendor_id = udev_device_get_sysattr_value(dev, "idVendor"); 152 const char* vendor_id = udev_device_get_sysattr_value(dev, "idVendor");
153 const char* product_id = udev_device_get_sysattr_value(dev, "idProduct"); 153 const char* product_id = udev_device_get_sysattr_value(dev, "idProduct");
154 mapper = GetGamepadStandardMappingFunction(vendor_id, product_id); 154 mapper = GetGamepadStandardMappingFunction(vendor_id, product_id);
155 155
156 const char* manufacturer = 156 const char* manufacturer =
157 udev_device_get_sysattr_value(dev, "manufacturer"); 157 udev_device_get_sysattr_value(dev, "manufacturer");
158 const char* product = udev_device_get_sysattr_value(dev, "product"); 158 const char* product = udev_device_get_sysattr_value(dev, "product");
159 159
160 // Driver returns utf-8 strings here, so combine in utf-8 and then convert 160 // Driver returns utf-8 strings here, so combine in utf-8 and then convert
161 // to WebUChar to build the id string. 161 // to WebUChar to build the id string.
162 std::string id; 162 std::string id = base::StringPrintf("%s %s (%sVendor: %s Product: %s)",
163 if (mapper) {
164 id = base::StringPrintf("%s %s (STANDARD GAMEPAD)",
165 manufacturer,
166 product);
167 } else {
168 id = base::StringPrintf("%s %s (Vendor: %s Product: %s)",
169 manufacturer, 163 manufacturer,
170 product, 164 product,
165 mapper ? "STANDARD GAMEPAD " : "",
171 vendor_id, 166 vendor_id,
172 product_id); 167 product_id);
173 }
174 TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id); 168 TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id);
175 string16 tmp16 = UTF8ToUTF16(id); 169 string16 tmp16 = UTF8ToUTF16(id);
176 memset(pad.id, 0, sizeof(pad.id)); 170 memset(pad.id, 0, sizeof(pad.id));
177 tmp16.copy(pad.id, arraysize(pad.id) - 1); 171 tmp16.copy(pad.id, arraysize(pad.id) - 1);
178 172
179 pad.connected = true; 173 pad.connected = true;
180 } 174 }
181 } 175 }
182 176
183 void GamepadPlatformDataFetcherLinux::EnumerateDevices() { 177 void GamepadPlatformDataFetcherLinux::EnumerateDevices() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 pad.buttons[item] = event.value ? 1.0 : 0.0; 214 pad.buttons[item] = event.value ? 1.0 : 0.0;
221 if (item >= pad.buttonsLength) 215 if (item >= pad.buttonsLength)
222 pad.buttonsLength = item + 1; 216 pad.buttonsLength = item + 1;
223 } 217 }
224 pad.timestamp = event.time; 218 pad.timestamp = event.time;
225 } 219 }
226 } 220 }
227 221
228 222
229 } // namespace content 223 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/platform_data_fetcher_linux.h ('k') | content/browser/gamepad/platform_data_fetcher_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698