1// Copyright 2013 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.
4
5#ifndef UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
6#define UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
7
8#include "ui/events/event.h"
9#include "ui/events/events_export.h"
10#include "ui/events/ozone/evdev/event_modifiers.h"
11#include "ui/events/ozone/event_converter_ozone.h"
12
13struct input_event;
14
15namespace ui {
16
17class EVENTS_EXPORT KeyEventConverterEvdev : public EventConverterOzone {
18 public:
19  KeyEventConverterEvdev(int fd, int id, EventModifiersEvdev* modifiers);
20  virtual ~KeyEventConverterEvdev();
21
22  // Overidden from base::MessagePumpLibevent::Watcher.
23  virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
24  virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
25
26  void ProcessEvents(const struct input_event* inputs, int count);
27
28 private:
29  // File descriptor for the /dev/input/event* instance.
30  int fd_;
31
32  // Number corresponding to * in the source evdev device: /dev/input/event*
33  int id_;
34
35  // Shared modifier state.
36  EventModifiersEvdev* modifiers_;
37
38  void ConvertKeyEvent(int key, int value);
39
40  DISALLOW_COPY_AND_ASSIGN(KeyEventConverterEvdev);
41};
42
43}  // namspace ui
44
45#endif  // UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
46
47