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.
5 #ifndef DEVICE_HID_HID_SERVICE_WIN_H_
6 #define DEVICE_HID_HID_SERVICE_WIN_H_
16 #include "base/memory/scoped_ptr.h"
17 #include "base/scoped_observer.h"
18 #include "base/win/scoped_handle.h"
19 #include "device/core/device_monitor_win.h"
20 #include "device/hid/hid_device_info.h"
21 #include "device/hid/hid_service.h"
31 class HidServiceWin
: public HidService
, public DeviceMonitorWin::Observer
{
35 virtual void Connect(const HidDeviceId
& device_id
,
36 const ConnectCallback
& callback
) override
;
39 virtual ~HidServiceWin();
41 void DoInitialEnumeration();
42 static void CollectInfoFromButtonCaps(PHIDP_PREPARSED_DATA preparsed_data
,
43 HIDP_REPORT_TYPE report_type
,
44 USHORT button_caps_length
,
45 HidCollectionInfo
* collection_info
);
46 static void CollectInfoFromValueCaps(PHIDP_PREPARSED_DATA preparsed_data
,
47 HIDP_REPORT_TYPE report_type
,
48 USHORT value_caps_length
,
49 HidCollectionInfo
* collection_info
);
51 // DeviceMonitorWin::Observer implementation:
52 void OnDeviceAdded(const std::string
& device_path
) override
;
53 void OnDeviceRemoved(const std::string
& device_path
) override
;
55 // Tries to open the device read-write and falls back to read-only.
56 base::win::ScopedHandle
OpenDevice(const std::string
& device_path
);
58 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
59 ScopedObserver
<DeviceMonitorWin
, DeviceMonitorWin::Observer
> device_observer_
;
61 DISALLOW_COPY_AND_ASSIGN(HidServiceWin
);
66 #endif // DEVICE_HID_HID_SERVICE_WIN_H_