Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / events / ozone / evdev / libgestures_glue / event_reader_libevdev_cros.h
blobe0869015e24dbf3e6e284a6e6483af7fc9365338
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"
13 #include "ui/events/ozone/evdev/event_device_info.h"
15 namespace ui {
17 // Basic wrapper for libevdev-cros.
19 // This drives libevdev-cros from a file descriptor and calls delegate
20 // with the updated event state from libevdev-cros.
22 // The library doesn't support all devices currently. In particular there
23 // is no support for keyboard events.
24 class EventReaderLibevdevCros : 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;
38 // Notifier for stop. This is called with the final event state.
39 virtual void OnLibEvdevCrosStopped(Evdev* evdev, EventStateRec* state) = 0;
42 EventReaderLibevdevCros(int fd,
43 const base::FilePath& path,
44 int id,
45 InputDeviceType type,
46 const EventDeviceInfo& devinfo,
47 scoped_ptr<Delegate> delegate);
48 ~EventReaderLibevdevCros() override;
50 // EventConverterEvdev:
51 void OnFileCanReadWithoutBlocking(int fd) override;
52 bool HasKeyboard() const override;
53 bool HasMouse() const override;
54 bool HasTouchpad() const override;
55 bool HasCapsLockLed() const override;
56 void OnStopped() override;
58 private:
59 static void OnSynReport(void* data,
60 EventStateRec* evstate,
61 struct timeval* tv);
62 static void OnLogMessage(void*, int level, const char*, ...);
64 // Input modalities for this device.
65 bool has_keyboard_;
66 bool has_mouse_;
67 bool has_touchpad_;
69 // LEDs for this device.
70 bool has_caps_lock_led_;
72 // Libevdev state.
73 Evdev evdev_;
75 // Event state.
76 EventStateRec evstate_;
78 // Path to input device.
79 base::FilePath path_;
81 // Delegate for event processing.
82 scoped_ptr<Delegate> delegate_;
84 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros);
87 } // namspace ui
89 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_