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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « remoting/tools/javascript_key_tester/main.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <string>
6 6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_console.h"
7 #include "ppapi/cpp/input_event.h" 9 #include "ppapi/cpp/input_event.h"
8 #include "ppapi/cpp/instance.h" 10 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/var.h" 12 #include "ppapi/cpp/var.h"
11 #include "ppapi/cpp/var_dictionary.h" 13 #include "ppapi/cpp/var_dictionary.h"
12 14
13 namespace remoting { 15 namespace remoting {
14 16
15 class KeyTesterInstance : public pp::Instance { 17 class KeyTesterInstance : public pp::Instance {
16 public: 18 public:
17 explicit KeyTesterInstance(PP_Instance instance) : pp::Instance(instance) { 19 explicit KeyTesterInstance(PP_Instance instance) : pp::Instance(instance) {
18 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); 20 LogToConsole(PP_LOGLEVEL_LOG,
21 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE |
22 PP_INPUTEVENT_CLASS_WHEEL));
23 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
24 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD));
19 } 25 }
20 26
21 virtual ~KeyTesterInstance() {} 27 virtual ~KeyTesterInstance() {}
22 28
23 virtual bool HandleInputEvent(const pp::InputEvent& event) { 29 bool HandleInputEvent(const pp::InputEvent& event) override {
30 LogToConsole(PP_LOGLEVEL_LOG, EventTypeToString(event.GetType()));
24 switch (event.GetType()) { 31 switch (event.GetType()) {
25 case PP_INPUTEVENT_TYPE_KEYDOWN: 32 case PP_INPUTEVENT_TYPE_KEYDOWN:
26 case PP_INPUTEVENT_TYPE_KEYUP: 33 case PP_INPUTEVENT_TYPE_KEYUP:
27 case PP_INPUTEVENT_TYPE_CHAR: { 34 case PP_INPUTEVENT_TYPE_CHAR: {
28 HandleKeyboardEvent(pp::KeyboardInputEvent(event)); 35 HandleKeyboardEvent(pp::KeyboardInputEvent(event));
29 break; 36 break;
30 } 37 }
38 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
39 case PP_INPUTEVENT_TYPE_MOUSEUP:
40 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
41 case PP_INPUTEVENT_TYPE_MOUSEENTER:
42 case PP_INPUTEVENT_TYPE_MOUSELEAVE:
43 case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
44 HandleMouseEvent(pp::MouseInputEvent(event));
45 break;
46 }
47 case PP_INPUTEVENT_TYPE_WHEEL: {
48 HandleWheelEvent(pp::WheelInputEvent(event));
49 break;
50 }
31 default: 51 default:
32 break; 52 break;
33 } 53 }
34 return true; 54 return true;
35 } 55 }
36 56
37 private: 57 private:
38 void HandleKeyboardEvent(const pp::KeyboardInputEvent& event) { 58 void HandleKeyboardEvent(const pp::KeyboardInputEvent& event) {
39 pp::VarDictionary out; 59 pp::VarDictionary out;
40 out.Set("type", EventTypeToString(event.GetType())); 60 out.Set("type", EventTypeToString(event.GetType()));
41 out.Set("modifiers", (double)event.GetModifiers()); 61 out.Set("modifiers", (double)event.GetModifiers());
42 out.Set("keyCode", (double)event.GetKeyCode()); 62 out.Set("keyCode", (double)event.GetKeyCode());
43 out.Set("characterText", event.GetCharacterText()); 63 out.Set("characterText", event.GetCharacterText());
44 out.Set("code", event.GetCode()); 64 out.Set("code", event.GetCode());
45 PostMessage(out); 65 PostMessage(out);
46 } 66 }
47 67
48 std::string EventTypeToString(PP_InputEvent_Type t) { 68 void HandleMouseEvent(const pp::MouseInputEvent& event) {
69 pp::VarDictionary out;
70 out.Set("type", EventTypeToString(event.GetType()));
71 out.Set("button", (double)event.GetButton());
72 out.Set("position", PointToString(event.GetPosition()));
73 out.Set("clickCount", event.GetClickCount());
74 out.Set("movement", PointToString(event.GetMovement()));
75 PostMessage(out);
76 }
77
78 void HandleWheelEvent(const pp::WheelInputEvent& event) {
79 pp::VarDictionary out;
80 out.Set("type", EventTypeToString(event.GetType()));
81 out.Set("delta", PointToString(event.GetDelta()));
82 out.Set("ticks", PointToString(event.GetTicks()));
83 out.Set("scrollByPage", event.GetScrollByPage());
84 PostMessage(out);
85 }
86
87 template <typename T>
88 static std::string PointToString(const T& point) {
89 return std::to_string(point.x()) + ", " + std::to_string(point.y());
90 }
91
92 static std::string EventTypeToString(PP_InputEvent_Type t) {
49 switch (t) { 93 switch (t) {
50 case PP_INPUTEVENT_TYPE_UNDEFINED: 94 case PP_INPUTEVENT_TYPE_UNDEFINED:
51 return "UNDEFINED"; 95 return "UNDEFINED";
52 case PP_INPUTEVENT_TYPE_MOUSEDOWN: 96 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
53 return "MOUSEDOWN"; 97 return "MOUSEDOWN";
54 case PP_INPUTEVENT_TYPE_MOUSEUP: 98 case PP_INPUTEVENT_TYPE_MOUSEUP:
55 return "MOUSEUP"; 99 return "MOUSEUP";
56 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 100 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
57 return "MOUSEMOVE"; 101 return "MOUSEMOVE";
58 case PP_INPUTEVENT_TYPE_MOUSEENTER: 102 case PP_INPUTEVENT_TYPE_MOUSEENTER:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 149
106 } // namespace remoting 150 } // namespace remoting
107 151
108 namespace pp { 152 namespace pp {
109 153
110 Module* CreateModule() { 154 Module* CreateModule() {
111 return new remoting::KeyTesterModule(); 155 return new remoting::KeyTesterModule();
112 } 156 }
113 157
114 } // namespace pp 158 } // namespace pp
OLDNEW
« 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