Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / ozone / evdev / libgestures_glue / event_reader_libevdev_cros.h
blob1631c5b685bdca6c558e02a7867572f05d419698
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"
14 namespace ui {
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 {
25 public:
26 class Delegate {
27 public:
28 virtual ~Delegate();
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,
35 EventStateRec* state,
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;
46 void Stop() OVERRIDE;
48 // Overidden from MessagePumpLibevent::Watcher.
49 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
50 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
52 private:
53 static void OnSynReport(void* data,
54 EventStateRec* evstate,
55 struct timeval* tv);
56 static void OnLogMessage(void*, int level, const char*, ...);
58 // Libevdev state.
59 Evdev evdev_;
61 // Event state.
62 EventStateRec evstate_;
64 // Path to input device.
65 base::FilePath path_;
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);
76 } // namspace ui
78 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_