You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported in version: 1.2.14 Reported for operating system, platform: Linux, x86
Comments on the original bug report:
On 2010-08-13 21:05:33 +0000, Gabriel Marcano wrote:
Created attachment 530
Source code for the program to test joystick.
Overview:
A joystick with two axis and 8 buttons is properly identified by the application 'jstest' with the correct number of buttons and axis. However, it seems that any application using SDL (at least two separate ones on the system this was encountered) to handle input identifies incorrectly that the joystick has at least one less axis than it really has.
Steps to Reproduce:
Having SDL 1.2.14 installed, run zsnes or other application that uses SDL for input
or
Having SDL 1.2.14 installed, compile and run attachement (sdl_js_test.cpp).
View result and/or check whether joystick axis are functioning properly in the application.
Actual Results:
One of the joystick axis was not identified and could not be used.
Expected Results:
Joystick's axis are correctly identified and enumerated.
Build Date & Platform:
Built on 2010-08-13 from SDL-1.2.14.tar.gz on Gentoo Linux (unstable) running on an Intel Pentium 4.
Additional Information:
This was first noted while launching 'zsnes' from a terminal window, and observing that it outputted the following:
The problem disappeared when downgrading to the SDL library version 1.2.13.
To further confirm that this was an issue with SDL and not zsnes, a very small c++ program was built to test the joystick using SDL function calls directly. This program (attached for convenience, see comment inside for compiling) prints the following (ran first with SDL version 1.2.13 and then 1.2.14):
$ g++ sdl_js_test.cpp -lSDL -o testJoystick && ./testJoystick
SDL Version: 1.2.13
Number of Axes: 2
$ g++ sdl_js_test.cpp -lSDL -o testJoystick && ./testJoystick
SDL Version: 1.2.14
Number of Axes: 1
The program assumes that the joystick to be tested is the first one (index 0), and does no error checking whatsoever since it's sole purpose was to be a quick test.
On 2010-08-13 21:13:24 +0000, Gabriel Marcano wrote:
Just in case: I seemingly forgot to mention that this bug might be related to bug 1041.
On another note: I am willing to give any more information needed, but within the next 14 days only. I will be leaving for two years, for which I will not be able to check on anything computer related due to the nature of the work I will be doing. Hopefully all information I need to post will be requested and handled before I leave!
I will check tomorrow to see if the SVN snapshot of SDL 1.2 has corrected this problem.
On 2010-08-14 10:28:11 +0000, Gabriel Marcano wrote:
Created attachment 531
SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c patch correcting a possible memory overflow
After checking some documentation on the include file <linux/input.h> I identified the problem: It appears that an extra unsigned int was added to the structure input_absinfo in the include file-- something not taken into account for in the SDL-1.2.14 code. This is found in line 703 of the file src/joystick/linux/SDL_sysjoystick.c in the code released under SDL-1.2.14. The code from the Mercurial repository fixes the issue by increasing the array that is used to store this information by 1 (making the constant 6), but that number is still hard coded (magic number)... What if the programmers in charge of <linux/input.h> change the structure once again? I think that the memory overflow that was taking place in SDL-1.2.14 was (at least part of) the problem as to why the axis were not being recognized. I modified the source and created a patch for the problem, which I am attaching. After compiling the code with the patch, testing zsnes and the custom test code I wrote both yielded positive results.
I have one question about the code in that file: Why is this include conditional?
#if SDL_INPUT_LINUXEV
#include <linux/input.h>
#endif
In order to know the size of the struct input_absinfo this include must be unconditional (notice it is being removed in the patch). Will this have undesired consequences?
I guess this can be marked as fixed, although I don't like the magic number solution found in the file previously mentioned. I will thus wait to see if any developer has insight on the situation.
On 2010-08-14 11:44:50 +0000, Gabriel Marcano wrote:
Created attachment 532
SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c patch that is more memory efficient, along with allowing for better reading
I found a stupid mistake on my end regarding arrays and memory allocated. I didn't think an array was needed in the first place, so I replaced the array with the correct struct, hopefully avoiding future memory overflow problems with this section of the code. As a bonus, the code is more readable now. I tested it, and it compiled and SDL seems to be working fine.
On 2010-08-15 19:56:00 +0000, Gabriel Marcano wrote:
Created attachment 534
SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c patch undoing the change with the includes...
I need to pay more attention to preprocessor conditionals. The removal of the conditional at the beginning was not necessary since the code that needs it is also under the same conditional... I am uploading a patch with the fix. I compiled the sdl 1.2.14 release with the patch, and it is working fine as well. Running SDL applications as well as the custom test application show correct utilization of the joystick.
On 2011-12-29 01:34:30 +0000, Sam Lantinga wrote:
This is fixed in source control. Thanks!
The text was updated successfully, but these errors were encountered:
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c patch correcting a possible memory overflow (libsdl-1.2.14-joystick.patch, text/plain, 2010-08-14 10:28:11 +0000, 717 bytes)SDL-1.2.14/src/joystick/linux/SDL_sysjoystick.c patch that is more memory efficient, along with allowing for better reading (libsdl-1.2.14-joystick.patch, text/plain, 2010-08-14 11:44:50 +0000, 1879 bytes)Reported in version: 1.2.14
Reported for operating system, platform: Linux, x86
Comments on the original bug report:
On 2010-08-13 21:05:33 +0000, Gabriel Marcano wrote:
On 2010-08-13 21:13:24 +0000, Gabriel Marcano wrote:
On 2010-08-14 10:28:11 +0000, Gabriel Marcano wrote:
On 2010-08-14 11:44:50 +0000, Gabriel Marcano wrote:
On 2010-08-15 19:56:00 +0000, Gabriel Marcano wrote:
On 2011-12-29 01:34:30 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: