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

Side by Side Diff: src/trusted/sel_universal/non_standard_pepper_events.cc

Issue 7046064: Some small refactoring and renaming of sel_universel pepper emulation components. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 // This file provives a utilty function to translate and SDL event structure
Sang Ahn 2011/06/09 20:34:48 s/provives/provides s/and/an
robertm 2011/06/09 21:02:21 Done.
8 // into a PPAPI event structure.
Sang Ahn 2011/06/09 20:34:48 s/into/to
robertm 2011/06/09 21:02:21 Done.
9 // This is very adhoc and especially the keyboard event part is very
10 // incomplete.
11
12 #include <stdint.h>
13 #include "ppapi/c/pp_input_event.h"
14
15 #include "native_client/src/trusted/sel_universal/primitives.h"
16
17 const int PP_INPUTEVENT_USER = 88;
18 const int PP_INPUTEVENT_TERMINATION = 90;
19
20 // ppapi does not have a user defined event notion.
21 // c.f. ppapi/c/pp_input_event.h
22 typedef struct {
23 int code;
24 int data1;
25 int data2;
26 } PP_InputEvent_User;
Sang Ahn 2011/06/09 20:34:48 Could this be wrapped to a namespace? It might be
robertm 2011/06/09 21:02:21 excellent idea - done On 2011/06/09 20:34:48, Sang
27
28 static PP_InputEvent_User* GetUserEvent(PP_InputEvent* event) {
29 return reinterpret_cast<PP_InputEvent_User*>(&event->u);
30 }
31
32 bool IsInvalidEvent(PP_InputEvent* event) {
33 return event->type == PP_INPUTEVENT_TYPE_UNDEFINED;
34 }
35
36
37 void MakeInvalidEvent(PP_InputEvent* event) {
38 event->type = PP_INPUTEVENT_TYPE_UNDEFINED;
39 }
40
41
42 bool IsTerminationEvent(PP_InputEvent* event) {
43 return event->type == PP_INPUTEVENT_TERMINATION;
44 }
45
46
47 void MakeTerminationEvent(PP_InputEvent* event) {
48 event->type = (PP_InputEvent_Type) PP_INPUTEVENT_TERMINATION;
49 }
50
51
52 bool IsUserEvent(PP_InputEvent* event) {
53 return event->type == PP_INPUTEVENT_USER;
54 }
55
56
57 int GetCodeFromUserEvent(PP_InputEvent* event) {
58 return GetUserEvent(event)->code;
59 }
60
61
62 int GetData1FromUserEvent(PP_InputEvent* event) {
63 return GetUserEvent(event)->data1;
64 }
65
66
67 int GetData2FromUserEvent(PP_InputEvent* event) {
68 return GetUserEvent(event)->data2;
69 }
70
71
72 void MakeUserEvent(PP_InputEvent* event, int code, int data1, int data2) {
73 event->type = (PP_InputEvent_Type) PP_INPUTEVENT_USER;
74 PP_InputEvent_User* user = GetUserEvent(event);
75 user->code = code;
76 user->data1 = data1;
77 user->data2 = data2;
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698