The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Deadzone in analog input at center using SDL2 (Linux)
Stephen Anthony
Guest

I'm testing an adaptor that converts from Atari 2600 paddle controllers
to USB analog values (www.2600-daptor.com). The input is being received
in Stella (Atari 2600 emulator) in the range -32768 to 32767, as
expected. Problem is, there's a deadzone in the center, at position 0,
where there's no input for a few moments.

I've also tested this with 'testjoystick' from SDL2, and it confirms the
dead spot. Also, in SDL1 using the old joystick API, the dead spot
isn't there. Finally, when testing with 'evtest', the problem isn't
there either.

From my testing, it seems that event input is working correctly, just
not in SDL2. Also, this happening only in Linux. The controller is
working fine in Windows and OSX.

Can anyone offer some advice on this??

Thanks,
Steve A.
Stella maintainer

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Deadzone in analog input at center using SDL2 (Linux)
mungewell


Joined: 17 Nov 2011
Posts: 40
On Sun, February 7, 2016 1:14 pm, Stephen Anthony wrote:
Quote:
I'm testing an adaptor that converts from Atari 2600 paddle controllers
to USB analog values (www.2600-daptor.com). The input is being received in
Stella (Atari 2600 emulator) in the range -32768 to 32767, as
expected. Problem is, there's a deadzone in the center, at position 0,
where there's no input for a few moments.

I've also tested this with 'testjoystick' from SDL2, and it confirms the
dead spot. Also, in SDL1 using the old joystick API, the dead spot isn't
there. Finally, when testing with 'evtest', the problem isn't there
either.

From my testing, it seems that event input is working correctly, just
not in SDL2. Also, this happening only in Linux. The controller is
working fine in Windows and OSX.

Can anyone offer some advice on this??

The linux input system automatically adds some deadzone, seen on joystick
interface (/dev/input/js0) but not on the event interface
(/dev/input/event8). You probably want to check which interface SDL2 is
really using on your machine(s).

This is controlled using 'fuzz' and 'flat' values, which can be altered
after the initial setting, but I don't recall exactly how this is done.

I had this 'work around' for the Logitech wheel driver I was working on a
while ago:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/hid/hid-lg.c?id=94b3f712fe2cd5c33d57ca0ab9604d2402bc72cd

Good luck,
Simon

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Deadzone in analog input at center using SDL2 (Linux)
mungewell


Joined: 17 Nov 2011
Posts: 40
Quote:
This is controlled using 'fuzz' and 'flat' values, which can be altered
after the initial setting, but I don't recall exactly how this is done.

I'm probably recalling this util, which although is intended for the G25 I
think it will work with any 'joystick'.

https://github.com/VDrift/vdrift/tree/master/tools/G25manage

Simon

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Deadzone in analog input at center using SDL2 (Linux)
Stephen Anthony
Guest

On February 7, 2016 01:54:02 PM Simon Wood wrote:
Quote:
Quote:
This is controlled using 'fuzz' and 'flat' values, which can be
altered after the initial setting, but I don't recall exactly how
this is done.
I'm probably recalling this util, which although is intended for the
G25 I think it will work with any 'joystick'.

https://github.com/VDrift/vdrift/tree/master/tools/G25manage

I finally got the G25manage util to work, and it does indeed adjust the
deadzone (aka flatness). But I'm wondering if SDL shouldn't just set
the flatness/deadzone to zero for all axes, or at least offer the
ability to do it through its API.

The reason being, it's easy to enforce a deadzone in an app when none
initally exists, than to get rid of one that currently exists. In fact,
the only way to do it with G25manage, a 7 year old program that most
people won't have available on their system.

Perhaps SDL could be extended to pass the deadzone to a joystick, or
take an environment variable (perhaps 'SDL_JOYSTICK_DEADZONE') to set
it.

Thanks,
Steve A.
Stella maintainer

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Deadzone in analog input at center using SDL2 (Linux)
mungewell


Joined: 17 Nov 2011
Posts: 40
On Sun, February 7, 2016 3:55 pm, Stephen Anthony wrote:

Quote:
The reason being, it's easy to enforce a deadzone in an app when none
initally exists, than to get rid of one that currently exists. In fact,
the only way to do it with G25manage, a 7 year old program that most
people won't have available on their system.

Of course I wasn't suggesting that an end user would use G25manage, just
that it might help confirm the problem you are having. It's also a
reference to which ioctl()'s are needed to set the fuzz/flat.

IMHO linux input is wrong applying such a large deadzone in the first
place, but it is what it is...

Quote:

Perhaps SDL could be extended to pass the deadzone to a joystick, or
take an environment variable (perhaps 'SDL_JOYSTICK_DEADZONE') to set it.

As this deadzone is only on Linux and only with js0 (or is it eventx) then
perhaps a variable is overkill, or maybe others want this...

As a side note SDL and SDL2 have a variable (SDL_JOYSTICK_DEVICE) to
switch between which interface is used, and I think that switched between
SDL/SDL2. IIRC that causes issues with haptics.

Simon

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Deadzone in analog input at center using SDL2 (Linux)
Stephen Anthony
Guest

On 2016-02-07 8:54 PM, Simon Wood wrote:
Quote:
On Sun, February 7, 2016 3:55 pm, Stephen Anthony wrote:

Quote:
The reason being, it's easy to enforce a deadzone in an app when none
initally exists, than to get rid of one that currently exists. In fact,
the only way to do it with G25manage, a 7 year old program that most
people won't have available on their system.
Of course I wasn't suggesting that an end user would use G25manage, just
that it might help confirm the problem you are having. It's also a
reference to which ioctl()'s are needed to set the fuzz/flat.

IMHO linux input is wrong applying such a large deadzone in the first
place, but it is what it is...

Yes, the util was very useful in finding the right ioctl to use. In
fact, I modified a local copy of SDL 2.0.4 to set the flatness to 0 for
every axis on every joystick, and it works perfectly.

Quote:
As this deadzone is only on Linux and only with js0 (or is it eventx)
then perhaps a variable is overkill, or maybe others want this... As a
side note SDL and SDL2 have a variable (SDL_JOYSTICK_DEVICE) to switch
between which interface is used, and I think that switched between
SDL/SDL2. IIRC that causes issues with haptics. Simon
It is with eventx input only (the jsX interface doesn't work in SDL2 any
more). This also means the SDL_JOYSTICK_DEVICE thing won't work any
more either.

I think this is something that can be considered for a future release of
SDL. For now, I guess I can just statically link a patched SDL with my
app. But it would be nice to have it available in the API.

Thanks,
Steve A.
Stella maintainer

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org