| OLD | NEW |
| 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/gamepad_platform_data_fetcher_mac.h" | 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 // We can't handle this many connected devices. | 347 // We can't handle this many connected devices. |
| 348 if (slot == WebGamepads::itemsLengthCap) | 348 if (slot == WebGamepads::itemsLengthCap) |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 device->SetLEDPattern( | 351 device->SetLEDPattern( |
| 352 (XboxController::LEDPattern)(XboxController::LED_FLASH_TOP_LEFT + slot)); | 352 (XboxController::LEDPattern)(XboxController::LED_FLASH_TOP_LEFT + slot)); |
| 353 | 353 |
| 354 NSString* ident = | 354 NSString* ident = |
| 355 [NSString stringWithFormat: | 355 [NSString stringWithFormat: |
| 356 @"Xbox 360 Controller (STANDARD GAMEPAD Vendor: %04x Product: %04x)", | 356 @"%@ (STANDARD GAMEPAD Vendor: %04x Product: %04x)", |
| 357 device->GetControllerType() == XboxController::XBOX_360_CONTROLLER |
| 358 ? @"Xbox 360 Controller" |
| 359 : @"Xbox One Controller", |
| 357 device->GetProductId(), device->GetVendorId()]; | 360 device->GetProductId(), device->GetVendorId()]; |
| 358 NSData* as16 = [ident dataUsingEncoding:NSUTF16StringEncoding]; | 361 NSData* as16 = [ident dataUsingEncoding:NSUTF16StringEncoding]; |
| 359 const size_t kOutputLengthBytes = sizeof(data_.items[slot].id); | 362 const size_t kOutputLengthBytes = sizeof(data_.items[slot].id); |
| 360 memset(&data_.items[slot].id, 0, kOutputLengthBytes); | 363 memset(&data_.items[slot].id, 0, kOutputLengthBytes); |
| 361 [as16 getBytes:data_.items[slot].id | 364 [as16 getBytes:data_.items[slot].id |
| 362 length:kOutputLengthBytes - sizeof(blink::WebUChar)]; | 365 length:kOutputLengthBytes - sizeof(blink::WebUChar)]; |
| 363 | 366 |
| 364 associated_[slot].is_xbox = true; | 367 associated_[slot].is_xbox = true; |
| 365 associated_[slot].xbox.device = device; | 368 associated_[slot].xbox.device = device; |
| 366 associated_[slot].xbox.location_id = device->location_id(); | 369 associated_[slot].xbox.location_id = device->location_id(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 pads->length = WebGamepads::itemsLengthCap; | 434 pads->length = WebGamepads::itemsLengthCap; |
| 432 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 435 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
| 433 if (!associated_[i].is_xbox && associated_[i].hid.mapper) | 436 if (!associated_[i].is_xbox && associated_[i].hid.mapper) |
| 434 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); | 437 associated_[i].hid.mapper(data_.items[i], &pads->items[i]); |
| 435 else | 438 else |
| 436 pads->items[i] = data_.items[i]; | 439 pads->items[i] = data_.items[i]; |
| 437 } | 440 } |
| 438 } | 441 } |
| 439 | 442 |
| 440 } // namespace content | 443 } // namespace content |
| OLD | NEW |