Commit graph

84 commits

Author SHA1 Message Date
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Philipp Wiesemann
e83262a725 Corrected spelling in C source files. 2013-05-01 11:59:54 +02:00
Ryan C. Gordon
4f438b70a2 Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
2013-03-31 12:48:50 -04:00
Sam Lantinga
c63c6c5103 Removed duplicate include 2013-02-24 12:56:29 -08:00
Sam Lantinga
22f666c86c Fixed compiling on older Linux systems without libudev 2013-02-24 12:55:51 -08:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Jørgen P. Tjernø
781ab3764f Fix a corruption when you remove first joystick on Linux.
Fixes a bug where the joystick subsystem would get corrupted if you unplug the
first of multiple joysticks. Fixes bug 1714.


CR: saml
2013-02-12 11:47:29 -08:00
Sam Lantinga
11176cfece Fixed compiling SYN_DROPPED with older kernel headers 2013-02-11 18:22:17 -08:00
Sam Lantinga
354604b7bb Patch - Joystick coef[] doesn't support dial with low number of positions.
Simon <simon@mungewell.org>

I am working on joystick support for the SRW-S1 gaming wheel on Linux,
this device has 3 dials with only a few positions each.

At present SDL2 only fail to report the highest position value, due to the
interger math used for coef[]'s.

So with a 4 position switch I have input values (with evtest)
--
Event: time 1358967246.173186, type 3 (EV_ABS), code 9 (ABS_GAS), value 2
Event: time 1358967246.173186, -------------- SYN_REPORT ------------
Event: time 1358967246.369150, type 3 (EV_ABS), code 9 (ABS_GAS), value 1
Event: time 1358967246.369150, -------------- SYN_REPORT ------------
Event: time 1358967246.930277, type 3 (EV_ABS), code 9 (ABS_GAS), value 0
Event: time 1358967246.930277, -------------- SYN_REPORT ------------
Event: time 1358967249.369832, type 3 (EV_ABS), code 9 (ABS_GAS), value 1
Event: time 1358967249.369832, -------------- SYN_REPORT ------------
Event: time 1358967249.514382, type 3 (EV_ABS), code 9 (ABS_GAS), value 2
Event: time 1358967249.514382, -------------- SYN_REPORT ------------
Event: time 1358967249.626189, type 3 (EV_ABS), code 9 (ABS_GAS), value 3
Event: time 1358967249.626189, -------------- SYN_REPORT ------------
--

Testjoystick reports
--
Joystick has 6 axes, 1 hats, 0 balls, and 17 buttons
Joystick 0 axis 5 value: 32767
Joystick 0 axis 5 value: 0
Joystick 0 axis 5 value: -32768
Joystick 0 axis 5 value: 0
Joystick 0 axis 5 value: 32767
Joystick 0 axis 5 value: 0
Joystick 0 axis 5 value: -32768
--

The attached patch 'shifts' the coef[], so that 1/2 values can be
computed/seen and allows testjoystick to report correctly.
--
Joystick has 6 axes, 1 hats, 0 balls, and 17 buttons
Joystick 0 axis 5 value: -10923
Joystick 0 axis 5 value: 10922
Joystick 0 axis 5 value: 32767
Joystick 0 axis 5 value: 10922
Joystick 0 axis 5 value: -10923
Joystick 0 axis 5 value: -32768
Joystick 0 axis 5 value: -10923
Joystick 0 axis 5 value: 10922
Joystick 0 axis 5 value: 32767
--

Cheers,
Simon
2013-02-11 16:51:00 -08:00
Sam Lantinga
7b84e779ec Fix for dropped joystick events contributed by Simon <simon@mungewell.org>
In my system SDL2 is dropping a chunk of joystick events, which result in
a 'stuck brake/accelerator' whilst playing a racing simulator. This
basically means SDL2 is unsuitable for use at this point...

