Re: [PATCH xf86-input-joystick] Silence clang warnings on floating point abs() / pow() calls.

2019-02-10 Thread Walter Harms


> Matthieu Herrb  hat am 10. Februar 2019 um 17:15
> geschrieben:
> 
> 
> Signed-off-by: Matthieu Herrb 
> ---
>  src/jstk_axis.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/jstk_axis.c b/src/jstk_axis.c
> index cb4a004..37bb66b 100644
> --- a/src/jstk_axis.c
> +++ b/src/jstk_axis.c
> @@ -136,11 +136,11 @@ jstkAxisTimer(OsTimerPtrtimer,
>*/
>  
>  /* How many pixels should this axis move the cursor */
> -p1 = (pow((abs((float)axis->value) - (float)axis->deadzone) *
> +p1 = (powf((fabsf((float)axis->value) - (float)axis->deadzone) *
>scale / 23, 1.4f) + 100.0f) *
>   ((float)NEXTTIMER / 4.0f);

look reasonable perhaps we can improve readability also, like:
 double delta=fabsf(axis->value) - axis->deadzone;
 double ftimer=(float)NEXTTIMER / 4.0f;

 p1= powf(delta/23.0*scale,1.4f)/ftimer+100.0f/ftimer;


>  /* How many "pixels" should this axis scroll */
> -p2 = ((pow((abs((float)axis->value) - (float)axis->deadzone) *

   ftimer=(float)NEXTTIMER / 20.0f;
   p2= powf(delta/1000.0*scale,2.5f)/ftimer+200.0f/ftimer;
you can earn bonus points for explaining the magic numbers.

just my 2 cents,
   re,
wh
 
> +p2 = ((powf((fabsf((float)axis->value) - (float)axis->deadzone) *
>scale / 1000.0f, 2.5f)) + 200.0f) *
>   ((float)NEXTTIMER / 20.0f);
>  } else if (axis->type == JSTK_TYPE_ACCELERATED) {
> -- 
> 2.20.1
> 
> ___
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-input-joystick] Silence clang warnings on floating point abs() / pow() calls.

2019-02-10 Thread Matthieu Herrb
Signed-off-by: Matthieu Herrb 
---
 src/jstk_axis.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index cb4a004..37bb66b 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -136,11 +136,11 @@ jstkAxisTimer(OsTimerPtrtimer,
 */
 
 /* How many pixels should this axis move the cursor */
-p1 = (pow((abs((float)axis->value) - (float)axis->deadzone) *
+p1 = (powf((fabsf((float)axis->value) - (float)axis->deadzone) *
   scale / 23, 1.4f) + 100.0f) *
  ((float)NEXTTIMER / 4.0f);
 /* How many "pixels" should this axis scroll */
-p2 = ((pow((abs((float)axis->value) - (float)axis->deadzone) *
+p2 = ((powf((fabsf((float)axis->value) - (float)axis->deadzone) *
   scale / 1000.0f, 2.5f)) + 200.0f) *
  ((float)NEXTTIMER / 20.0f);
 } else if (axis->type == JSTK_TYPE_ACCELERATED) {
-- 
2.20.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel