SDL/src
Sam Lantinga 8795ca7067 Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085

I added some printf to verify the math being done.  Of the three joysticks I have, it works correctly for at least two, and seems to work correctly for the third.  I say "seems to" because, for the third joystick, the values never go through the AxisCorrect function, and thus never hit my printf statements, even though they did in the version I wrote my patch against.  I'm not sure what's going on there, but it at least seems to be working correctly in as much as I can tell.

I note this result in particular, for an SNES Gamepad (min=0, max=255):

Joystick value 0 becomes -32768
Joystick value 127 becomes 0
Joystick value 255 becomes 32767

Without the code that forces a zero point, the 127 input value would become -129, so I think you see why I added that code to turn it into zero.  However, I think Kai Krakow has a point about how SDL shouldn't assume that there should be a center.

Obviously in the majority of cases there actually should be a center, and the code that turns that 127 into an actual 0 is creating only a 0.2% error over 0.4% of this joystick's range.  However, what if there is an axis that is some kind of special control, like a 4-position switch, and, for whatever reason, the joystick reports it as an axis with 4 possible values, 0 to 3?  In that case, mutilating the two center values to the same value is much more of an error and and turns that 4-position switch into a 3-position switch.  If any joystick does this with a 2-position switch, then this code would render that control entirely useless as it would report the same value with the switch in either position.  Obviously the code could require that there be at least N possible values, to guess whether something is a proper axis or just some kind of switch, but the choice of N would be arbitrary and that's ugly.

I guess the real problem here is that my gamepad is just kind of broken.  It should be reporting a range of -1 to +1 since that's what it actually does.  Also, as Kai Krakow points out, it's probably not SDL's place to fix broken hardware.  I'll add that, if SDL does fix broken hardware, it should probably actually know that it's broken rather than be merely guessing that it is.

So, to the extent that SDL is able to do stuff like this, perhaps it's something better left for the user to configure in some kind of config file.
2020-12-14 09:15:47 -08:00
..
atomic Add basic support for compiling on RISC OS 2020-02-13 20:50:47 +00:00
audio Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
core linux/SDL_threadprio.c: fix build on older systems: 2020-12-13 18:00:20 +03:00
cpuinfo Add Zhaoxin processor support 2020-11-09 20:36:35 -08:00
dynapi Added SDL_wcscasecmp() and SDL_wcsncasecmp() 2020-11-24 12:43:01 -08:00
events Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
file Fixed compile warning 2020-02-10 13:59:05 -08:00
filesystem Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
haptic Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
hidapi Fixed build for platforms with only libusb hidapi implementations 2020-12-13 01:58:05 -08:00
joystick Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off 2020-12-14 09:15:47 -08:00
libm k_rem_pio2.c: fix typo in second memset(): iq, not q. fixes bug #5309. 2020-10-08 11:51:02 +03:00
loadso windows SDL_LoadObject: fix warning after commit 2ff650230d96 2020-12-13 18:25:02 +03:00
locale Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
main Updated SDL to 2.0.14 in preparation for release candidate 2020-12-08 18:56:06 -08:00
misc riscos: Implement SDL_OpenURL() 2020-10-11 17:32:32 +01:00
power Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
render Fixed bug 5213 - Add support to metal in iOS/tvOS simulator 2020-12-09 07:23:47 -08:00
sensor Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
stdlib Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
test fix watcom build of SDL_test_common.c 2020-06-14 12:05:56 +03:00
thread Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
timer Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
video Fixed compile warning 2020-12-13 02:10:46 -08:00
SDL.c os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
SDL_assert.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_assert_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_dataqueue.c Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
SDL_dataqueue.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_error.c SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_error_c.h SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_hints.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_hints_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_internal.h Fixed bug 5235 - All internal sources should include SDL_assert.h 2020-12-09 07:16:22 -08:00
SDL_log.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00