15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file.
48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/files/file_path.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/message_loop/message_pump_libevent.h"
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/events/event.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/events/ozone/evdev/event_converter_evdev.h"
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)struct input_event;
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace ui {
188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class EVENTS_OZONE_EVDEV_EXPORT KeyEventConverterEvdev
201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    : public EventConverterEvdev {
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public:
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  KeyEventConverterEvdev(int fd,
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         base::FilePath path,
240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         EventModifiersEvdev* modifiers,
250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         const EventDispatchCallback& dispatch);
268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual ~KeyEventConverterEvdev();
278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // EventConverterEvdev:
298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void ProcessEvents(const struct input_event* inputs, int count);
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private:
341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Callback for dispatching events.
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EventDispatchCallback callback_;
36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
37f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Shared modifier state.
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EventModifiersEvdev* modifiers_;
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Controller for watching the input fd.
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::MessagePumpLibevent::FileDescriptorWatcher controller_;
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void ConvertKeyEvent(int key, int value);
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(KeyEventConverterEvdev);
468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)};
478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}  // namspace ui
498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif  // UI_EVENTS_OZONE_EVDEV_KEY_EVENT_CONVERTER_EVDEV_H_
518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
52