Chromium Code Reviews| Index: content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
| diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
| index 63733b21a2cbd166846d478e12a3f988b628b0d7..ee244ebf410ed57e5c038d032697b493b63f01b3 100644 |
| --- a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
| +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
| @@ -181,6 +181,27 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
| // Append the vendor and product information then convert the utf-8 |
| // id string to WebUChar. |
| +#ifdef ENABLE_NEW_GAMEPAD_API |
|
scottmg
2014/02/18 23:45:26
I'm not sure I like the #ifs. How are we going to
bajones
2014/02/18 23:54:04
Sorry, I should have clarified this. These #ifdefs
scottmg
2014/02/18 23:57:30
Gotcha, that sounds good.
My concern then is that
|
| + std::string id = name_string + base::StringPrintf( |
| + " (Vendor: %s Product: %s)", |
| + vendor_id, |
| + product_id); |
| + base::TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id); |
| + base::string16 tmp16 = base::UTF8ToUTF16(id); |
| + memset(pad.id, 0, sizeof(pad.id)); |
| + tmp16.copy(pad.id, arraysize(pad.id) - 1); |
| + |
| + if (mapper) { |
| + std::string mapping = "standard"; |
| + base::TruncateUTF8ToByteSize(mapping, WebGamepad::mappingLengthCap - 1, |
| + &mapping); |
| + tmp16 = base::UTF8ToUTF16(mapping); |
| + memset(pad.mapping, 0, sizeof(pad.mapping)); |
| + tmp16.copy(pad.mapping, arraysize(pad.mapping) - 1); |
| + } else { |
| + pad.mapping[0] = 0; |
| + } |
| +#else |
| std::string id = name_string + base::StringPrintf( |
| " (%sVendor: %s Product: %s)", |
| mapper ? "STANDARD GAMEPAD " : "", |
| @@ -190,6 +211,7 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
| base::string16 tmp16 = base::UTF8ToUTF16(id); |
| memset(pad.id, 0, sizeof(pad.id)); |
| tmp16.copy(pad.id, arraysize(pad.id) - 1); |
| +#endif |
| pad.connected = true; |
| } |