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"
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
{
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;
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
,
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
;
59 static void OnSynReport(void* data
,
60 EventStateRec
* evstate
,
62 static void OnLogMessage(void*, int level
, const char*, ...);
64 // Input modalities for this device.
69 // LEDs for this device.
70 bool has_caps_lock_led_
;
76 EventStateRec evstate_
;
78 // Path to input device.
81 // Delegate for event processing.
82 scoped_ptr
<Delegate
> delegate_
;
84 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros
);
89 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_