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 #ifndef DEVICE_HID_HID_CONNECTION_MAC_H_
6 #define DEVICE_HID_HID_CONNECTION_MAC_H_
8 #include <CoreFoundation/CoreFoundation.h>
9 #include <IOKit/hid/IOHIDManager.h>
13 #include "base/mac/foundation_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "device/hid/hid_connection.h"
18 class MessageLoopProxy
;
27 class HidConnectionMac
: public HidConnection
{
29 explicit HidConnectionMac(HidDeviceInfo device_info
);
32 virtual ~HidConnectionMac();
34 // HidConnection implementation.
35 virtual void PlatformRead(const ReadCallback
& callback
) OVERRIDE
;
36 virtual void PlatformWrite(scoped_refptr
<net::IOBuffer
> buffer
,
38 const WriteCallback
& callback
) OVERRIDE
;
39 virtual void PlatformGetFeatureReport(uint8_t report_id
,
40 const ReadCallback
& callback
) OVERRIDE
;
41 virtual void PlatformSendFeatureReport(
42 scoped_refptr
<net::IOBuffer
> buffer
,
44 const WriteCallback
& callback
) OVERRIDE
;
46 static void InputReportCallback(void* context
,
51 uint8_t* report_bytes
,
52 CFIndex report_length
);
54 void WriteReport(IOHIDReportType type
,
55 scoped_refptr
<net::IOBuffer
> buffer
,
57 const WriteCallback
& callback
);
60 void ProcessInputReport(scoped_refptr
<net::IOBufferWithSize
> buffer
);
61 void ProcessReadQueue();
63 base::ScopedCFTypeRef
<IOHIDDeviceRef
> device_
;
64 scoped_refptr
<base::MessageLoopProxy
> message_loop_
;
65 std::vector
<uint8_t> inbound_buffer_
;
67 std::queue
<PendingHidReport
> pending_reports_
;
68 std::queue
<PendingHidRead
> pending_reads_
;
70 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac
);
75 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_