Re: joydev.c and saitek cyborg evo force

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/05/07, Renato Golin <[email protected]> wrote:
Problem is, on joydev_connect, when defining the corrections for every
axis, the joystick is reporting dev->absmax = 127 and dev->absmin =
-127 for both axis 0 and 1, so the correction is based on a signed
range when the joystick is actually sending an unsigned range.

Quick fix so I can play flightgear:

on joydev_connect, created absmin and absmax to avoid messing dev
variables (pointer)

if current position (dev->abs) is not in range:

if (dev->abs[j] > dev->absmax[j] || dev->abs[j] < dev->absmin[j]) {
    absmin = 0;
    absmax = dev->abs[j] * 2;
}

problems:
- it only works when joy is centred at connection
- it assumes the joy will report correct positions (instead of uncalibrated)

Now I'll figure out how to turn off button 12...

cheers,
--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm
--- joydev.c	2007-04-12 18:15:56.000000000 +0100
+++ /usr/src/linux/drivers/input/joydev.c	2007-05-18 22:21:26.000000000 +0100
@@ -471,6 +471,7 @@
 	struct joydev *joydev;
 	struct class_device *cdev;
 	int i, j, t, minor;
+	int absmin, absmax;
 
 	for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
 	if (minor == JOYDEV_MINORS) {
@@ -520,11 +521,20 @@
 			joydev->abs[i] = dev->abs[j];
 			continue;
 		}
+		/* Some joysticks don't report max/min correctly */
+		if (dev->abs[j] > dev->absmax[j] || dev->abs[j] < dev->absmin[j]) {
+			/* assume joystick is centered */
+			absmin = 0;
+			absmax = dev->abs[j] * 2;
+		} else {
+			absmin = dev->absmin[j];
+			absmax = dev->absmax[j];
+		}
 		joydev->corr[i].type = JS_CORR_BROKEN;
 		joydev->corr[i].prec = dev->absfuzz[j];
-		joydev->corr[i].coef[0] = (dev->absmax[j] + dev->absmin[j]) / 2 - dev->absflat[j];
-		joydev->corr[i].coef[1] = (dev->absmax[j] + dev->absmin[j]) / 2 + dev->absflat[j];
-		if (!(t = ((dev->absmax[j] - dev->absmin[j]) / 2 - 2 * dev->absflat[j])))
+		joydev->corr[i].coef[0] = (absmax + absmin) / 2 - dev->absflat[j];
+		joydev->corr[i].coef[1] = (absmax + absmin) / 2 + dev->absflat[j];
+		if (!(t = ((absmax - absmin) / 2 - 2 * dev->absflat[j])))
 			continue;
 		joydev->corr[i].coef[2] = (1 << 29) / t;
 		joydev->corr[i].coef[3] = (1 << 29) / t;

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux