1 // Copyright 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/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h"
12 int32_t GetHidIntProperty(IOHIDDeviceRef device
, CFStringRef key
) {
14 if (TryGetHidIntProperty(device
, key
, &value
))
19 std::string
GetHidStringProperty(IOHIDDeviceRef device
, CFStringRef key
) {
21 TryGetHidStringProperty(device
, key
, &value
);
25 bool TryGetHidIntProperty(IOHIDDeviceRef device
,
28 CFNumberRef ref
= base::mac::CFCast
<CFNumberRef
>(
29 IOHIDDeviceGetProperty(device
, key
));
30 return ref
&& CFNumberGetValue(ref
, kCFNumberSInt32Type
, result
);
33 bool TryGetHidStringProperty(IOHIDDeviceRef device
,
35 std::string
* result
) {
36 CFStringRef ref
= base::mac::CFCast
<CFStringRef
>(
37 IOHIDDeviceGetProperty(device
, key
));
41 *result
= base::SysCFStringRefToUTF8(ref
);