[Solved] analog joystick dead zone

For discussion of ports to POSIX based systems, especially using GNUStep.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

[Solved] analog joystick dead zone

Post by Tichy »

Hi! Does someone know how to set the dead zone in analog joysticks on gnu-linux?
I use a Logitech extreme 3d pro. I roll and pitch with the x and y axis, and yaw twisting the stick. My problem is that the twist is very sensitive and it's too easy to activate the yaw movement by mistake.

I already searched for similar problems, but all I was able to find was windows related, i.e.: install the logitech utilities.
Last edited by Getafix on Sun Aug 19, 2012 11:54 am, edited 2 times in total.
Reason: Capitalized solved to Solved.
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: analog joystick dead zone

Post by CommRLock78 »

Tichy wrote:
Hi! Does someone know how to set the dead zone in analog joysticks on gnu-linux?
I use a Logitech extreme 3d pro. I roll and pitch with the x and y axis, and yaw twisting the stick. My problem is that the twist is very sensitive and it's too easy to activate the yaw movement by mistake.

I already searched for similar problems, but all I was able to find was windows related, i.e.: install the logitech utilities.
I guess the first question to ask is what distro are you using?
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

Re: analog joystick dead zone

Post by Tichy »

I'm using Arch
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: analog joystick dead zone

Post by CommRLock78 »

I'm a couple years from Arch yet (I'm still learning with Mint in the Debian branch), but I found this site. I hope it helps:
http://www.thelinuxblog.com/linux-man-pages/4/joystick
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

Re: analog joystick dead zone

Post by Tichy »

I installed the X11 driver (xf86-input-joystick). When using the joystick in X11 as mouse and keyboard, the deadzone option works, but looks like the game ignores it. Maybe oolite hooks directly to the kernel driver, not the x11 input device.
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

Re: analog joystick dead zone

Post by Tichy »

Problem solved! You need jscal and jstest ("joyutils" package in Arch's AUR). There's also al frontend called jstest-gtk.
Calibrate and set the dead zone with jstest-gtk. We need to set CenterMin and CenterMax values.
My settings:
Image

Then you need to save these values, in order to reload them every time you plug the joystick. This is done by making jscal dump the actual values in a script file:

Code: Select all

jscal -p /dev/input/js0 > jscal.sh
Edit the file and add this on top of it

Code: Select all

#!/bin/bash
Make the script executable (chmod +x jscal.sh) and move it in /usr/local/bin

Now, we need to make this to automatically load every time we plug in the device. To do so, we'll make an udev rule.
Create a file in /etc/udev/rules.d and name it 85-jscal.rules (or something similar).
This is mine

Code: Select all

SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c215", ACTION=="add", RUN+="/usr/local/bin/jscal.sh"
If a device matching these rules is plugged, the script specified in RUN+= will be executed. You need to adapt it to your device. To find your idVendor and idProduct, launch

Code: Select all

udevadm info --attribute-walk --name /dev/input/js0
or, with lsusb (Bus ... Device ...: ID vedor:product Name):

Code: Select all

Bus 005 Device 011: ID 046d:c215 Logitech, Inc. Extreme 3D Pro
The last thing to do, is to export an enviroinment variable that says to the SDL libraries that we are using /dev/input/js0 as joystick. Without it, Oolite would ignore our settings.
Put in your .profile or .bashrc or where you usually set your evniroinment variables that line

Code: Select all

export SDL_JOYSTICK_DEVICE=/dev/input/js0
ps. I hope that the guide is understandable. And forgive my grammar: english is not my native language. :)
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: [solved] analog joystick dead zone

Post by CommRLock78 »

I'm glad you got it figured out :mrgreen: ; sorry I couldn't be of much assistance.
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

Re: [solved] analog joystick dead zone

Post by Tichy »

No problem ;)
User avatar
captain122
Above Average
Above Average
Posts: 19
Joined: Sun Sep 28, 2008 12:46 pm
Location: You really don't need to know that

Re: [solved] analog joystick dead zone

Post by captain122 »

Wow. I have been searching for an answer to that issue for years. I just rediscovered my account here and the first thing I see is just what I needed. I am very impressed and happy! (Also amazed at how many of the old faces are still around and how many are long gone!)
cybertiger
Above Average
Above Average
Posts: 16
Joined: Mon Mar 24, 2008 5:50 pm

Re: [Solved] analog joystick dead zone

Post by cybertiger »

Sorry for thread necromancy, but this solution is worth a sticky.

Calibrating joysticks in linux is non obvious and is not helped that SDL by default ignores your calibration (without setting SDL_JOYSTICK_DEVICE to /dev/input/jsX).
hayden
Above Average
Above Average
Posts: 26
Joined: Thu Nov 03, 2011 3:30 pm

Re: [Solved] analog joystick dead zone

Post by hayden »

Does this fix work in windows at all, or purely Linux?
User avatar
Tichy
---- E L I T E ----
---- E L I T E ----
Posts: 345
Joined: Wed Jul 11, 2012 5:48 pm

Re: [Solved] analog joystick dead zone

Post by Tichy »

Only gnu-linux. :)
Post Reply