Commit graph

56 commits

Author SHA1 Message Date
Ryan C. Gordon
ae216dde6c Added a FIXME. 2014-03-01 22:27:21 -05:00
Ryan C. Gordon
8135173e3f Fixed a typo in a comment. 2014-03-01 22:27:13 -05:00
Ryan C. Gordon
81801cb940 Added some FIXMEs. 2014-03-01 20:59:43 -05:00
Ryan C. Gordon
441bde12ca Wired up haptic hotplugging for Windows DirectInput/XInput code. 2014-02-06 07:37:20 -05:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
Ryan C. Gordon
63256a2384 Implemented the Dynamic API magic.
--HG--
extra : rebase_source : 38f639089d3d142895d5cf106919a0bfbb65c5ed
2013-12-09 16:03:18 -05: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
Ryan C. Gordon
cc7596fc7e Fix adding of XInput devices (thanks, Mitchell!)
Partially fixes Bugzilla #2126.
2013-10-20 15:40:20 -04:00
Sam Lantinga
4a8f77da84 Fixed bug 2069 - Device addition/removal queries all USB devices rather than only HID devices.
Andreas Ertelt
SDL_dxjoystick.c is setting the classguid for device (dis)connect events to USB Devices in general:
    dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;

Wouldn't it make more sense to have it just subscribe to Hid device events? This would mean less meaningless events reaching the application.
2013-10-17 23:40:13 -07:00
Sam Lantinga
08dfaaa2e6 Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
Ryan C. Gordon
44918e378d Change order we enumerate Windows joysticks.
Make it so XInput devices are listed before DirectInput devices, and that the XInput
 devices are sorted by userid in ascending numeric order (so device 0 comes first).
2013-08-28 22:09:17 -04:00
Ryan C. Gordon
e670fc63f1 Don't corrupt XInput device state during SDL_SYS_JoystickClose(). 2013-08-28 22:07:54 -04:00
Ryan C. Gordon
526597ad95 Make XInput joystick names match the numbers on the device.
(And how the Haptic code already names them.)
2013-08-28 17:17:21 -04:00
Ryan C. Gordon
6f21990987 Reworked XInput and DirectInput joystick code.
Now multiple XInput controllers map correctly to device indexes instead of grabbing
the first available userid, and are completely separated out from DirectInput.

Also, the hardcoded limitation on number of DirectInput devices is gone. I don't
expect there to really ever be more than eight joysticks plugged into a machine, but
it was a leftover limitation for a static array we didn't actually use anymore.

Fixes Bugzilla #1984. (etc?)

--HG--
extra : rebase_source : 103ce667c1cdd87a3691c9dd9eea2318bad908c8
2013-08-28 16:43:47 -04:00
Ryan C. Gordon
17c90f1186 Better XInput detection code for DirectInput device enumeration.
This code is way faster than the Wbem code, and less ugly.

--HG--
extra : rebase_source : cce46397251068b426e2ec267c15292aa0744386
2013-08-28 16:35:32 -04:00
Sam Lantinga
54d87dfc28 SDL
- detect that you tried to open a gamecontroller in xinput mode and failed, then re-get the mapping for the dinput variant you did open (and most likely now just fail the open)

CR: SamL
2013-08-21 10:32:04 -07:00
Sam Lantinga
8ddc481d35 Fix SDL xinput code to work at all when xinput has devices at high indexes but no device connected at lower index, for instance 0->disconnected, 1->wireles, 2->wired. Previously the SDL code assumed the indexes were always used up in order which is not true at all and lead to a bunch of failure cases where controllers would go unrecognized.
This entire function is kind of a mess and more complicated than needed, but I don't want to refactor it too heavily tonight.  May look at improving how the indexes are assigned more significanly later.  The way it handles not finding a valid "gamepad" type device is also super broken, it leaves in place the xinput bindings but opens the controller with dinput and ends up with completely wrong mappings, not solving that now, but fixing the bug where we'd very frequently not find a controller due to gaps in assigned player numbers should mostly avoid it.
2013-08-21 10:31:44 -07:00
Gabriel Jacobo
5e78879e76 More non C89 compliant comments 2013-08-20 20:34:40 -03:00
Sam Lantinga
a8055a9808 Fixed bug: SDL2 Xinput joystick axis jumps from positive to negative
Franz Schrober

Attached is my patch. It ensures that the values are correctly limitted between -32767 and 32767 (otherwise the negator - and the conversion to sint16 would corrupt the result)

