OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "native_client/src/include/nacl_scoped_ptr.h" | 10 #include "native_client/src/include/nacl_scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using ppapi_proxy::DebugPrintf; | 23 using ppapi_proxy::DebugPrintf; |
24 using ppapi_proxy::GetMainSrpcChannel; | 24 using ppapi_proxy::GetMainSrpcChannel; |
25 using ppapi_proxy::kInvalidResourceId; | 25 using ppapi_proxy::kInvalidResourceId; |
26 using ppapi_proxy::PluginInputEvent; | 26 using ppapi_proxy::PluginInputEvent; |
27 using ppapi_proxy::PluginResource; | 27 using ppapi_proxy::PluginResource; |
28 using ppapi_proxy::Serialize; | 28 using ppapi_proxy::Serialize; |
29 | 29 |
30 // InputEvent ------------------------------------------------------------------ | 30 // InputEvent ------------------------------------------------------------------ |
31 | 31 |
32 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { | 32 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { |
33 DebugPrintf("PPB_InputEvent::RequestInputEvents: instance=%"NACL_PRIu32", " | 33 DebugPrintf("PPB_InputEvent::RequestInputEvents: instance=%"NACL_PRId32", " |
34 "event_classes=%"NACL_PRIu32"\n", | 34 "event_classes=%"NACL_PRIu32"\n", |
35 instance, event_classes); | 35 instance, event_classes); |
36 uint32_t success = 0; | 36 uint32_t success = 0; |
37 NaClSrpcError srpc_result = | 37 NaClSrpcError srpc_result = |
38 PpbInputEventRpcClient::PPB_InputEvent_RequestInputEvents( | 38 PpbInputEventRpcClient::PPB_InputEvent_RequestInputEvents( |
39 GetMainSrpcChannel(), | 39 GetMainSrpcChannel(), |
40 instance, | 40 instance, |
41 static_cast<int32_t>(event_classes), | 41 static_cast<int32_t>(event_classes), |
42 false, // false -> Don't filter. | 42 false, // false -> Don't filter. |
43 reinterpret_cast<int32_t*>(&success)); | 43 reinterpret_cast<int32_t*>(&success)); |
44 if (srpc_result == NACL_SRPC_RESULT_OK) { | 44 if (srpc_result == NACL_SRPC_RESULT_OK) { |
45 return success; | 45 return success; |
46 } | 46 } |
47 return PP_ERROR_FAILED; | 47 return PP_ERROR_FAILED; |
48 } | 48 } |
49 | 49 |
50 int32_t RequestFilteringInputEvents(PP_Instance instance, | 50 int32_t RequestFilteringInputEvents(PP_Instance instance, |
51 uint32_t event_classes) { | 51 uint32_t event_classes) { |
52 DebugPrintf("PPB_InputEvent::RequestFilteringInputEvents: instance=" | 52 DebugPrintf("PPB_InputEvent::RequestFilteringInputEvents: instance=" |
53 "%"NACL_PRIu32", event_classes=%"NACL_PRIu32"\n", | 53 "%"NACL_PRId32", event_classes=%"NACL_PRIu32"\n", |
54 instance, event_classes); | 54 instance, event_classes); |
55 uint32_t success = 0; | 55 uint32_t success = 0; |
56 NaClSrpcError srpc_result = | 56 NaClSrpcError srpc_result = |
57 PpbInputEventRpcClient::PPB_InputEvent_RequestInputEvents( | 57 PpbInputEventRpcClient::PPB_InputEvent_RequestInputEvents( |
58 GetMainSrpcChannel(), | 58 GetMainSrpcChannel(), |
59 instance, | 59 instance, |
60 static_cast<int32_t>(event_classes), | 60 static_cast<int32_t>(event_classes), |
61 true, // true -> Filter. | 61 true, // true -> Filter. |
62 reinterpret_cast<int32_t*>(&success)); | 62 reinterpret_cast<int32_t*>(&success)); |
63 if (srpc_result == NACL_SRPC_RESULT_OK) { | 63 if (srpc_result == NACL_SRPC_RESULT_OK) { |
64 return success; | 64 return success; |
65 } | 65 } |
66 return PP_ERROR_FAILED; | 66 return PP_ERROR_FAILED; |
67 } | 67 } |
68 | 68 |
69 void ClearInputEventRequest(PP_Instance instance, | 69 void ClearInputEventRequest(PP_Instance instance, |
70 uint32_t event_classes) { | 70 uint32_t event_classes) { |
71 DebugPrintf("PPB_InputEvent::ClearInputEventRequest: instance=%"NACL_PRIu32 | 71 DebugPrintf("PPB_InputEvent::ClearInputEventRequest: instance=%"NACL_PRId32 |
72 ", event_classes=%"NACL_PRIu32"\n", | 72 ", event_classes=%"NACL_PRIu32"\n", |
73 instance, event_classes); | 73 instance, event_classes); |
74 PpbInputEventRpcClient::PPB_InputEvent_ClearInputEventRequest( | 74 PpbInputEventRpcClient::PPB_InputEvent_ClearInputEventRequest( |
75 GetMainSrpcChannel(), | 75 GetMainSrpcChannel(), |
76 instance, | 76 instance, |
77 static_cast<int32_t>(event_classes)); | 77 static_cast<int32_t>(event_classes)); |
78 } | 78 } |
79 | 79 |
80 // Helper RAII class to get the PluginInputEvent from the PP_Resource and hold | 80 // Helper RAII class to get the PluginInputEvent from the PP_Resource and hold |
81 // it with a scoped_refptr. Also does a DebugPrintf. | 81 // it with a scoped_refptr. Also does a DebugPrintf. |
82 class InputEventGetter { | 82 class InputEventGetter { |
83 public: | 83 public: |
84 InputEventGetter(PP_Resource resource, const char* function_name) { | 84 InputEventGetter(PP_Resource resource, const char* function_name) { |
85 DebugPrintf("PPB_InputEvent::%s: resource=%"NACL_PRIu32"\n", | 85 DebugPrintf("PPB_InputEvent::%s: resource=%"NACL_PRId32"\n", |
86 function_name, | 86 function_name, |
87 resource); | 87 resource); |
88 input_event_ = | 88 input_event_ = |
89 PluginResource::GetAs<PluginInputEvent>(resource); | 89 PluginResource::GetAs<PluginInputEvent>(resource); |
90 } | 90 } |
91 | 91 |
92 PluginInputEvent* get() { | 92 PluginInputEvent* get() { |
93 return input_event_.get(); | 93 return input_event_.get(); |
94 } | 94 } |
95 | 95 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance, | 132 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance, |
133 PP_InputEvent_Type type, | 133 PP_InputEvent_Type type, |
134 PP_TimeTicks time_stamp, | 134 PP_TimeTicks time_stamp, |
135 uint32_t modifiers, | 135 uint32_t modifiers, |
136 PP_InputEvent_MouseButton mouse_button, | 136 PP_InputEvent_MouseButton mouse_button, |
137 const PP_Point* mouse_position, | 137 const PP_Point* mouse_position, |
138 int32_t click_count, | 138 int32_t click_count, |
139 const PP_Point* mouse_movement) { | 139 const PP_Point* mouse_movement) { |
140 DebugPrintf("PPB_InputEvent::CreateMouseInputEvent: instance=" | 140 DebugPrintf("PPB_InputEvent::CreateMouseInputEvent: instance=" |
141 "%"NACL_PRIu32", type=%d, time_stamp=%lf, modifiers=" | 141 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" |
142 "%"NACL_PRIu32", mouse_button=%d, x=%"NACL_PRId32", y=" | 142 "%"NACL_PRIu32", mouse_button=%d, x=%"NACL_PRId32", y=" |
143 "%"NACL_PRId32", click_count=%d, movement_x=" | 143 "%"NACL_PRId32", click_count=%d, movement_x=" |
144 "%"NACL_PRId32", movement_y=%"NACL_PRId32"\n", | 144 "%"NACL_PRId32", movement_y=%"NACL_PRId32"\n", |
145 instance, type, time_stamp, modifiers, mouse_button, | 145 instance, type, time_stamp, modifiers, mouse_button, |
146 mouse_position->x, mouse_position->y, click_count, | 146 mouse_position->x, mouse_position->y, click_count, |
147 mouse_movement->x, mouse_movement->y); | 147 mouse_movement->x, mouse_movement->y); |
148 PP_Resource resource_id = kInvalidResourceId; | 148 PP_Resource resource_id = kInvalidResourceId; |
149 NaClSrpcError srpc_result = | 149 NaClSrpcError srpc_result = |
150 PpbInputEventRpcClient::PPB_InputEvent_CreateMouseInputEvent( | 150 PpbInputEventRpcClient::PPB_InputEvent_CreateMouseInputEvent( |
151 GetMainSrpcChannel(), | 151 GetMainSrpcChannel(), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 // Wheel ----------------------------------------------------------------------- | 211 // Wheel ----------------------------------------------------------------------- |
212 | 212 |
213 PP_Resource CreateWheelInputEvent(PP_Instance instance, | 213 PP_Resource CreateWheelInputEvent(PP_Instance instance, |
214 PP_TimeTicks time_stamp, | 214 PP_TimeTicks time_stamp, |
215 uint32_t modifiers, | 215 uint32_t modifiers, |
216 const PP_FloatPoint* wheel_delta, | 216 const PP_FloatPoint* wheel_delta, |
217 const PP_FloatPoint* wheel_ticks, | 217 const PP_FloatPoint* wheel_ticks, |
218 PP_Bool scroll_by_page) { | 218 PP_Bool scroll_by_page) { |
219 DebugPrintf("PPB_InputEvent::CreateWheelInputEvent: instance=" | 219 DebugPrintf("PPB_InputEvent::CreateWheelInputEvent: instance=" |
220 "%"NACL_PRIu32", time_stamp=%lf, modifiers=" | 220 "%"NACL_PRId32", time_stamp=%lf, modifiers=" |
221 "%"NACL_PRIu32", delta.x=%d, delta.y=%d, ticks.x=%d, ticks.y=%d, " | 221 "%"NACL_PRIu32", delta.x=%d, delta.y=%d, ticks.x=%d, ticks.y=%d, " |
222 "scroll_by_page=%s\n", | 222 "scroll_by_page=%s\n", |
223 instance, time_stamp, modifiers, wheel_delta->x, wheel_delta->y, | 223 instance, time_stamp, modifiers, wheel_delta->x, wheel_delta->y, |
224 wheel_ticks->x, wheel_ticks->y, | 224 wheel_ticks->x, wheel_ticks->y, |
225 (scroll_by_page ? "true" : "false")); | 225 (scroll_by_page ? "true" : "false")); |
226 PP_Resource resource_id = kInvalidResourceId; | 226 PP_Resource resource_id = kInvalidResourceId; |
227 NaClSrpcError srpc_result = | 227 NaClSrpcError srpc_result = |
228 PpbInputEventRpcClient::PPB_InputEvent_CreateWheelInputEvent( | 228 PpbInputEventRpcClient::PPB_InputEvent_CreateWheelInputEvent( |
229 GetMainSrpcChannel(), | 229 GetMainSrpcChannel(), |
230 instance, | 230 instance, |
(...skipping 29 matching lines...) Expand all Loading... |
260 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); | 260 IMPLEMENT_RESOURCE_THUNK(GetWheelScrollByPage, wheel_event, PP_FALSE); |
261 } | 261 } |
262 | 262 |
263 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, | 263 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, |
264 PP_InputEvent_Type type, | 264 PP_InputEvent_Type type, |
265 PP_TimeTicks time_stamp, | 265 PP_TimeTicks time_stamp, |
266 uint32_t modifiers, | 266 uint32_t modifiers, |
267 uint32_t key_code, | 267 uint32_t key_code, |
268 struct PP_Var character_text) { | 268 struct PP_Var character_text) { |
269 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" | 269 DebugPrintf("PPB_InputEvent::CreateKeyboardInputEvent: instance=" |
270 "%"NACL_PRIu32", type=%d, time_stamp=%lf, modifiers=" | 270 "%"NACL_PRId32", type=%d, time_stamp=%lf, modifiers=" |
271 "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", | 271 "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", |
272 instance, type, time_stamp, modifiers, key_code); | 272 instance, type, time_stamp, modifiers, key_code); |
273 // Serialize the character_text Var. | 273 // Serialize the character_text Var. |
274 uint32_t text_size = 0; | 274 uint32_t text_size = 0; |
275 nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, | 275 nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, |
276 &text_size)); | 276 &text_size)); |
277 PP_Resource resource_id = kInvalidResourceId; | 277 PP_Resource resource_id = kInvalidResourceId; |
278 NaClSrpcError srpc_result = | 278 NaClSrpcError srpc_result = |
279 PpbInputEventRpcClient::PPB_InputEvent_CreateKeyboardInputEvent( | 279 PpbInputEventRpcClient::PPB_InputEvent_CreateKeyboardInputEvent( |
280 GetMainSrpcChannel(), | 280 GetMainSrpcChannel(), |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 uint32_t PluginInputEvent::GetKeyCode() const { | 433 uint32_t PluginInputEvent::GetKeyCode() const { |
434 return input_event_data_.key_code; | 434 return input_event_data_.key_code; |
435 } | 435 } |
436 | 436 |
437 PP_Var PluginInputEvent::GetCharacterText() const { | 437 PP_Var PluginInputEvent::GetCharacterText() const { |
438 PPBVarInterface()->AddRef(character_text_); | 438 PPBVarInterface()->AddRef(character_text_); |
439 return character_text_; | 439 return character_text_; |
440 } | 440 } |
441 | 441 |
442 } // namespace ppapi_proxy | 442 } // namespace ppapi_proxy |
OLD | NEW |