Properly rotate full [-pi, +pi] orientation range if available
The code currently in place assumes that orientation has a range of [-pi/2, +pi/2] as may be found with a touch digitizer. However, when used with a digitzer that can report the full [-pi, +pi] range of orientations (e.g. a stylus) the calculations here are incorrect. This patch checks if the post-rotation value is out of range for the axis, and wraps it back around. Change-Id: I03a22f7bf9526a5d995df1a18430d6dd24c6d6ee
This commit is contained in:
@@ -4170,20 +4170,24 @@ void TouchInputMapper::cookPointerData() {
|
||||
x = float(in.y - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
|
||||
y = float(mRawPointerAxes.x.maxValue - in.x) * mXScale + mXTranslate;
|
||||
orientation -= M_PI_2;
|
||||
if (orientation < - M_PI_2) {
|
||||
orientation += M_PI;
|
||||
if (orientation < mOrientedRanges.orientation.min) {
|
||||
orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
|
||||
}
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_180:
|
||||
x = float(mRawPointerAxes.x.maxValue - in.x) * mXScale + mXTranslate;
|
||||
y = float(mRawPointerAxes.y.maxValue - in.y) * mYScale + mYTranslate;
|
||||
orientation -= M_PI;
|
||||
if (orientation < mOrientedRanges.orientation.min) {
|
||||
orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
|
||||
}
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_270:
|
||||
x = float(mRawPointerAxes.y.maxValue - in.y) * mYScale + mYTranslate;
|
||||
y = float(in.x - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
|
||||
orientation += M_PI_2;
|
||||
if (orientation > M_PI_2) {
|
||||
orientation -= M_PI;
|
||||
if (orientation > mOrientedRanges.orientation.max) {
|
||||
orientation -= (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user