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
,
45 const EventDeviceInfo
& devinfo
,
46 scoped_ptr
<Delegate
> delegate
);
47 ~EventReaderLibevdevCros() override
;
49 // EventConverterEvdev:
50 void OnFileCanReadWithoutBlocking(int fd
) override
;
51 bool HasKeyboard() const override
;
52 bool HasMouse() const override
;
53 bool HasTouchpad() const override
;
54 bool HasCapsLockLed() const override
;
55 void OnDisabled() override
;
58 static void OnSynReport(void* data
,
59 EventStateRec
* evstate
,
61 static void OnLogMessage(void*, int level
, const char*, ...);
63 // Input modalities for this device.
68 // LEDs for this device.
69 bool has_caps_lock_led_
;
75 EventStateRec evstate_
;
77 // Path to input device.
80 // Delegate for event processing.
81 scoped_ptr
<Delegate
> delegate_
;
83 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros
);
88 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_