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. 4 5 #ifndef DEVICE_HID_HID_SERVICE_MAC_H_ 6 #define DEVICE_HID_HID_SERVICE_MAC_H_ 7 8 #include <CoreFoundation/CoreFoundation.h> 9 #include <IOKit/hid/IOHIDManager.h> 10 11 #include <string> 12 13 #include "base/mac/foundation_util.h" 14 #include "base/memory/ref_counted.h" 15 #include "device/hid/hid_service.h" 16 17 namespace base { 18 class MessageLoopProxy; 19 } 20 21 namespace device { 22 23 class HidConnection; 24 25 class HidServiceMac : public HidService { 26 public: 27 HidServiceMac(); 28 29 virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id) 30 OVERRIDE; 31 32 private: 33 virtual ~HidServiceMac(); 34 35 void StartWatchingDevices(); 36 void StopWatchingDevices(); 37 38 // Device changing callbacks. 39 static void AddDeviceCallback(void* context, 40 IOReturn result, 41 void* sender, 42 IOHIDDeviceRef hid_device); 43 static void RemoveDeviceCallback(void* context, 44 IOReturn result, 45 void* sender, 46 IOHIDDeviceRef hid_device); 47 48 void Enumerate(); 49 50 void PlatformAddDevice(IOHIDDeviceRef hid_device); 51 void PlatformRemoveDevice(IOHIDDeviceRef hid_device); 52 53 // Platform HID Manager 54 base::ScopedCFTypeRef<IOHIDManagerRef> hid_manager_; 55 56 // The message loop for the thread on which this service was created. 57 scoped_refptr<base::MessageLoopProxy> message_loop_; 58 59 DISALLOW_COPY_AND_ASSIGN(HidServiceMac); 60 }; 61 62 } // namespace device 63 64 #endif // DEVICE_HID_HID_SERVICE_MAC_H_ 65