Commit 7b5b72bd authored by spang's avatar spang Committed by Commit bot

ozone: evdev: Move KeyboardEvdev usage during dispatch to EventFactoryEvdev

This is part of a series moving IO on evdev devices to a fast thread,
since UI thread is too slow for the cursor.

The keyboard layout is a UI thread object, so move all of the keyboard
processing that needs layout information outside of the device-specific
processing. Devices no longer get a KeyboardEvdev* since they will
execute on a different thread.

BUG=449710
TEST=boot link_freon & press key

Review URL: https://codereview.chromium.org/872883003

Cr-Commit-Position: refs/heads/master@{#313397}
parent 43b0a2a0
...@@ -81,6 +81,8 @@ component("events_ozone_evdev") { ...@@ -81,6 +81,8 @@ component("events_ozone_evdev") {
"evdev/input_injector_evdev.h", "evdev/input_injector_evdev.h",
"evdev/keyboard_evdev.cc", "evdev/keyboard_evdev.cc",
"evdev/keyboard_evdev.h", "evdev/keyboard_evdev.h",
"evdev/keyboard_util_evdev.cc",
"evdev/keyboard_util_evdev.h",
"evdev/mouse_button_map_evdev.cc", "evdev/mouse_button_map_evdev.cc",
"evdev/mouse_button_map_evdev.h", "evdev/mouse_button_map_evdev.h",
"evdev/tablet_event_converter_evdev.cc", "evdev/tablet_event_converter_evdev.cc",
......
...@@ -7,17 +7,20 @@ ...@@ -7,17 +7,20 @@
#include <errno.h> #include <errno.h>
#include <linux/input.h> #include <linux/input.h>
#include "base/message_loop/message_loop.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/keycodes/dom4/keycode_converter.h" #include "ui/events/keycodes/dom4/keycode_converter.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h" #include "ui/events/ozone/evdev/keyboard_util_evdev.h"
namespace ui { namespace ui {
namespace {
// Values for EV_KEY. // Values for EV_KEY.
const int kKeyReleaseValue = 0; const int kKeyReleaseValue = 0;
const int kKeyRepeatValue = 2; const int kKeyRepeatValue = 2;
} // namespace
EventConverterEvdevImpl::EventConverterEvdevImpl( EventConverterEvdevImpl::EventConverterEvdevImpl(
int fd, int fd,
base::FilePath path, base::FilePath path,
...@@ -27,7 +30,7 @@ EventConverterEvdevImpl::EventConverterEvdevImpl( ...@@ -27,7 +30,7 @@ EventConverterEvdevImpl::EventConverterEvdevImpl(
EventModifiersEvdev* modifiers, EventModifiersEvdev* modifiers,
MouseButtonMapEvdev* button_map, MouseButtonMapEvdev* button_map,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
KeyboardEvdev* keyboard, const KeyEventDispatchCallback& key_callback,
const EventDispatchCallback& callback) const EventDispatchCallback& callback)
: EventConverterEvdev(fd, path, id, type), : EventConverterEvdev(fd, path, id, type),
has_keyboard_(devinfo.HasKeyboard()), has_keyboard_(devinfo.HasKeyboard()),
...@@ -35,9 +38,9 @@ EventConverterEvdevImpl::EventConverterEvdevImpl( ...@@ -35,9 +38,9 @@ EventConverterEvdevImpl::EventConverterEvdevImpl(
x_offset_(0), x_offset_(0),
y_offset_(0), y_offset_(0),
cursor_(cursor), cursor_(cursor),
keyboard_(keyboard),
modifiers_(modifiers), modifiers_(modifiers),
button_map_(button_map), button_map_(button_map),
key_callback_(key_callback),
callback_(callback) { callback_(callback) {
} }
...@@ -117,9 +120,11 @@ void EventConverterEvdevImpl::ConvertKeyEvent(const input_event& input) { ...@@ -117,9 +120,11 @@ void EventConverterEvdevImpl::ConvertKeyEvent(const input_event& input) {
// Keyboard processing. // Keyboard processing.
DomCode key_code = KeycodeConverter::NativeKeycodeToDomCode( DomCode key_code = KeycodeConverter::NativeKeycodeToDomCode(
KeyboardEvdev::EvdevCodeToNativeCode(input.code)); EvdevCodeToNativeCode(input.code));
if (!allowed_keys_ || allowed_keys_->count(key_code)) if (!allowed_keys_ || allowed_keys_->count(key_code)) {
keyboard_->OnKeyChange(input.code, input.value != kKeyReleaseValue); key_callback_.Run(
KeyEventParams(id_, input.code, input.value != kKeyReleaseValue));
}
} }
void EventConverterEvdevImpl::ConvertMouseMoveEvent(const input_event& input) { void EventConverterEvdevImpl::ConvertMouseMoveEvent(const input_event& input) {
......
...@@ -34,7 +34,7 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl ...@@ -34,7 +34,7 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
EventModifiersEvdev* modifiers, EventModifiersEvdev* modifiers,
MouseButtonMapEvdev* button_map, MouseButtonMapEvdev* button_map,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
KeyboardEvdev* keyboard, const KeyEventDispatchCallback& key_callback,
const EventDispatchCallback& callback); const EventDispatchCallback& callback);
~EventConverterEvdevImpl() override; ~EventConverterEvdevImpl() override;
...@@ -78,16 +78,14 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl ...@@ -78,16 +78,14 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
// Shared cursor state. // Shared cursor state.
CursorDelegateEvdev* cursor_; CursorDelegateEvdev* cursor_;
// Shared keyboard state.
KeyboardEvdev* keyboard_;
// Modifier key state (shift, ctrl, etc). // Modifier key state (shift, ctrl, etc).
EventModifiersEvdev* modifiers_; EventModifiersEvdev* modifiers_;
// Shared mouse button map. // Shared mouse button map.
MouseButtonMapEvdev* button_map_; MouseButtonMapEvdev* button_map_;
// Callback for dispatching events. // Callbacks for dispatching events.
KeyEventDispatchCallback key_callback_;
EventDispatchCallback callback_; EventDispatchCallback callback_;
DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl); DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl);
......
...@@ -27,7 +27,7 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { ...@@ -27,7 +27,7 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
EventModifiersEvdev* modifiers, EventModifiersEvdev* modifiers,
MouseButtonMapEvdev* button_map, MouseButtonMapEvdev* button_map,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
KeyboardEvdev* keyboard, const KeyEventDispatchCallback& key_callback,
const EventDispatchCallback& callback) const EventDispatchCallback& callback)
: EventConverterEvdevImpl(fd, : EventConverterEvdevImpl(fd,
base::FilePath(kTestDevicePath), base::FilePath(kTestDevicePath),
...@@ -37,7 +37,7 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { ...@@ -37,7 +37,7 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
modifiers, modifiers,
button_map, button_map,
cursor, cursor,
keyboard, key_callback,
callback) { callback) {
Start(); Start();
} }
...@@ -100,12 +100,15 @@ class EventConverterEvdevImplTest : public testing::Test { ...@@ -100,12 +100,15 @@ class EventConverterEvdevImplTest : public testing::Test {
const ui::EventDispatchCallback callback = const ui::EventDispatchCallback callback =
base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest, base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest,
base::Unretained(this)); base::Unretained(this));
const ui::KeyEventDispatchCallback key_callback =
base::Bind(&EventConverterEvdevImplTest::DispatchKeyEventForTest,
base::Unretained(this));
keyboard_.reset(new ui::KeyboardEvdev( keyboard_.reset(new ui::KeyboardEvdev(
modifiers_.get(), modifiers_.get(),
ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), callback)); ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), callback));
device_.reset(new ui::MockEventConverterEvdevImpl( device_.reset(new ui::MockEventConverterEvdevImpl(
events_in_, modifiers_.get(), button_map_.get(), cursor_.get(), events_in_, modifiers_.get(), button_map_.get(), cursor_.get(),
keyboard_.get(), callback)); key_callback, callback));
} }
void TearDown() override { void TearDown() override {
device_.reset(); device_.reset();
...@@ -141,6 +144,10 @@ class EventConverterEvdevImplTest : public testing::Test { ...@@ -141,6 +144,10 @@ class EventConverterEvdevImplTest : public testing::Test {
dispatched_events_.push_back(event.release()); dispatched_events_.push_back(event.release());
} }
void DispatchKeyEventForTest(const ui::KeyEventParams& params) {
keyboard_->OnKeyChange(params.code, params.down);
}
base::MessageLoopForUI ui_loop_; base::MessageLoopForUI ui_loop_;
scoped_ptr<ui::MockCursorEvdev> cursor_; scoped_ptr<ui::MockCursorEvdev> cursor_;
......
...@@ -6,6 +6,15 @@ ...@@ -6,6 +6,15 @@
namespace ui { namespace ui {
KeyEventParams::KeyEventParams(int device_id, unsigned int code, bool down)
: device_id(device_id), code(code), down(down) {
}
KeyEventParams::KeyEventParams(const KeyEventParams& other) = default;
KeyEventParams::~KeyEventParams() {
}
TouchEventParams::TouchEventParams(int device_id, TouchEventParams::TouchEventParams(int device_id,
int touch_id, int touch_id,
EventType type, EventType type,
......
...@@ -27,6 +27,19 @@ class Event; ...@@ -27,6 +27,19 @@ class Event;
typedef base::Callback<void(scoped_ptr<Event>)> EventDispatchCallback; typedef base::Callback<void(scoped_ptr<Event>)> EventDispatchCallback;
struct EVENTS_OZONE_EVDEV_EXPORT KeyEventParams {
KeyEventParams(int device_id, unsigned int code, bool down);
KeyEventParams(const KeyEventParams& other);
~KeyEventParams();
int device_id;
unsigned int code;
bool down;
};
typedef base::Callback<void(const KeyEventParams& params)>
KeyEventDispatchCallback;
struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams { struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams {
TouchEventParams(int device_id, TouchEventParams(int device_id,
int touch_id, int touch_id,
......
...@@ -51,12 +51,12 @@ struct OpenInputDeviceParams { ...@@ -51,12 +51,12 @@ struct OpenInputDeviceParams {
// Callback for dispatching events. Call on UI thread only. // Callback for dispatching events. Call on UI thread only.
EventDispatchCallback dispatch_callback; EventDispatchCallback dispatch_callback;
KeyEventDispatchCallback key_callback;
TouchEventDispatchCallback touch_callback; TouchEventDispatchCallback touch_callback;
// State shared between devices. Must not be dereferenced on worker thread. // State shared between devices. Must not be dereferenced on worker thread.
EventModifiersEvdev* modifiers; EventModifiersEvdev* modifiers;
MouseButtonMapEvdev* button_map; MouseButtonMapEvdev* button_map;
KeyboardEvdev* keyboard;
CursorDelegateEvdev* cursor; CursorDelegateEvdev* cursor;
#if defined(USE_EVDEV_GESTURES) #if defined(USE_EVDEV_GESTURES)
GesturePropertyProvider* gesture_property_provider; GesturePropertyProvider* gesture_property_provider;
...@@ -87,7 +87,7 @@ scoped_ptr<EventConverterEvdev> CreateConverter( ...@@ -87,7 +87,7 @@ scoped_ptr<EventConverterEvdev> CreateConverter(
scoped_ptr<GestureInterpreterLibevdevCros> gesture_interp = scoped_ptr<GestureInterpreterLibevdevCros> gesture_interp =
make_scoped_ptr(new GestureInterpreterLibevdevCros( make_scoped_ptr(new GestureInterpreterLibevdevCros(
params.id, params.modifiers, params.button_map, params.cursor, params.id, params.modifiers, params.button_map, params.cursor,
params.keyboard, params.gesture_property_provider, params.gesture_property_provider, params.key_callback,
params.dispatch_callback)); params.dispatch_callback));
return make_scoped_ptr(new EventReaderLibevdevCros( return make_scoped_ptr(new EventReaderLibevdevCros(
fd, params.path, params.id, type, devinfo, gesture_interp.Pass())); fd, params.path, params.id, type, devinfo, gesture_interp.Pass()));
...@@ -111,7 +111,7 @@ scoped_ptr<EventConverterEvdev> CreateConverter( ...@@ -111,7 +111,7 @@ scoped_ptr<EventConverterEvdev> CreateConverter(
// Everything else: use EventConverterEvdevImpl. // Everything else: use EventConverterEvdevImpl.
return make_scoped_ptr<EventConverterEvdevImpl>(new EventConverterEvdevImpl( return make_scoped_ptr<EventConverterEvdevImpl>(new EventConverterEvdevImpl(
fd, params.path, params.id, type, devinfo, params.modifiers, fd, params.path, params.id, type, devinfo, params.modifiers,
params.button_map, params.cursor, params.keyboard, params.button_map, params.cursor, params.key_callback,
params.dispatch_callback)); params.dispatch_callback));
} }
...@@ -200,6 +200,10 @@ scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { ...@@ -200,6 +200,10 @@ scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() {
&modifiers_, cursor_, &keyboard_, dispatch_callback_)); &modifiers_, cursor_, &keyboard_, dispatch_callback_));
} }
void EventFactoryEvdev::PostKeyEvent(const KeyEventParams& params) {
keyboard_.OnKeyChange(params.code, params.down);
}
void EventFactoryEvdev::PostTouchEvent(const TouchEventParams& params) { void EventFactoryEvdev::PostTouchEvent(const TouchEventParams& params) {
float x = params.location.x(); float x = params.location.x();
float y = params.location.y(); float y = params.location.y();
...@@ -268,9 +272,9 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { ...@@ -268,9 +272,9 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
params->dispatch_callback = dispatch_callback_; params->dispatch_callback = dispatch_callback_;
params->modifiers = &modifiers_; params->modifiers = &modifiers_;
params->button_map = &button_map_; params->button_map = &button_map_;
params->keyboard = &keyboard_;
params->cursor = cursor_; params->cursor = cursor_;
params->key_callback = base::Bind(&EventFactoryEvdev::PostKeyEvent,
weak_ptr_factory_.GetWeakPtr());
params->touch_callback = base::Bind(&EventFactoryEvdev::PostTouchEvent, params->touch_callback = base::Bind(&EventFactoryEvdev::PostTouchEvent,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
......
...@@ -78,6 +78,9 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver, ...@@ -78,6 +78,9 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver,
InputController* input_controller() { return &input_controller_; } InputController* input_controller() { return &input_controller_; }
// Post a key event to the unified keyboard (KeyboardEvdev).
void PostKeyEvent(const KeyEventParams& params);
// Post a touch event to UI. // Post a touch event to UI.
void PostTouchEvent(const TouchEventParams& params); void PostTouchEvent(const TouchEventParams& params);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ui/events/ozone/evdev/event_modifiers_evdev.h" #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/input_injector_evdev.h" #include "ui/events/ozone/evdev/input_injector_evdev.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h" #include "ui/events/ozone/evdev/keyboard_evdev.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"
namespace ui { namespace ui {
...@@ -82,7 +83,7 @@ void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) { ...@@ -82,7 +83,7 @@ void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) {
} }
int native_keycode = KeycodeConverter::DomCodeToNativeKeycode(physical_key); int native_keycode = KeycodeConverter::DomCodeToNativeKeycode(physical_key);
int evdev_code = KeyboardEvdev::NativeCodeToEvdevCode(native_keycode); int evdev_code = NativeCodeToEvdevCode(native_keycode);
keyboard_->OnKeyChange(evdev_code, down); keyboard_->OnKeyChange(evdev_code, down);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/keycodes/dom4/keycode_converter.h" #include "ui/events/keycodes/dom4/keycode_converter.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h" #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h" #include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/ozone/layout/layout_util.h" #include "ui/events/ozone/layout/layout_util.h"
...@@ -16,8 +17,6 @@ namespace ui { ...@@ -16,8 +17,6 @@ namespace ui {
namespace { namespace {
const int kXkbKeycodeOffset = 8;
const int kRepeatDelayMs = 500; const int kRepeatDelayMs = 500;
const int kRepeatIntervalMs = 50; const int kRepeatIntervalMs = 50;
...@@ -189,19 +188,4 @@ void KeyboardEvdev::DispatchKey(unsigned int key, bool down, bool repeat) { ...@@ -189,19 +188,4 @@ void KeyboardEvdev::DispatchKey(unsigned int key, bool down, bool repeat) {
callback_.Run(make_scoped_ptr(event)); callback_.Run(make_scoped_ptr(event));
} }
// static
int KeyboardEvdev::NativeCodeToEvdevCode(int native_code) {
if (native_code == KeycodeConverter::InvalidNativeKeycode()) {
return KEY_RESERVED;
}
return native_code - kXkbKeycodeOffset;
}
// static
int KeyboardEvdev::EvdevCodeToNativeCode(int evdev_code) {
if (evdev_code == KEY_RESERVED)
return KeycodeConverter::InvalidNativeKeycode();
return evdev_code + kXkbKeycodeOffset;
}
} // namespace ui } // namespace ui
...@@ -26,8 +26,6 @@ enum class DomCode; ...@@ -26,8 +26,6 @@ enum class DomCode;
// one logical keyboard, applying modifiers & implementing key repeat. // one logical keyboard, applying modifiers & implementing key repeat.
// //
// It also currently also applies the layout. // It also currently also applies the layout.
//
// TODO(spang): Implement key repeat & turn off kernel repeat.
class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
public: public:
KeyboardEvdev(EventModifiersEvdev* modifiers, KeyboardEvdev(EventModifiersEvdev* modifiers,
...@@ -35,9 +33,6 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { ...@@ -35,9 +33,6 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
const EventDispatchCallback& callback); const EventDispatchCallback& callback);
~KeyboardEvdev(); ~KeyboardEvdev();
static int NativeCodeToEvdevCode(int native_code);
static int EvdevCodeToNativeCode(int evdev_code);
// Handlers for raw key presses & releases. // Handlers for raw key presses & releases.
void OnKeyChange(unsigned int code, bool down); void OnKeyChange(unsigned int code, bool down);
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include <linux/input.h>
#include "ui/events/keycodes/dom4/keycode_converter.h"
namespace ui {
namespace {
const int kXkbKeycodeOffset = 8;
} // namespace
int NativeCodeToEvdevCode(int native_code) {
if (native_code == KeycodeConverter::InvalidNativeKeycode())
return KEY_RESERVED;
return native_code - kXkbKeycodeOffset;
}
int EvdevCodeToNativeCode(int evdev_code) {
if (evdev_code == KEY_RESERVED)
return KeycodeConverter::InvalidNativeKeycode();
return evdev_code + kXkbKeycodeOffset;
}
} // namespace ui
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_EVENTS_OZONE_EVDEV_KEYBOARD_UTIL_EVDEV_H_
#define UI_EVENTS_OZONE_EVDEV_KEYBOARD_UTIL_EVDEV_H_
namespace ui {
int NativeCodeToEvdevCode(int native_code);
int EvdevCodeToNativeCode(int evdev_code);
} // namespace ui
#endif // UI_EVENTS_OZONE_EVDEV_KEYBOARD_UTIL_EVDEV_H_
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "ui/events/ozone/evdev/event_device_info.h" #include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/event_device_util.h" #include "ui/events/ozone/evdev/event_device_util.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h" #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h" #include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h"
#include "ui/events/ozone/evdev/mouse_button_map_evdev.h" #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
...@@ -110,16 +110,16 @@ GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros( ...@@ -110,16 +110,16 @@ GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros(
EventModifiersEvdev* modifiers, EventModifiersEvdev* modifiers,
MouseButtonMapEvdev* button_map, MouseButtonMapEvdev* button_map,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
KeyboardEvdev* keyboard,
GesturePropertyProvider* property_provider, GesturePropertyProvider* property_provider,
const KeyEventDispatchCallback& key_callback,
const EventDispatchCallback& callback) const EventDispatchCallback& callback)
: id_(id), : id_(id),
is_mouse_(false), is_mouse_(false),
modifiers_(modifiers), modifiers_(modifiers),
button_map_(button_map), button_map_(button_map),
cursor_(cursor), cursor_(cursor),
keyboard_(keyboard),
property_provider_(property_provider), property_provider_(property_provider),
key_callback_(key_callback),
dispatch_callback_(callback), dispatch_callback_(callback),
interpreter_(NULL), interpreter_(NULL),
evdev_(NULL), evdev_(NULL),
...@@ -245,8 +245,8 @@ void GestureInterpreterLibevdevCros::SetAllowedKeys( ...@@ -245,8 +245,8 @@ void GestureInterpreterLibevdevCros::SetAllowedKeys(
allowed_keys_.reset(new std::set<int>()); allowed_keys_.reset(new std::set<int>());
for (const auto& it : *allowed_keys) { for (const auto& it : *allowed_keys) {
int evdev_code = KeyboardEvdev::NativeCodeToEvdevCode( int evdev_code =
KeycodeConverter::DomCodeToNativeKeycode(it)); NativeCodeToEvdevCode(KeycodeConverter::DomCodeToNativeKeycode(it));
allowed_keys_->insert(evdev_code); allowed_keys_->insert(evdev_code);
} }
} }
...@@ -508,7 +508,7 @@ void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, ...@@ -508,7 +508,7 @@ void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev,
continue; continue;
// Dispatch key press or release to keyboard. // Dispatch key press or release to keyboard.
keyboard_->OnKeyChange(key, value); key_callback_.Run(KeyEventParams(id_, key, value));
} }
} }
......
...@@ -22,7 +22,6 @@ class EventDeviceInfo; ...@@ -22,7 +22,6 @@ class EventDeviceInfo;
class EventModifiersEvdev; class EventModifiersEvdev;
class MouseButtonMapEvdev; class MouseButtonMapEvdev;
class CursorDelegateEvdev; class CursorDelegateEvdev;
class KeyboardEvdev;
struct GestureDeviceProperties; struct GestureDeviceProperties;
class GesturePropertyProvider; class GesturePropertyProvider;
...@@ -46,8 +45,8 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -46,8 +45,8 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
EventModifiersEvdev* modifiers, EventModifiersEvdev* modifiers,
MouseButtonMapEvdev* button_map, MouseButtonMapEvdev* button_map,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
KeyboardEvdev* keyboard,
GesturePropertyProvider* property_provider, GesturePropertyProvider* property_provider,
const KeyEventDispatchCallback& key_callback,
const EventDispatchCallback& callback); const EventDispatchCallback& callback);
~GestureInterpreterLibevdevCros() override; ~GestureInterpreterLibevdevCros() override;
...@@ -105,13 +104,11 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -105,13 +104,11 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
// Shared cursor state. // Shared cursor state.
CursorDelegateEvdev* cursor_; CursorDelegateEvdev* cursor_;
// Shared keyboard state.
KeyboardEvdev* keyboard_;
// Shared gesture property provider. // Shared gesture property provider.
GesturePropertyProvider* property_provider_; GesturePropertyProvider* property_provider_;
// Callback for dispatching events. // Callbacks for dispatching events.
KeyEventDispatchCallback key_callback_;
EventDispatchCallback dispatch_callback_; EventDispatchCallback dispatch_callback_;
// Gestures interpretation state. // Gestures interpretation state.
......
...@@ -94,6 +94,8 @@ ...@@ -94,6 +94,8 @@
'evdev/input_injector_evdev.h', 'evdev/input_injector_evdev.h',
'evdev/keyboard_evdev.cc', 'evdev/keyboard_evdev.cc',
'evdev/keyboard_evdev.h', 'evdev/keyboard_evdev.h',
'evdev/keyboard_util_evdev.cc',
'evdev/keyboard_util_evdev.h',
'evdev/mouse_button_map_evdev.cc', 'evdev/mouse_button_map_evdev.cc',
'evdev/mouse_button_map_evdev.h', 'evdev/mouse_button_map_evdev.h',
'evdev/tablet_event_converter_evdev.cc', 'evdev/tablet_event_converter_evdev.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment