| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/hid/hid_utils_mac.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" |
| 11 |
| 12 #if defined(OS_MACOSX) |
| 13 #include <CoreFoundation/CoreFoundation.h> |
| 14 #include <IOKit/hid/IOHIDManager.h> |
| 15 #endif |
| 16 |
| 17 namespace device { |
| 18 |
| 19 bool GetIntProperty(IOHIDDeviceRef device, CFStringRef key, int32_t* result) { |
| 20 CFNumberRef ref = base::mac::CFCast<CFNumberRef>( |
| 21 IOHIDDeviceGetProperty(device, key)); |
| 22 return ref && CFNumberGetValue(ref, kCFNumberSInt32Type, result); |
| 23 } |
| 24 |
| 25 bool GetStringProperty(IOHIDDeviceRef device, |
| 26 CFStringRef key, |
| 27 std::string* result) { |
| 28 CFStringRef ref = base::mac::CFCast<CFStringRef>( |
| 29 IOHIDDeviceGetProperty(device, key)); |
| 30 if (!ref) { |
| 31 return false; |
| 32 } |
| 33 *result = base::SysCFStringRefToUTF8(ref); |
| 34 return true; |
| 35 } |
| 36 |
| 37 } // namespace device |
| OLD | NEW |