I am using Motioninjoy (Dualshock 3 Sixaxxis controller on Windows 7)  together with a recent SDL2 (post rc1) and noticed with the testjoystick binary that the axis 3 (left analog up/down) jumps when going in down direction from 32257 to -32768. This seems obviously wrong and I have never seen this before. In my games the people are now going backwards before they start to sprint forward when the player actually wants to run as fast as possible backwards. This also happens on the axis 2 (right analog stick up/down)

This problem doesn't happen in DX mode
2013-06-27 11:21:37 -07:00
Sam Lantinga
4c59063d54 Check for well known XInput device GUIDs before enumerating the device list. 2013-06-07 18:26:55 -07:00
Sam Lantinga
7de1fa00ff It's better not to have the full range of the axis (by 1 on the negative side) than turn 0 value into -1 2013-06-07 08:48:25 -07:00
Sam Lantinga
0e48e3563b The triggers should be expanded out to the full range to match DirectInput behavior.
The game controller code will scale them back to 0 - 32767 when it converts the triggers axes.
2013-06-06 17:59:01 -07:00
Sam Lantinga
86b3564df2 Hopefully fixed mingw32 build 2013-06-02 08:48:52 -07:00
Sam Lantinga
cd88135edc Gyrations to get the code to compile with the latest version of mingw-w64 as well as Visual Studio.
I think in this case mingw-w64 is incorrect in defining the GUID instead of declaring it like Visual Studio and the older mingw32 compilers.
2013-06-02 01:35:38 -07:00
Sam Lantinga
fbef22a01a Fixed Visual Studio build 2013-05-26 14:37:41 -07:00
Sam Lantinga
8408ce85ee Fixed compile errors building with mingw64 2013-05-26 11:34:04 -07: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
Ryan C. Gordon
8181152c53 Patched to compile on Visual Studio. 2013-03-10 13:36:20 -04:00
Ryan C. Gordon
2e19fefe52 Attempt to get XInput haptics building on Cygwin (or rather, avoid building). 2013-03-10 13:28:39 -04:00
Ryan C. Gordon
3d572bdf89 First shot at Windows XInput haptics.
--HG--
extra : rebase_source : 52e691a0917d173e891e67714a135373daea0ef5
2013-03-10 13:05:47 -04:00
Sam Lantinga
c6388c87c1 Changed the name of SDL_mutexP() SDL_mutexV() 2013-03-07 20:12:40 -08:00
Sam Lantinga
69b8182419 The joystick events contain a joystick instance ID, which is a signed value, with -1 being invalid. 2013-03-06 11:59:21 -08:00
Sam Lantinga
541a638836 Fixed compile errors on Windows 2013-03-06 09:45:53 -08:00
Edward Rudd
191718be44 add hint to allow disabling the use of Xinput. 2013-03-05 18:01:59 -05:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
f4294fd806 Improvements from Alfred:
- Added new SDL_HINT_ALLOW_TOPMOST hint, when set to "0" then never set the topmost bit on a window. Useful when debugging fullscreen issues.
- fixed crash in windows joystick scanning if we failed to load the xinput dll
- added support for SDL_WINDOW_FULLSCREEN_DESKTOP under windows
- synthesize relative mouse movements if directinput fails to send relative moves, happens under virtual box.
2012-12-31 09:30:15 -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
6ac6dd737a Move all DirectInput code from DI2 to DI8.
Fixes failing Haptic subsystem initialization on Windows.
2012-11-29 15:24:56 -05:00
Sam Lantinga
556c764047 Fixed crashes in new joystick code 2012-11-28 11:52:38 -08:00
Sam Lantinga
cf4a5b5570 Alfred Reynolds - add scanning of XInput for controller connectedness so we can detect when the wireless controller turns on and off, the usb side doesn't change when the controller goes away 2012-11-27 09:19:09 -08:00
Sam Lantinga
9ab24950fc Fixed compiler warnings 2012-11-27 01:09:18 -08: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
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
816523a285 Fixed a bunch of compiler warnings with Cygwin/MingW. 2012-08-24 19:34:28 -04:00
Sam Lantinga
68b32846b8 Fixed bug 1371 - DX joystick axis ordering fix
Alex Nankervis 2012-01-15 11:19:45 PST

DirectX joysticks can enumerate their axis out of order. This results in some
joysticks having vertical/horizontal swapped, for example (vertical axis gets
assigned to axis0). Joysticks that I've tested with this problem: XBOX 360
controller, Logitech Extreme 3D Pro.

Attached is a diff that fixes this by sorting the DX joystick objects by their
data offsets into the DX data structs. This puts the joystick objects into a
standard ordering (X axis -> axis0, Y axis -> axis1, and so on).
2012-01-15 15:48:27 -05:00