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

Unified Diff: remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc

Issue 2063623002: [Chromoting] Log mouse events in remoting_key_tester (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « remoting/tools/javascript_key_tester/main.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
diff --git a/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc b/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
index 408725c5e4a77b7ae7f401e79d80114736b900ef..ac68721b73ef44dccb2a1ba8f5f1e04cff7d7c51 100644
--- a/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
+++ b/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <sstream>
+#include <string>
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_console.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
@@ -15,12 +17,17 @@ namespace remoting {
class KeyTesterInstance : public pp::Instance {
public:
explicit KeyTesterInstance(PP_Instance instance) : pp::Instance(instance) {
- RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
+ LogToConsole(PP_LOGLEVEL_LOG,
+ RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE |
+ PP_INPUTEVENT_CLASS_WHEEL));
+ LogToConsole(PP_LOGLEVEL_LOG,
Jamie 2016/06/13 17:25:42 I don't think you want LogToConsole here. If you d
Hzj_jie 2016/06/13 20:23:09 Oh, these are for debugging purpose, I should remo
+ RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD));
}
virtual ~KeyTesterInstance() {}
- virtual bool HandleInputEvent(const pp::InputEvent& event) {
+ bool HandleInputEvent(const pp::InputEvent& event) override {
+ LogToConsole(PP_LOGLEVEL_LOG, EventTypeToString(event.GetType()));
switch (event.GetType()) {
case PP_INPUTEVENT_TYPE_KEYDOWN:
case PP_INPUTEVENT_TYPE_KEYUP:
@@ -28,6 +35,19 @@ class KeyTesterInstance : public pp::Instance {
HandleKeyboardEvent(pp::KeyboardInputEvent(event));
break;
}
+ case PP_INPUTEVENT_TYPE_MOUSEDOWN:
+ case PP_INPUTEVENT_TYPE_MOUSEUP:
+ case PP_INPUTEVENT_TYPE_MOUSEMOVE:
+ case PP_INPUTEVENT_TYPE_MOUSEENTER:
+ case PP_INPUTEVENT_TYPE_MOUSELEAVE:
+ case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
+ HandleMouseEvent(pp::MouseInputEvent(event));
+ break;
+ }
+ case PP_INPUTEVENT_TYPE_WHEEL: {
+ HandleWheelEvent(pp::WheelInputEvent(event));
+ break;
+ }
default:
break;
}
@@ -45,7 +65,31 @@ class KeyTesterInstance : public pp::Instance {
PostMessage(out);
}
- std::string EventTypeToString(PP_InputEvent_Type t) {
+ void HandleMouseEvent(const pp::MouseInputEvent& event) {
+ pp::VarDictionary out;
+ out.Set("type", EventTypeToString(event.GetType()));
+ out.Set("button", (double)event.GetButton());
+ out.Set("position", PointToString(event.GetPosition()));
+ out.Set("clickCount", event.GetClickCount());
+ out.Set("movement", PointToString(event.GetMovement()));
+ PostMessage(out);
+ }
+
+ void HandleWheelEvent(const pp::WheelInputEvent& event) {
+ pp::VarDictionary out;
+ out.Set("type", EventTypeToString(event.GetType()));
+ out.Set("delta", PointToString(event.GetDelta()));
+ out.Set("ticks", PointToString(event.GetTicks()));
+ out.Set("scrollByPage", event.GetScrollByPage());
+ PostMessage(out);
+ }
+
+ template <typename T>
+ static std::string PointToString(const T& point) {
+ return std::to_string(point.x()) + ", " + std::to_string(point.y());
+ }
+
+ static std::string EventTypeToString(PP_InputEvent_Type t) {
switch (t) {
case PP_INPUTEVENT_TYPE_UNDEFINED:
return "UNDEFINED";
« no previous file with comments | « remoting/tools/javascript_key_tester/main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698