mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Renato Golin" <rengolin@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: joydev.c and saitek cyborg evo force
Date: Fri, 18 May 2007 22:35:06 +0100	[thread overview]
Message-ID: <d9b9d95f0705181435h40377f9cl8a573f8743d35eaf@mail.gmail.com> (raw)
In-Reply-To: <d9b9d95f0705180654x342ff6dbwf134243dfeabed20@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]

On 18/05/07, Renato Golin <rengolin@gmail.com> 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

[-- Attachment #2: joydev.patch --]
[-- Type: text/x-patch, Size: 1350 bytes --]

--- 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;

  reply	other threads:[~2007-05-18 21:35 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-18 13:54 Renato Golin
2007-05-18 21:35 ` Renato Golin [this message]
2007-05-21  4:16 ` Dmitry Torokhov
2007-05-21 12:49   ` Jiri Kosina
2007-05-24 13:27     ` Renato Golin
2007-05-29 23:57     ` Renato Golin
2007-05-30  0:10       ` Jiri Kosina
2007-05-30  9:14         ` Renato Golin
2007-05-30 14:56           ` Jiri Kosina
2007-05-30 15:18             ` Renato Golin
2007-05-30 22:26               ` Renato Golin
2007-05-31 19:53                 ` Dmitry Torokhov
2007-05-31 20:22                   ` Jiri Kosina
2007-05-31 21:48                     ` Jiri Kosina
2007-06-01 18:16                     ` Renato Golin
2007-06-03  9:41                       ` Jiri Kosina
2007-06-04 22:06                         ` Renato Golin
2007-06-04 22:10                           ` Jiri Kosina
2007-06-04 22:46                             ` Renato Golin
2007-06-12 12:28                               ` Renato Golin
2007-06-12 12:37                               ` Jiri Kosina
2007-06-12 13:08                                 ` Renato Golin
2007-06-12 13:13                                   ` Dmitry Torokhov
2007-06-12 13:31                                     ` Renato Golin
2007-06-12 13:45                                       ` Dmitry Torokhov
2007-06-12 15:25                                       ` Jiri Kosina
2007-06-14 22:24                                         ` Renato Golin
2007-06-20 10:00                                           ` Jiri Kosina
2007-07-21  0:10                                             ` Renato Golin
2007-08-10 15:10                                               ` Jiri Kosina
2007-08-10 15:54                                                 ` Jiri Kosina
2007-08-11 17:38                                                   ` Renato Golin
2007-08-11 21:06                                                     ` Jiri Kosina
2007-08-11 21:15                                                       ` Renato Golin
2007-08-10 16:31                                                 ` Renato Golin
2007-08-11 13:42                                                   ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9b9d95f0705181435h40377f9cl8a573f8743d35eaf@mail.gmail.com \
    --to=rengolin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®