So, modify coordinate calculation when rotating.
Change-Id: I1ce7788a098104e1a729e2c78a7cf3fb49b7e31a
if(angle == 90)
{
- newX = size.GetWidth() - y;
+ newX = (size.GetWidth() - 1) - y;
newY = x;
}
else if(angle == 180)
{
- newX = size.GetHeight() - x;
- newY = size.GetWidth() - y;
+ newX = (size.GetHeight() - 1) - x;
+ newY = (size.GetWidth() - 1) - y;
}
else if(angle == 270)
{
newX = y;
- newY = size.GetHeight() - x;
+ newY = (size.GetHeight() - 1) - x;
}
else
{
{
Vector2 convertedPosition;
+ // Note: We need to subtract 1 from width and height because the range of touch coordinates is from to width - 1 or height - 1
switch(mRotationAngle)
{
case 90:
{
- convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth - 1) - position.y;
convertedPosition.y = position.x;
break;
}
case 180:
{
- convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
- convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth - 1) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight - 1) - position.y;
break;
}
case 270:
{
convertedPosition.x = position.y;
- convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight - 1) - position.x;
break;
}
default:
{
Vector2 convertedPosition;
+ // Note: We need to subtract 1 from width and height because the range of touch coordinates is from to width - 1 or height - 1
switch(mTotalRotationAngle)
{
case 90:
{
- convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth - 1) - position.y;
convertedPosition.y = position.x;
break;
}
case 180:
{
- convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
- convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth - 1) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight - 1) - position.y;
break;
}
case 270:
{
convertedPosition.x = position.y;
- convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight - 1) - position.x;
break;
}
default: