| 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/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 snprintf(product_as_str, sizeof(product_as_str), "%04x", product_int); | 210 snprintf(product_as_str, sizeof(product_as_str), "%04x", product_int); |
| 211 associated_[slot].mapper = | 211 associated_[slot].mapper = |
| 212 GetGamepadStandardMappingFunction(vendor_as_str, product_as_str); | 212 GetGamepadStandardMappingFunction(vendor_as_str, product_as_str); |
| 213 | 213 |
| 214 NSString* ident = [NSString stringWithFormat: | 214 NSString* ident = [NSString stringWithFormat: |
| 215 @"%@ (%sVendor: %04x Product: %04x)", | 215 @"%@ (%sVendor: %04x Product: %04x)", |
| 216 product, | 216 product, |
| 217 associated_[slot].mapper ? "STANDARD GAMEPAD " : "", | 217 associated_[slot].mapper ? "STANDARD GAMEPAD " : "", |
| 218 vendor_int, | 218 vendor_int, |
| 219 product_int]; | 219 product_int]; |
| 220 NSData* as16 = [ident dataUsingEncoding:NSUTF16StringEncoding]; | 220 NSData* as16 = [ident dataUsingEncoding:NSUTF16LittleEndianStringEncoding]; |
| 221 | 221 |
| 222 const size_t kOutputLengthBytes = sizeof(data_.items[slot].id); | 222 const size_t kOutputLengthBytes = sizeof(data_.items[slot].id); |
| 223 memset(&data_.items[slot].id, 0, kOutputLengthBytes); | 223 memset(&data_.items[slot].id, 0, kOutputLengthBytes); |
| 224 [as16 getBytes:data_.items[slot].id | 224 [as16 getBytes:data_.items[slot].id |
| 225 length:kOutputLengthBytes - sizeof(WebKit::WebUChar)]; | 225 length:kOutputLengthBytes - sizeof(WebKit::WebUChar)]; |
| 226 | 226 |
| 227 base::mac::ScopedCFTypeRef<CFArrayRef> elements( | 227 base::mac::ScopedCFTypeRef<CFArrayRef> elements( |
| 228 IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone)); | 228 IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone)); |
| 229 AddButtonsAndAxes(CFToNSCast(elements), slot); | 229 AddButtonsAndAxes(CFToNSCast(elements), slot); |
| 230 | 230 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 pads->length = WebKit::WebGamepads::itemsLengthCap; | 304 pads->length = WebKit::WebGamepads::itemsLengthCap; |
| 305 for (size_t i = 0; i < WebKit::WebGamepads::itemsLengthCap; ++i) { | 305 for (size_t i = 0; i < WebKit::WebGamepads::itemsLengthCap; ++i) { |
| 306 if (associated_[i].mapper) | 306 if (associated_[i].mapper) |
| 307 associated_[i].mapper(data_.items[i], &pads->items[i]); | 307 associated_[i].mapper(data_.items[i], &pads->items[i]); |
| 308 else | 308 else |
| 309 pads->items[i] = data_.items[i]; | 309 pads->items[i] = data_.items[i]; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace content | 313 } // namespace content |
| OLD | NEW |