hid_connection_mac.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef SERVICES_DEVICE_HID_HID_CONNECTION_MAC_H_
  5. #define SERVICES_DEVICE_HID_HID_CONNECTION_MAC_H_
  6. #include <CoreFoundation/CoreFoundation.h>
  7. #include <IOKit/hid/IOHIDDevice.h>
  8. #include <stddef.h>
  9. #include <stdint.h>
  10. #include "base/containers/queue.h"
  11. #include "base/mac/foundation_util.h"
  12. #include "services/device/hid/hid_connection.h"
  13. namespace base {
  14. class SequencedTaskRunner;
  15. }
  16. namespace device {
  17. class HidConnectionMac : public HidConnection {
  18. public:
  19. HidConnectionMac(base::ScopedCFTypeRef<IOHIDDeviceRef> device,
  20. scoped_refptr<HidDeviceInfo> device_info,
  21. bool allow_protected_reports,
  22. bool allow_fido_reports);
  23. HidConnectionMac(HidConnectionMac&) = delete;
  24. HidConnectionMac& operator=(HidConnectionMac&) = delete;
  25. private:
  26. ~HidConnectionMac() override;
  27. // HidConnection implementation.
  28. void PlatformClose() override;
  29. void PlatformWrite(scoped_refptr<base::RefCountedBytes> buffer,
  30. WriteCallback callback) override;
  31. void PlatformGetFeatureReport(uint8_t report_id,
  32. ReadCallback callback) override;
  33. void PlatformSendFeatureReport(scoped_refptr<base::RefCountedBytes> buffer,
  34. WriteCallback callback) override;
  35. static void InputReportCallback(void* context,
  36. IOReturn result,
  37. void* sender,
  38. IOHIDReportType type,
  39. uint32_t report_id,
  40. uint8_t* report_bytes,
  41. CFIndex report_length);
  42. void GetFeatureReportAsync(uint8_t report_id, ReadCallback callback);
  43. void SetReportAsync(IOHIDReportType report_type,
  44. scoped_refptr<base::RefCountedBytes> buffer,
  45. WriteCallback callback);
  46. void ReturnAsyncResult(base::OnceClosure callback);
  47. base::ScopedCFTypeRef<IOHIDDeviceRef> device_;
  48. const scoped_refptr<base::SequencedTaskRunner> task_runner_;
  49. const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
  50. std::vector<uint8_t> inbound_buffer_;
  51. };
  52. } // namespace device
  53. #endif // SERVICES_DEVICE_HID_HID_CONNECTION_MAC_H_