1 // Copyright 2019 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/gamepad/hid_writer_mac.h" 6 7 #include <CoreFoundation/CoreFoundation.h> 8 9 namespace device { 10 HidWriterMac(IOHIDDeviceRef device_ref)11HidWriterMac::HidWriterMac(IOHIDDeviceRef device_ref) 12 : device_ref_(device_ref) {} 13 14 HidWriterMac::~HidWriterMac() = default; 15 WriteOutputReport(base::span<const uint8_t> report)16size_t HidWriterMac::WriteOutputReport(base::span<const uint8_t> report) { 17 IOReturn success = 18 IOHIDDeviceSetReport(device_ref_, kIOHIDReportTypeOutput, report[0], 19 report.data(), report.size_bytes()); 20 return (success == kIOReturnSuccess) ? report.size_bytes() : 0; 21 } 22 23 } // namespace device 24