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_EVENT_CONVERTER_EVDEV_IMPL_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_
10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_pump_libevent.h"
12 #include "ui/events/devices/input_device.h"
13 #include "ui/events/event.h"
14 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
15 #include "ui/events/ozone/evdev/event_converter_evdev.h"
16 #include "ui/events/ozone/evdev/event_device_info.h"
17 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
18 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
19 #include "ui/events/ozone/evdev/keyboard_evdev.h"
20 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
26 class DeviceEventDispatcherEvdev
;
28 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
29 : public EventConverterEvdev
{
31 EventConverterEvdevImpl(int fd
,
35 const EventDeviceInfo
& info
,
36 CursorDelegateEvdev
* cursor
,
37 DeviceEventDispatcherEvdev
* dispatcher
);
38 ~EventConverterEvdevImpl() override
;
40 // EventConverterEvdev:
41 void OnFileCanReadWithoutBlocking(int fd
) override
;
42 bool HasKeyboard() const override
;
43 bool HasTouchpad() const override
;
44 void SetAllowedKeys(scoped_ptr
<std::set
<DomCode
>> allowed_keys
) override
;
45 void AllowAllKeys() override
;
47 void ProcessEvents(const struct input_event
* inputs
, int count
);
50 void ConvertKeyEvent(const input_event
& input
);
52 void ConvertMouseMoveEvent(const input_event
& input
);
54 void DispatchMouseButton(const input_event
& input
);
56 // Flush events delimited by EV_SYN. This is useful for handling
57 // non-axis-aligned movement properly.
60 // Input modalities for this device.
64 // Save x-axis events of relative devices to be flushed at EV_SYN time.
67 // Save y-axis events of relative devices to be flushed at EV_SYN time.
70 // Controller for watching the input fd.
71 base::MessagePumpLibevent::FileDescriptorWatcher controller_
;
73 // The keys which should be processed. nullptr if all keys should be
75 scoped_ptr
<std::set
<DomCode
>> allowed_keys_
;
77 // Shared cursor state.
78 CursorDelegateEvdev
* cursor_
;
80 // Callbacks for dispatching events.
81 DeviceEventDispatcherEvdev
* dispatcher_
;
83 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl
);
88 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_