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

Unified Diff: chrome/browser/android/vr_shell/vr_input_manager.cc

Issue 2661823002: NOT FOR REVIEW: A set of patches for Josh to work on top of. (Closed)
Patch Set: Created 3 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 | « chrome/browser/android/vr_shell/vr_input_manager.h ('k') | chrome/browser/android/vr_shell/vr_omnibox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_input_manager.cc
diff --git a/chrome/browser/android/vr_shell/vr_input_manager.cc b/chrome/browser/android/vr_shell/vr_input_manager.cc
index e8ceb40ca4f51631706b59e5cb61ae8a5b82ae9d..750c9e90718bd5ba0dac75c17768725d437e1967 100644
--- a/chrome/browser/android/vr_shell/vr_input_manager.cc
+++ b/chrome/browser/android/vr_shell/vr_input_manager.cc
@@ -9,6 +9,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
+#include "ui/events/keycodes/dom/dom_key.h"
using blink::WebGestureEvent;
using blink::WebMouseEvent;
@@ -44,11 +45,62 @@ void VrInputManager::ProcessUpdatedGesture(
std::unique_ptr<blink::WebInputEvent> event) {
if (WebInputEvent::isMouseEventType(event->type())) {
ForwardMouseEvent(static_cast<const blink::WebMouseEvent&>(*event));
- } else {
+ } else if (WebInputEvent::isGestureEventType(event->type())) {
SendGesture(static_cast<const blink::WebGestureEvent&>(*event));
}
}
+void VrInputManager::ProcessKeyboardEvent(int char_value, int modifiers) {
+
+ // DOWN
+ content::NativeWebKeyboardEvent event_d(
+ blink::WebInputEvent::Type::KeyDown, modifiers,
+ (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
+ event_d.domKey = ui::DomKey::FromCharacter(char_value);
+ event_d.nativeKeyCode = char_value;
+ event_d.windowsKeyCode = char_value;
+ LOG(INFO) << "KEY 1 ==> " << event_d.type() << " " << event_d.nativeKeyCode
+ << " " << event_d.windowsKeyCode << " " << event_d.domKey << " "
+ << event_d.domCode << " " << event_d.isSystemKey << " "
+ << event_d.text[0] << " " << event_d.unmodifiedText[0] << " "
+ << event_d.text[1] << " " << event_d.unmodifiedText[1] << " ";
+
+ ForwardKeyboardEvent(event_d);
+
+ // CHAR
+ content::NativeWebKeyboardEvent event(
+ blink::WebInputEvent::Type::Char, modifiers,
+ (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
+ event.text[0] = char_value;
+ event.unmodifiedText[0] = char_value;
+ event.domCode = char_value;
+ event.nativeKeyCode = char_value;
+ event.windowsKeyCode = char_value;
+ LOG(INFO) << "KEY ==> " << event.type() << " " << event.nativeKeyCode
+ << " " << event.windowsKeyCode << " " << event.domKey << " "
+ << event.domCode << " " << event.isSystemKey << " "
+ << event.text[0] << " " << event.unmodifiedText[0] << " "
+ << event.text[1] << " " << event.unmodifiedText[1] << " ";
+
+ ForwardKeyboardEvent(event);
+
+ // UP
+ content::NativeWebKeyboardEvent event_u(
+ blink::WebInputEvent::Type::KeyUp, modifiers,
+ (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
+ event_u.domKey = ui::DomKey::FromCharacter(char_value);
+ event_u.nativeKeyCode = char_value;
+ event_u.windowsKeyCode = char_value;
+ LOG(INFO) << "KEY 2 ==> " << event_u.type() << " " << event_u.nativeKeyCode
+ << " " << event_u.windowsKeyCode << " " << event_u.domKey << " "
+ << event_u.domCode << " " << event_u.isSystemKey << " "
+ << event_u.text[0] << " " << event_u.unmodifiedText[0] << " "
+ << event_u.text[1] << " " << event_u.unmodifiedText[1] << " ";
+
+ ForwardKeyboardEvent(event_u);
+ LOG(INFO) << "KEY ================================ ";
+}
+
void VrInputManager::SendGesture(const WebGestureEvent& gesture) {
if (gesture.type() == WebGestureEvent::GestureTapDown) {
ForwardGestureEvent(gesture);
@@ -84,4 +136,14 @@ void VrInputManager::ForwardMouseEvent(
rwh->ForwardMouseEvent(mouse_event);
}
+void VrInputManager::ForwardKeyboardEvent(
+ const content::NativeWebKeyboardEvent& keyboard_event) {
+ if (!web_contents_->GetRenderWidgetHostView())
+ return;
+ content::RenderWidgetHost* rwh =
+ web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost();
+ if (rwh)
+ rwh->ForwardKeyboardEvent(keyboard_event);
+}
+
} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/vr_input_manager.h ('k') | chrome/browser/android/vr_shell/vr_omnibox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698