提交 e8036400 编写于 作者: C chaos.proton@gmail.com

avoid divided by zero error

The old code only checks touch->max_x > touch->min_x but not touch->max_x == touch->min_x. Thus may lead to divided by zero error.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1782 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 9de3512c
......@@ -158,7 +158,7 @@ static void rtgui_touch_calculate()
{
touch->x = (touch->x - touch->min_x) * X_WIDTH/(touch->max_x - touch->min_x);
}
else
else if (touch->max_x < touch->min_x)
{
touch->x = (touch->min_x - touch->x) * X_WIDTH/(touch->min_x - touch->max_x);
}
......@@ -167,7 +167,7 @@ static void rtgui_touch_calculate()
{
touch->y = (touch->y - touch->min_y) * Y_WIDTH /(touch->max_y - touch->min_y);
}
else
else if (touch->max_y < touch->min_y)
{
touch->y = (touch->min_y - touch->y) * Y_WIDTH /(touch->min_y - touch->max_y);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册