Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1577)

Unified Diff: services/native_viewport/platform_viewport_android.cc

Issue 856063002: Adding keyboard service. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix local variable Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/native_viewport/platform_viewport_android.h ('k') | shell/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/native_viewport/platform_viewport_android.cc
diff --git a/services/native_viewport/platform_viewport_android.cc b/services/native_viewport/platform_viewport_android.cc
index 8090625efd7963e3926c5b0392635ddfb1a42374..f3db992290fe04a8f438cd39c27074226c4577a1 100644
--- a/services/native_viewport/platform_viewport_android.cc
+++ b/services/native_viewport/platform_viewport_android.cc
@@ -11,6 +11,7 @@
#include "jni/PlatformViewportAndroid_jni.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "ui/events/event.h"
+#include "ui/events/keycodes/keyboard_code_conversion_android.h"
#include "ui/gfx/point.h"
namespace native_viewport {
@@ -115,6 +116,24 @@ bool PlatformViewportAndroid::TouchEvent(JNIEnv* env, jobject obj,
return true;
}
+bool PlatformViewportAndroid::KeyEvent(JNIEnv* env,
+ jobject obj,
+ bool pressed,
+ jint key_code,
+ jint unicode_character) {
+ ui::KeyEvent event(pressed ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
+ ui::KeyboardCodeFromAndroidKeyCode(key_code), 0);
+ event.set_platform_keycode(key_code);
+ delegate_->OnEvent(&event);
+ if (pressed && unicode_character) {
+ ui::KeyEvent char_event(unicode_character,
+ ui::KeyboardCodeFromAndroidKeyCode(key_code), 0);
+ char_event.set_platform_keycode(key_code);
+ delegate_->OnEvent(&char_event);
+ }
+ return true;
+}
+
////////////////////////////////////////////////////////////////////////////////
// PlatformViewportAndroid, PlatformViewport implementation:
« no previous file with comments | « services/native_viewport/platform_viewport_android.h ('k') | shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698