The patch below detects this situation and forces a re-read of all
attached joystick axis - thus resync to the correct/current pedal
positions.
2013-02-11 16:45:24 -08:00
Sam Lantinga
e1f76ef0ea Fixed setting the GUID for Bluetooth joysticks 2013-02-01 17:09:01 -08:00
Sam Lantinga
29bfd0ab48 Load the runtime udev library, not the development one. 2012-12-14 18:50:07 +00:00
Ryan C. Gordon
6b4cb17219 Corrected Linux joystick things, fixes assertion failure from testjoystick. 2012-12-13 22:26:30 -05:00
Ryan C. Gordon
d2b1601539 Corrected device instance value for Linux joysticks. 2012-12-13 22:18:32 -05:00
Ryan C. Gordon
22f3f2b927 Fixed compiler warning. 2012-12-11 19:25:35 -05:00
Sam Lantinga
af4d258edb Fixed compiling Linux code 2012-12-11 12:08:36 -08:00
Sam Lantinga
89ef9e3168 Changes from Alfred:
- rename JoystickGUID -> SDL_JoystickGUID
- change SDL_JoystickGetGUIDString to take the string as an arg, rather than doing a malloc
2012-12-11 11:54:32 -08:00
Ryan C. Gordon
c8713a62c1 Updated Linux joystick code to support hotplug, GUIDs, etc.
This uses libudev for hotplug, but it's optional, so we'll just try to find
 some reasonable defaults without it (maybe an older Linux box or under
 FreeBSD's Linux emulation?).
2012-12-11 12:07:06 -05:00
Ryan C. Gordon
d935bb9d4d Removed old Linux joystick API (/dev/js*).
The newer API (/dev/input/event/*) is 12+ years old at this point, and has
 been available since Linux 2.4.
2012-12-11 11:07:48 -05:00
Ryan C. Gordon
0dc1a837b5 Removed the "logical" Linux joystick code.
It's been forcibly disabled since 2009, since the kernel apparently splits
 these devices for us now, and apparently the code was crashing at the time
 (see hg changeset 11c079bb52a8).

Also, it was a ton of messy #ifdefs in this file!
2012-12-10 15:50:42 -05:00
Sam Lantinga
03e08a6a79 Organized joystick hotplug code a bit.
Cleaned up names, return types, etc.
2012-11-27 00:58:12 -08:00
Sam Lantinga
c9f59a287d Completed adding new hotplug stubs for the joystick implementations 2012-11-26 22:27:49 -08:00
Sam Lantinga
968ccf93b1 Fixed iOS joystick support for new API 2012-11-26 21:11:28 -08:00
Sam Lantinga
3765f3223a Fixed joystick attached API call on Linux 2012-11-26 17:31:49 -08:00
Sam Lantinga
34b88dfaae Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds 2012-11-26 16:37:54 -08:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Ryan C. Gordon
8912814135 Removed some unused variables that gcc 4.6.1 complains about. 2012-08-09 14:14:41 -04:00
Ryan C. Gordon
110c52e2b4 Fix from 1.2 branch: ignore bogus Linux evdev joystick axes. 2012-06-03 05:05:34 -04:00
Sam Lantinga
028e5dcdbd Happy New Year! 2011-12-31 09:28:07 -05:00
Ryan C. Gordon
c4348f44f7 Linux: Search a smaller set of potential joystick axes.
Newer kernels seem to report bogus axes in the higher ranges, for example
 with a standard PlayStation 3 controller plugged in via USB.
2011-07-13 17:38:09 -07:00
Sam Lantinga
b0660ba5ff SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
c2204a539c Fixed bug #1121 (More than one device through SDL_JOYSTICK_DEVICE)
Chusslove Illich      2011-02-13 04:30:28 PST

Currently SDL_JOYSTICK_DEVICE environment variable can be used to add
exactly one topmost device. I think it would be nice if one could also set
several devices (e.g. a stick and a throttle) in this way, as a colon-
separated list. The attached patch implements this
2011-02-16 04:51:13 -08:00
Sam Lantinga
e5803d148c Happy 2011! :) 2011-02-11 22:37:15 -08:00
Sam Lantinga
b33881a48e Fixed compile error 2011-01-24 15:10:16 -08:00
Sam Lantinga
c330005880 Fixed bug #1080
Markus Rathgeb      2011-01-23 14:34:23 PST

With kernel 2.6.31 the struct input_absinfo defined in linux/input.h changed.
A field "__s32 resolution" was added at the end of the struct.

Because the macro EVIOCGABS(abs) is using the struct input_absinfo, it would be
better (IMHO) to change the declaration of variable values to
"int values[sizeof(struct input_absinfo) / sizeof(int)];" or using "struct
input_absinfo" directly.
2011-01-24 14:36:12 -08:00
Sam Lantinga
4d3df8b3e3 Fixed bug #926
Updated copyright to LGPL version 2.1 and year 2010

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404453
2010-01-24 21:10:53 +00:00
Sam Lantinga
a9012609d3 Fixed crash in joystick handling code. Newer 2.6 kernels add an additional 'resolution' field to input_absinfo. Note that we don't use that structure since we want to have enough space for the values even when building with an older kernel.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404339
2009-12-17 07:22:48 +00:00
Sam Lantinga
410baa467e Fixed bug #853
Ludwig Nussel      2009-10-18 05:34:18 PDT

src/joystick/linux/SDL_sysjoystick.c has some problems:

- test_bit() might break with strict aliasing
- test_bit() assumes array is Uint32 but its actually "unsigned long"
  on 64bit systems sizeof(long) != sizeof(Uint32).
- the keybit array is too small
- the arrays are unitialized so the number of
  detected buttons is quite random

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404108
2009-10-18 16:14:35 +00:00
Sam Lantinga
efc7893227 Temporary band-aid for bug #575
It looks like newer kernels do the logical device mapping in the driver,
so this code crashes.  I don't have one of these nor do I have remote
access to debug this, so I'm disabling the logical mapping for now.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403937
2009-09-29 00:42:21 +00:00
Sam Lantinga
5c172c5af8 Fixed type size for test_bit()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403731
2009-08-02 20:45:11 +00:00
Sam Lantinga
17406a3e50 Fixed potential double-free crash
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403555
2009-03-06 05:53:33 +00:00
Edgar Simo
dd682a6489 Fixed haptic subsystem on linux 2.6.28 by lowering the EV_IsJoystick check (seems like some stuff was changed). Shouldn't break anything with earlier versions. Might need to be more robust if false positives show up.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403545
2009-02-21 18:02:55 +00:00
Couriersud
3e968cec07 Fix a 64bit issue in linux/SDL_sysjoystick (int != long on 64bit)
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403484
2009-01-11 23:39:11 +00:00
Sam Lantinga
d123950aa3 Reverted Bob's indent checkin
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403475
2009-01-10 21:50:26 +00:00
Bob Pendleton
44fa7675c8 I ran a global "make indent" it modified the following files.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403473
2009-01-09 20:43:30 +00:00
Sam Lantinga
0c30a927ed Updated copyright date
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403321
2008-12-08 00:27:32 +00:00
Sam Lantinga
ede44c4b85 Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403188
2008-08-27 15:10:03 +00:00
Sam Lantinga
4fd9c25fe6 Final merge of Google Summer of Code 2008 work...
Force Feedback for SDL
by Edgar Simo, mentored by Ryan C. Gordon

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403159
2008-08-25 09:55:03 +00:00
Sam Lantinga
42495af337 Fixed bug #497
Check all joysticks instead of stopping if one has been removed.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402670
2007-12-29 06:17:31 +00:00
Sam Lantinga
554147b6c7 make indent
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402345
2007-06-14 13:21:29 +00:00