Commit graph

112 commits

Author SHA1 Message Date
Sam Lantinga
b044a3bba8 Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
Philipp Wiesemann
4755c05d29 linux: Changed internal functions to be static. 2017-06-11 22:30:58 +02:00
Sam Lantinga
3b03af8b7e Implemented Linux joystick blacklist
Based on https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py

This fixes a few devices that are not actually joysticks showing up as such in SDL
2017-04-06 06:30:43 -07:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
c0bf85bee4 The XBox One S controller sends keys outside the standard joystick button range 2016-11-22 22:14:28 -08:00
Philipp Wiesemann
2a8a7f92b7 Fixed empty parameter list in signatures of internal functions. 2016-11-16 22:08:51 +01:00
Sam Lantinga
dae32409e9 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
6fcf21b827 Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller. 2016-11-10 17:19:34 -08:00
Sam Lantinga
f98a06ec45 Added SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved()
Updated the removal code to iterate over all joystick add messages instead of just the first one.
2016-08-26 12:18:08 -07:00
Sam Lantinga
b97a48ebad commit 1170112da3776fdb06425f62d57b63144c33dc51
Author: James Zipperer <james.zipperer@synapse.com>
Date:   Sun Aug 21 01:19:19 2016 -0700

    bugfix for controller / joystick add / remove being in the event queue at the same time
2016-08-26 11:16:44 -07:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Ryan C. Gordon
4cb7923f25 Linux joystick: Look at entire axis namespace for controls (thanks, "spaz16"!).
This apparently has fallout: the PS4 (and maybe PS3?) controllers apparently
report some bogus axes, but it won't change the axes we currently expect, and
thus the game controller config string is still stable.

Fixes Bugzilla #2719.

--HG--
extra : rebase_source : 8c5a4d949e4706366bbf2d98d2d2df1762d040a9
2015-05-26 12:03:51 -04:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Philipp Wiesemann
fc24a2d81e Fixed typo in internal joystick documentation comments. 2015-04-15 21:29:55 +02:00
Ryan C. Gordon
3ff618a9c7 Cleanups in the joystick code.
Removed some redundant state and other confusions.

Fixes Bugzilla #2738.

--HG--
extra : rebase_source : 35dd561553379e00eb8d169ce12ecc99393b2f84
2015-03-24 13:52:01 -04:00
Philipp Wiesemann
bde0ce0969 Updated internal documentation comments. 2015-03-11 21:14:21 +01:00
Sam Lantinga
81aaff41c9 Fixed game controller hotplug support for some embedded Linux devices
When guessing the device class, it ends up being 0 for devices that have been removed (because the device node no longer exists)
2015-01-29 13:33:53 -08:00
Ryan C. Gordon
fbdde501ba Removed SDL_SYS_JoystickNeedsPolling().
It was simpler to just have the polling (actually: hotplug detection)
 functions return immediately if it's not an appropriate time to poll.

Note that previously, if any joystick/controller was opened, we would poll
 every time anyhow, skipping this function.
2014-06-14 23:31:23 -04:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
Philipp Wiesemann
d66561a66d Fixed comments in joystick implementation files claiming to be headers.
It seems comments were originally copied from SDL_sysjoystick.h.
2014-01-29 00:27:54 +01:00
Ryan C. Gordon
82edee6971 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.

--HG--
extra : rebase_source : ddf4a4c0dc2c554b98c82700798f343cd91b16e3
2013-11-24 23:56:17 -05:00
Sam Lantinga
db521ea67c Fixed detecting the wired XBox 360 controller on Linux
Also added some more debug output to detect issues
2013-12-06 09:13:31 -08:00
Sam Lantinga
edb61cbae1 Make sure the joystick count is correct when the added and removed events are dispatched, in case someone is watching for them with an event filter. 2013-11-08 14:04:59 -08:00
Gabriel Jacobo
344ed6c986 Fixes Bug 1944 - Linux events, joysticks having only hat are not read 2013-11-06 09:48:45 -03:00
Sam Lantinga
44dbed38ac Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings
Andreas Ertelt

The problem in question is caused by changeset 7771 (http://hg.libsdl.org/SDL/rev/4434498bf4b9 / https://bugzilla.libsdl.org/show_bug.cgi?id=2121)

The redefinition of __inline__ (introduced by the addition of begin_code.h:128's "|| __STRICT_ANSI__") results in mingw's gcc throwing multiple

   warning: always_inline function might not be inlinable [-Wattributes]

as well as a whole bunch of redefinitions of mingw internals which break linking of projects including the SDL2 headers.
2013-10-20 21:56:15 -07:00
Sam Lantinga
e63559cffd Report joystick added/removed events even if we don't have udev.
T. Joseph Carter

As discussed (possibly to death), the Linux joystick driver does not actually report events for added or removed joysticks when you haven't got udev support.

We simply cannot know about removed joysticks without udev.  But we can (and we should) report adding them.  This brings the legacy case in line with pretty much the rest of SDL's joystick drivers.
2013-10-10 20:58:20 -07:00
Sam Lantinga
5c03a1488f Fixed bug where a Logitech wireless keyboard with built-in mouse touchpad didn't get recongized as both devices. 2013-10-05 21:15:55 -07:00
Gabriel Jacobo
f82f0ebb6f Uses SDL_UDEV for Linux joystick hotplugging 2013-10-01 08:47:06 -03:00
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