[PATCH xf86-input-joystick] Silence clang warnings on floating point abs() / pow() calls.
Walter Harms
wharms at bfs.de
Sun Feb 10 17:42:34 UTC 2019
> Matthieu Herrb <matthieu at herrb.eu> hat am 10. Februar 2019 um 17:15
> geschrieben:
>
>
> Signed-off-by: Matthieu Herrb <matthieu at herrb.eu>
> ---
> 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(OsTimerPtr timer,
> */
>
> /* 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 / 40000.0f);
look reasonable perhaps we can improve readability also, like:
double delta=fabsf(axis->value) - axis->deadzone;
double ftimer=(float)NEXTTIMER / 40000.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 / 200000.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 / 200000.0f);
> } else if (axis->type == JSTK_TYPE_ACCELERATED) {
> --
> 2.20.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list