Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h

Issue 561243002: ozone: evdev: Move read polling into EventConverterEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ 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_ 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_
7 7
8 #include <libevdev/libevdev.h> 8 #include <libevdev/libevdev.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "ui/events/ozone/evdev/event_converter_evdev.h" 12 #include "ui/events/ozone/evdev/event_converter_evdev.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 // Basic wrapper for libevdev-cros. 16 // Basic wrapper for libevdev-cros.
17 // 17 //
18 // This drives libevdev-cros from a file descriptor and calls delegate 18 // This drives libevdev-cros from a file descriptor and calls delegate
19 // with the updated event state from libevdev-cros. 19 // with the updated event state from libevdev-cros.
20 // 20 //
21 // The library doesn't support all devices currently. In particular there 21 // The library doesn't support all devices currently. In particular there
22 // is no support for keyboard events. 22 // is no support for keyboard events.
23 class EventReaderLibevdevCros : public base::MessagePumpLibevent::Watcher, 23 class EventReaderLibevdevCros : public EventConverterEvdev {
24 public EventConverterEvdev {
25 public: 24 public:
26 class Delegate { 25 class Delegate {
27 public: 26 public:
28 virtual ~Delegate(); 27 virtual ~Delegate();
29 28
30 // Notifier for open. This is called with the initial event state. 29 // Notifier for open. This is called with the initial event state.
31 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0; 30 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0;
32 31
33 // Notifier for event. This is called with the updated event state. 32 // Notifier for event. This is called with the updated event state.
34 virtual void OnLibEvdevCrosEvent(Evdev* evdev, 33 virtual void OnLibEvdevCrosEvent(Evdev* evdev,
35 EventStateRec* state, 34 EventStateRec* state,
36 const timeval& time) = 0; 35 const timeval& time) = 0;
37 }; 36 };
38 37
39 EventReaderLibevdevCros(int fd, 38 EventReaderLibevdevCros(int fd,
40 const base::FilePath& path, 39 const base::FilePath& path,
41 scoped_ptr<Delegate> delegate); 40 scoped_ptr<Delegate> delegate);
42 ~EventReaderLibevdevCros(); 41 ~EventReaderLibevdevCros();
43 42
44 // Overridden from ui::EventDeviceEvdev. 43 // EventConverterEvdev:
45 void Start() OVERRIDE;
46 void Stop() OVERRIDE;
47
48 // Overidden from MessagePumpLibevent::Watcher.
49 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 44 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
50 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
51 45
52 private: 46 private:
53 static void OnSynReport(void* data, 47 static void OnSynReport(void* data,
54 EventStateRec* evstate, 48 EventStateRec* evstate,
55 struct timeval* tv); 49 struct timeval* tv);
56 static void OnLogMessage(void*, int level, const char*, ...); 50 static void OnLogMessage(void*, int level, const char*, ...);
57 51
58 // Libevdev state. 52 // Libevdev state.
59 Evdev evdev_; 53 Evdev evdev_;
60 54
61 // Event state. 55 // Event state.
62 EventStateRec evstate_; 56 EventStateRec evstate_;
63 57
64 // Path to input device. 58 // Path to input device.
65 base::FilePath path_; 59 base::FilePath path_;
66 60
67 // Delegate for event processing. 61 // Delegate for event processing.
68 scoped_ptr<Delegate> delegate_; 62 scoped_ptr<Delegate> delegate_;
69 63
70 // Controller for watching the input fd.
71 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
72
73 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros); 64 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros);
74 }; 65 };
75 66
76 } // namspace ui 67 } // namspace ui
77 68
78 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ 69 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698