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

Unified Diff: ppapi/shared_impl/ppb_input_event_shared.cc

Issue 2890323002: Add tilt_x and tilt_y to ppapi touchpoint. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/ppb_input_event_shared.cc
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc
index c966224b39dd177dec6e08158e20edf2fc95eab2..812e03cfb159523dd49cb1763c5bf496ae91814f 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.cc
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc
@@ -121,15 +121,16 @@ void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) {
void PPB_InputEvent_Shared::AddTouchPoint(PP_TouchListType list,
const PP_TouchPoint& point) {
+ TouchPointWithTilt point_with_tilt{point, {0, 0}};
switch (list) {
case PP_TOUCHLIST_TYPE_TOUCHES:
- data_.touches.push_back(point);
+ data_.touches.push_back(point_with_tilt);
break;
case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
- data_.changed_touches.push_back(point);
+ data_.changed_touches.push_back(point_with_tilt);
break;
case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
- data_.target_touches.push_back(point);
+ data_.target_touches.push_back(point_with_tilt);
break;
default:
break;
@@ -151,7 +152,7 @@ uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) {
PP_TouchPoint PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list,
uint32_t index) {
- std::vector<PP_TouchPoint>* points;
+ std::vector<TouchPointWithTilt>* points;
switch (list) {
case PP_TOUCHLIST_TYPE_TOUCHES:
points = &data_.touches;
@@ -168,12 +169,12 @@ PP_TouchPoint PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list,
if (index >= points->size()) {
return PP_MakeTouchPoint();
}
- return points->at(index);
+ return points->at(index).touch;
}
PP_TouchPoint PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list,
uint32_t id) {
- const std::vector<PP_TouchPoint>* points;
+ const std::vector<TouchPointWithTilt>* points;
switch (list) {
case PP_TOUCHLIST_TYPE_TOUCHES:
points = &data_.touches;
@@ -188,12 +189,57 @@ PP_TouchPoint PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list,
return PP_MakeTouchPoint();
}
for (size_t i = 0; i < points->size(); i++) {
- if (points->at(i).id == id)
- return points->at(i);
+ if (points->at(i).touch.id == id)
+ return points->at(i).touch;
}
return PP_MakeTouchPoint();
}
+PP_FloatPoint PPB_InputEvent_Shared::GetTouchTiltByIndex(PP_TouchListType list,
+ uint32_t index) {
+ std::vector<TouchPointWithTilt>* points;
+ switch (list) {
+ case PP_TOUCHLIST_TYPE_TOUCHES:
+ points = &data_.touches;
+ break;
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
+ points = &data_.changed_touches;
+ break;
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
+ points = &data_.target_touches;
+ break;
+ default:
+ return PP_MakeFloatPoint(0, 0);
+ }
+ if (index >= points->size()) {
+ return PP_MakeFloatPoint(0, 0);
+ }
+ return points->at(index).tilt;
+}
+
+PP_FloatPoint PPB_InputEvent_Shared::GetTouchTiltById(PP_TouchListType list,
+ uint32_t id) {
+ const std::vector<TouchPointWithTilt>* points;
+ switch (list) {
+ case PP_TOUCHLIST_TYPE_TOUCHES:
+ points = &data_.touches;
+ break;
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
+ points = &data_.changed_touches;
+ break;
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
+ points = &data_.target_touches;
+ break;
+ default:
+ return PP_MakeFloatPoint(0, 0);
+ }
+ for (size_t i = 0; i < points->size(); i++) {
+ if (points->at(i).touch.id == id)
+ return points->at(i).tilt;
+ }
+ return PP_MakeFloatPoint(0, 0);
+}
+
// static
PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent(
ResourceObjectType type,

Powered by Google App Engine
This is Rietveld 408576698