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_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_
6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_
8 #include <libevdev/libevdev.h>
10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h"
12 #include "ui/events/ozone/evdev/event_converter_evdev.h"
16 // Basic wrapper for libevdev-cros.
18 // This drives libevdev-cros from a file descriptor and calls delegate
19 // with the updated event state from libevdev-cros.
21 // The library doesn't support all devices currently. In particular there
22 // is no support for keyboard events.
23 class EventReaderLibevdevCros
: public base::MessagePumpLibevent::Watcher
,
24 public EventConverterEvdev
{
30 // Notifier for open. This is called with the initial event state.
31 virtual void OnLibEvdevCrosOpen(Evdev
* evdev
, EventStateRec
* evstate
) = 0;
33 // Notifier for event. This is called with the updated event state.
34 virtual void OnLibEvdevCrosEvent(Evdev
* evdev
,
36 const timeval
& time
) = 0;
39 EventReaderLibevdevCros(int fd
,
40 const base::FilePath
& path
,
41 scoped_ptr
<Delegate
> delegate
);
42 ~EventReaderLibevdevCros();
44 // Overridden from ui::EventDeviceEvdev.
45 void Start() OVERRIDE
;
48 // Overidden from MessagePumpLibevent::Watcher.
49 virtual void OnFileCanReadWithoutBlocking(int fd
) OVERRIDE
;
50 virtual void OnFileCanWriteWithoutBlocking(int fd
) OVERRIDE
;
53 static void OnSynReport(void* data
,
54 EventStateRec
* evstate
,
56 static void OnLogMessage(void*, int level
, const char*, ...);
62 EventStateRec evstate_
;
64 // Path to input device.
67 // Delegate for event processing.
68 scoped_ptr
<Delegate
> delegate_
;
70 // Controller for watching the input fd.
71 base::MessagePumpLibevent::FileDescriptorWatcher controller_
;
73 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros
);
78 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_