Landing Recent QUIC Changes.
[chromium-blink-merge.git] / ui / events / ozone / evdev / input_device_factory_evdev.h
blob5136a2141fffcc00d300181bf2ac6e4055bb18ae
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 UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_H_
8 #include <map>
9 #include <set>
10 #include <vector>
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/task_runner.h"
17 #include "ui/events/ozone/evdev/event_converter_evdev.h"
18 #include "ui/events/ozone/evdev/event_device_info.h"
19 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
21 namespace ui {
23 class CursorDelegateEvdev;
24 class DeviceEventDispatcherEvdev;
25 class InputDeviceFactoryEvdevProxy;
27 #if !defined(USE_EVDEV)
28 #error Missing dependency on ui/events/ozone:events_ozone_evdev
29 #endif
31 #if defined(USE_EVDEV_GESTURES)
32 class GesturePropertyProvider;
33 #endif
35 typedef base::Callback<void(scoped_ptr<std::string>)> GetTouchDeviceStatusReply;
37 // Manager for event device objects. All device I/O starts here.
38 class EVENTS_OZONE_EVDEV_EXPORT InputDeviceFactoryEvdev {
39 public:
40 InputDeviceFactoryEvdev(scoped_ptr<DeviceEventDispatcherEvdev> dispatcher,
41 CursorDelegateEvdev* cursor);
42 ~InputDeviceFactoryEvdev();
44 // Open & start reading a newly plugged-in input device.
45 void AddInputDevice(int id, const base::FilePath& path);
47 // Stop reading & close an unplugged input device.
48 void RemoveInputDevice(const base::FilePath& path);
50 // Disables the internal touchpad.
51 void DisableInternalTouchpad();
53 // Enables the internal touchpad.
54 void EnableInternalTouchpad();
56 // Disables all keys on the internal keyboard except |excepted_keys|.
57 void DisableInternalKeyboardExceptKeys(
58 scoped_ptr<std::set<DomCode>> excepted_keys);
60 // Enables all keys on the internal keyboard.
61 void EnableInternalKeyboard();
63 // Bits from InputController that have to be answered on IO.
64 void SetTouchpadSensitivity(int value);
65 void SetTapToClick(bool enabled);
66 void SetThreeFingerClick(bool enabled);
67 void SetTapDragging(bool enabled);
68 void SetNaturalScroll(bool enabled);
69 void SetMouseSensitivity(int value);
70 void SetTapToClickPaused(bool state);
71 void GetTouchDeviceStatus(const GetTouchDeviceStatusReply& reply);
73 base::WeakPtr<InputDeviceFactoryEvdev> GetWeakPtr();
75 private:
76 // Open device at path & starting processing events (on UI thread).
77 void AttachInputDevice(scoped_ptr<EventConverterEvdev> converter);
79 // Close device at path (on UI thread).
80 void DetachInputDevice(const base::FilePath& file_path);
82 // Update observers on device changes.
83 void NotifyDeviceChange(const EventConverterEvdev& converter);
84 void NotifyKeyboardsUpdated();
85 void NotifyTouchscreensUpdated();
86 void NotifyMouseDevicesUpdated();
87 void NotifyTouchpadDevicesUpdated();
89 void SetIntPropertyForOneType(const EventDeviceType type,
90 const std::string& name,
91 int value);
92 void SetBoolPropertyForOneType(const EventDeviceType type,
93 const std::string& name,
94 bool value);
96 // Owned per-device event converters (by path).
97 std::map<base::FilePath, EventConverterEvdev*> converters_;
99 // Task runner for our thread.
100 scoped_refptr<base::TaskRunner> task_runner_;
102 // Cursor movement.
103 CursorDelegateEvdev* cursor_;
105 #if defined(USE_EVDEV_GESTURES)
106 // Gesture library property provider (used by touchpads/mice).
107 scoped_ptr<GesturePropertyProvider> gesture_property_provider_;
108 #endif
110 // Dispatcher for events.
111 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher_;
113 // Support weak pointers for attach & detach callbacks.
114 base::WeakPtrFactory<InputDeviceFactoryEvdev> weak_ptr_factory_;
116 DISALLOW_COPY_AND_ASSIGN(InputDeviceFactoryEvdev);
119 } // namespace ui
121 #endif // UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_H_