ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / device / hid / hid_service_win.h
blob1704ac75c14ef7cc282a86d08d90ce9f0fc2a2a1
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_
8 #include <windows.h>
9 #include <hidclass.h>
11 extern "C" {
12 #include <hidsdi.h>
13 #include <hidpi.h>
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/scoped_observer.h"
19 #include "base/win/scoped_handle.h"
20 #include "device/core/device_monitor_win.h"
21 #include "device/hid/hid_device_info.h"
22 #include "device/hid/hid_service.h"
24 namespace base {
25 namespace win {
26 class MessageWindow;
30 namespace device {
32 class HidServiceWin : public HidService, public DeviceMonitorWin::Observer {
33 public:
34 HidServiceWin(scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
36 virtual void Connect(const HidDeviceId& device_id,
37 const ConnectCallback& callback) override;
39 private:
40 virtual ~HidServiceWin();
42 static void EnumerateOnFileThread(
43 base::WeakPtr<HidServiceWin> service,
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
45 static void CollectInfoFromButtonCaps(PHIDP_PREPARSED_DATA preparsed_data,
46 HIDP_REPORT_TYPE report_type,
47 USHORT button_caps_length,
48 HidCollectionInfo* collection_info);
49 static void CollectInfoFromValueCaps(PHIDP_PREPARSED_DATA preparsed_data,
50 HIDP_REPORT_TYPE report_type,
51 USHORT value_caps_length,
52 HidCollectionInfo* collection_info);
53 static void AddDeviceOnFileThread(
54 base::WeakPtr<HidServiceWin> service,
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
56 const std::string& device_path);
58 // DeviceMonitorWin::Observer implementation:
59 void OnDeviceAdded(const std::string& device_path) override;
60 void OnDeviceRemoved(const std::string& device_path) override;
62 // Tries to open the device read-write and falls back to read-only.
63 static base::win::ScopedHandle OpenDevice(const std::string& device_path);
65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
66 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
67 ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_;
68 base::WeakPtrFactory<HidServiceWin> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(HidServiceWin);
73 } // namespace device
75 #endif // DEVICE_HID_HID_SERVICE_WIN_H_