Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 332761 | Differences between
and this patch

Collapse All | Expand All

(-)SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c (-11 / +9 lines)
Lines 31-39 Link Here
31
#include <sys/ioctl.h>
31
#include <sys/ioctl.h>
32
#include <limits.h>		/* For the definition of PATH_MAX */
32
#include <limits.h>		/* For the definition of PATH_MAX */
33
#include <linux/joystick.h>
33
#include <linux/joystick.h>
34
#if SDL_INPUT_LINUXEV
34
#include <linux/input.h> /* Needed to calculate sizeof(struct input_absinfo) */
35
#include <linux/input.h>
36
#endif
37
35
38
#include "SDL_joystick.h"
36
#include "SDL_joystick.h"
39
#include "../SDL_sysjoystick.h"
37
#include "../SDL_sysjoystick.h"
Lines 700-725 Link Here
700
				continue;
698
				continue;
701
			}
699
			}
702
			if ( test_bit(i, absbit) ) {
700
			if ( test_bit(i, absbit) ) {
703
				int values[5];
701
				struct input_absinfo values;
704
702
705
				if ( ioctl(fd, EVIOCGABS(i), values) < 0 )
703
				if ( ioctl(fd, EVIOCGABS(i), &values) < 0 )
706
					continue;
704
					continue;
707
#ifdef DEBUG_INPUT_EVENTS
705
#ifdef DEBUG_INPUT_EVENTS
708
				printf("Joystick has absolute axis: %x\n", i);
706
				printf("Joystick has absolute axis: %x\n", i);
709
				printf("Values = { %d, %d, %d, %d, %d }\n",
707
				printf("Values = { %d, %d, %d, %d, %d }\n",
710
					values[0], values[1],
708
					values.value, values.minimum,
711
					values[2], values[3], values[4]);
709
					values.maximum, values.fuzz, values.flat);
712
#endif /* DEBUG_INPUT_EVENTS */
710
#endif /* DEBUG_INPUT_EVENTS */
713
				joystick->hwdata->abs_map[i] = joystick->naxes;
711
				joystick->hwdata->abs_map[i] = joystick->naxes;
714
				if ( values[1] == values[2] ) {
712
				if ( values.minimum == values.maximum ) {
715
				    joystick->hwdata->abs_correct[i].used = 0;
713
				    joystick->hwdata->abs_correct[i].used = 0;
716
				} else {
714
				} else {
717
				    joystick->hwdata->abs_correct[i].used = 1;
715
				    joystick->hwdata->abs_correct[i].used = 1;
718
				    joystick->hwdata->abs_correct[i].coef[0] =
716
				    joystick->hwdata->abs_correct[i].coef[0] =
719
					(values[2] + values[1]) / 2 - values[4];
717
					(values.maximum + values.minimum) / 2 - values.flat;
720
				    joystick->hwdata->abs_correct[i].coef[1] =
718
				    joystick->hwdata->abs_correct[i].coef[1] =
721
					(values[2] + values[1]) / 2 + values[4];
719
					(values.maximum + values.minimum) / 2 + values.flat;
722
				    t = ((values[2] - values[1]) / 2 - 2 * values[4]);
720
				    t = ((values.maximum - values.minimum) / 2 - 2 * values.flat);
723
				    if ( t != 0 ) {
721
				    if ( t != 0 ) {
724
					joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
722
					joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
725
				    } else {
723
				    } else {

Return to bug 332761