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

Side by Side Diff: remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc

Issue 884703006: Handling PNaCl KeyboardInputEvent(s) in the key tester app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding disable_nacl==0 condition and disabling _jscompile target. Created 5 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <sstream>
6
7 #include "ppapi/cpp/input_event.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/var.h"
11 #include "ppapi/cpp/var_dictionary.h"
12
13 namespace remoting {
14
15 class KeyTesterInstance : public pp::Instance {
16 public:
17 explicit KeyTesterInstance(PP_Instance instance) : pp::Instance(instance) {
18 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
19 }
20
21 virtual ~KeyTesterInstance() {}
22
23 virtual bool HandleInputEvent(const pp::InputEvent& event) {
24 switch (event.GetType()) {
25 case PP_INPUTEVENT_TYPE_KEYDOWN:
26 case PP_INPUTEVENT_TYPE_KEYUP:
27 case PP_INPUTEVENT_TYPE_CHAR: {
28 HandleKeyboardEvent(pp::KeyboardInputEvent(event));
29 break;
30 }
31 default:
32 break;
33 }
34 return true;
35 }
36
37 private:
38 void HandleKeyboardEvent(const pp::KeyboardInputEvent& event) {
39 pp::VarDictionary out;
40 out.Set("type", EventTypeToString(event.GetType()));
41 out.Set("modifiers", (double)event.GetModifiers());
42 out.Set("keyCode", (double)event.GetKeyCode());
43 out.Set("characterText", event.GetCharacterText());
44 out.Set("code", event.GetCode());
45 PostMessage(out);
46 }
47
48 std::string EventTypeToString(PP_InputEvent_Type t) {
49 switch (t) {
50 case PP_INPUTEVENT_TYPE_UNDEFINED:
51 return "UNDEFINED";
52 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
53 return "MOUSEDOWN";
54 case PP_INPUTEVENT_TYPE_MOUSEUP:
55 return "MOUSEUP";
56 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
57 return "MOUSEMOVE";
58 case PP_INPUTEVENT_TYPE_MOUSEENTER:
59 return "MOUSEENTER";
60 case PP_INPUTEVENT_TYPE_MOUSELEAVE:
61 return "MOUSELEAVE";
62 case PP_INPUTEVENT_TYPE_WHEEL:
63 return "WHEEL";
64 case PP_INPUTEVENT_TYPE_RAWKEYDOWN:
65 return "RAWKEYDOWN";
66 case PP_INPUTEVENT_TYPE_KEYDOWN:
67 return "KEYDOWN";
68 case PP_INPUTEVENT_TYPE_KEYUP:
69 return "KEYUP";
70 case PP_INPUTEVENT_TYPE_CHAR:
71 return "CHAR";
72 case PP_INPUTEVENT_TYPE_CONTEXTMENU:
73 return "CONTEXTMENU";
74 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START:
75 return "IME_COMPOSITION_START";
76 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE:
77 return "IME_COMPOSITION_UPDATE";
78 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_END:
79 return "IME_COMPOSITION_END";
80 case PP_INPUTEVENT_TYPE_IME_TEXT:
81 return "IME_TEXT";
82 case PP_INPUTEVENT_TYPE_TOUCHSTART:
83 return "TOUCHSTART";
84 case PP_INPUTEVENT_TYPE_TOUCHMOVE:
85 return "TOUCHMOVE";
86 case PP_INPUTEVENT_TYPE_TOUCHEND:
87 return "TOUCHEND";
88 case PP_INPUTEVENT_TYPE_TOUCHCANCEL:
89 return "TOUCHCANCEL";
90 default:
91 return "[UNRECOGNIZED]";
92 }
93 }
94 };
95
96 class KeyTesterModule : public pp::Module {
97 public:
98 KeyTesterModule() : pp::Module() {}
99 virtual ~KeyTesterModule() {}
100
101 virtual pp::Instance* CreateInstance(PP_Instance instance) {
102 return new KeyTesterInstance(instance);
103 }
104 };
105
106 } // namespace remoting
107
108 namespace pp {
109
110 Module* CreateModule() {
111 return new remoting::KeyTesterModule();
112 }
113
114 } // namespace pp
OLDNEW
« no previous file with comments | « remoting/tools/javascript_key_tester/main.js ('k') | remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.nmf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698