hid_writer_mac.cc 731 B

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