comparison src/joystick/linux/SDL_sysjoystick.c @ 871:9cc9e2462d9a

Avoid FPE with Linux 2.6
author Sam Lantinga <slouken@libsdl.org>
date Fri, 05 Mar 2004 15:09:18 +0000
parents b8d311d90021
children e7be95d758e8
comparison
equal deleted inserted replaced
870:95f22f17e44a 871:9cc9e2462d9a
381 381
382 #ifdef USE_INPUT_EVENTS 382 #ifdef USE_INPUT_EVENTS
383 383
384 static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd) 384 static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
385 { 385 {
386 int i; 386 int i, t;
387 unsigned long keybit[40]; 387 unsigned long keybit[40];
388 unsigned long absbit[40]; 388 unsigned long absbit[40];
389 unsigned long relbit[40]; 389 unsigned long relbit[40];
390 390
391 /* See if this device uses the new unified event API */ 391 /* See if this device uses the new unified event API */
434 joystick->hwdata->abs_map[i] = joystick->naxes; 434 joystick->hwdata->abs_map[i] = joystick->naxes;
435 if ( values[1] == values[2] ) { 435 if ( values[1] == values[2] ) {
436 joystick->hwdata->abs_correct[i].used = 0; 436 joystick->hwdata->abs_correct[i].used = 0;
437 } else { 437 } else {
438 joystick->hwdata->abs_correct[i].used = 1; 438 joystick->hwdata->abs_correct[i].used = 1;
439 joystick->hwdata->abs_correct[i].coef[0] = 439 t = (2 - values[4]);
440 (values[2] + values[1]) / 2 - values[4]; 440 if ( t != 0 ) {
441 joystick->hwdata->abs_correct[i].coef[1] = 441 joystick->hwdata->abs_correct[i].coef[0] = (values[2] + values[1]) / t;
442 (values[2] + values[1]) / 2 + values[4]; 442 }
443 joystick->hwdata->abs_correct[i].coef[2] = 443 t = (2 + values[4]);
444 (1 << 29) / ((values[2] - values[1]) / 2 - 2 * values[4]); 444 if ( t != 0 ) {
445 joystick->hwdata->abs_correct[i].coef[1] = (values[2] + values[1]) / t;
446 }
447 t = ((values[2] - values[1]) / 2 - 2 * values[4]);
448 if ( t != 0 ) {
449 joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
450 }
445 } 451 }
446 ++joystick->naxes; 452 ++joystick->naxes;
447 } 453 }
448 } 454 }
449 for ( i=ABS_HAT0X; i <= ABS_HAT3Y; i += 2 ) { 455 for ( i=ABS_HAT0X; i <= ABS_HAT3Y; i += 2 ) {