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

Side by Side Diff: ppapi/shared_impl/ppb_input_event_shared.cc

Issue 10543159: ppapi: Add support for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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
« no previous file with comments | « ppapi/shared_impl/ppb_input_event_shared.h ('k') | ppapi/tests/all_c_includes.h » ('j') | 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) 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 "ppapi/shared_impl/ppb_input_event_shared.h" 5 #include "ppapi/shared_impl/ppb_input_event_shared.h"
6 6
7 #include "ppapi/shared_impl/var.h" 7 #include "ppapi/shared_impl/var.h"
8 8
9 using ppapi::thunk::PPB_InputEvent_API; 9 using ppapi::thunk::PPB_InputEvent_API;
10 10
11 namespace ppapi { 11 namespace ppapi {
12 12
13 InputEventData::InputEventData() 13 InputEventData::InputEventData()
14 : is_filtered(false), 14 : is_filtered(false),
15 event_type(PP_INPUTEVENT_TYPE_UNDEFINED), 15 event_type(PP_INPUTEVENT_TYPE_UNDEFINED),
16 event_time_stamp(0.0), 16 event_time_stamp(0.0),
17 event_modifiers(0), 17 event_modifiers(0),
18 mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE), 18 mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE),
19 mouse_position(PP_MakePoint(0, 0)), 19 mouse_position(PP_MakePoint(0, 0)),
20 mouse_click_count(0), 20 mouse_click_count(0),
21 mouse_movement(PP_MakePoint(0, 0)), 21 mouse_movement(PP_MakePoint(0, 0)),
22 wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)), 22 wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)),
23 wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)), 23 wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)),
24 wheel_scroll_by_page(false), 24 wheel_scroll_by_page(false),
25 key_code(0), 25 key_code(0),
26 character_text(), 26 character_text(),
27 composition_target_segment(-1), 27 composition_target_segment(-1),
28 composition_selection_start(0), 28 composition_selection_start(0),
29 composition_selection_end(0) { 29 composition_selection_end(0),
30 touches(),
31 changed_touches(),
32 target_touches() {
30 } 33 }
31 34
32 InputEventData::~InputEventData() { 35 InputEventData::~InputEventData() {
33 } 36 }
34 37
35 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type, 38 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type,
36 PP_Instance instance, 39 PP_Instance instance,
37 const InputEventData& data) 40 const InputEventData& data)
38 : Resource(type, instance), 41 : Resource(type, instance),
39 data_(data) { 42 data_(data) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return data_.composition_target_segment; 123 return data_.composition_target_segment;
121 } 124 }
122 125
123 void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { 126 void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) {
124 if (start) 127 if (start)
125 *start = data_.composition_selection_start; 128 *start = data_.composition_selection_start;
126 if (end) 129 if (end)
127 *end = data_.composition_selection_end; 130 *end = data_.composition_selection_end;
128 } 131 }
129 132
133 void PPB_InputEvent_Shared::AddTouchPoint(PP_TouchListType list,
134 const PP_TouchPoint& point) {
135 switch (list) {
136 case PP_TOUCHLIST_TYPE_TOUCHES:
137 data_.touches.push_back(point);
138 break;
139 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
140 data_.changed_touches.push_back(point);
141 break;
142 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
143 data_.target_touches.push_back(point);
144 break;
145 default:
146 break;
147 }
148 }
149
150 uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) {
151 switch (list) {
152 case PP_TOUCHLIST_TYPE_TOUCHES:
153 return data_.touches.size();
154 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
155 return data_.changed_touches.size();
156 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
157 return data_.target_touches.size();
158 default:
159 return 0;
160 }
161 return data_.touches.size();
162 }
163
164 PP_TouchPoint PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list,
165 uint32_t index) {
166 std::vector<PP_TouchPoint>* points;
167 switch (list) {
168 case PP_TOUCHLIST_TYPE_TOUCHES:
169 points = &data_.touches;
170 break;
171 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
172 points = &data_.changed_touches;
173 break;
174 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
175 points = &data_.target_touches;
176 break;
177 default:
178 return PP_MakeTouchPoint();
179 }
180 if (index >= points->size()) {
181 return PP_MakeTouchPoint();
182 }
183 return points->at(index);
184 }
185
186 PP_TouchPoint PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list,
187 uint32_t id) {
188 const std::vector<PP_TouchPoint>* points;
189 switch (list) {
190 case PP_TOUCHLIST_TYPE_TOUCHES:
191 points = &data_.touches;
192 break;
193 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
194 points = &data_.changed_touches;
195 break;
196 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
197 points = &data_.target_touches;
198 break;
199 default:
200 return PP_MakeTouchPoint();
201 }
202 for (size_t i = 0; i < points->size(); i++) {
203 if (points->at(i).id == id)
204 return points->at(i);
205 }
206 return PP_MakeTouchPoint();
207 }
208
130 //static 209 //static
131 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( 210 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent(
132 ResourceObjectType type, 211 ResourceObjectType type,
133 PP_Instance instance, 212 PP_Instance instance,
134 PP_InputEvent_Type event_type, 213 PP_InputEvent_Type event_type,
135 PP_TimeTicks time_stamp, 214 PP_TimeTicks time_stamp,
136 struct PP_Var text, 215 struct PP_Var text,
137 uint32_t segment_number, 216 uint32_t segment_number,
138 const uint32_t* segment_offsets, 217 const uint32_t* segment_offsets,
139 int32_t target_segment, 218 int32_t target_segment,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 data.event_time_stamp = time_stamp; 318 data.event_time_stamp = time_stamp;
240 data.event_modifiers = modifiers; 319 data.event_modifiers = modifiers;
241 data.wheel_delta = *wheel_delta; 320 data.wheel_delta = *wheel_delta;
242 data.wheel_ticks = *wheel_ticks; 321 data.wheel_ticks = *wheel_ticks;
243 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); 322 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page);
244 323
245 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); 324 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
246 } 325 }
247 326
248 } // namespace ppapi 327 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_input_event_shared.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698