Add git cl format presubmit warning for extension and apps.
[chromium-blink-merge.git] / device / hid / hid_utils_mac.cc
blob588041a3ccb2b3c614b29c413236302d2af731fb
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.
5 #include "device/hid/hid_utils_mac.h"
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"
12 #if defined(OS_MACOSX)
13 #include <CoreFoundation/CoreFoundation.h>
14 #include <IOKit/hid/IOHIDManager.h>
15 #endif
17 namespace device {
19 bool GetHidIntProperty(IOHIDDeviceRef device,
20 CFStringRef key,
21 int32_t* result) {
22 CFNumberRef ref = base::mac::CFCast<CFNumberRef>(
23 IOHIDDeviceGetProperty(device, key));
24 return ref && CFNumberGetValue(ref, kCFNumberSInt32Type, result);
27 bool GetHidStringProperty(IOHIDDeviceRef device,
28 CFStringRef key,
29 std::string* result) {
30 CFStringRef ref = base::mac::CFCast<CFStringRef>(
31 IOHIDDeviceGetProperty(device, key));
32 if (!ref) {
33 return false;
35 *result = base::SysCFStringRefToUTF8(ref);
36 return true;
39 } // namespace device