Commit graph

140 commits

Author SHA1 Message Date
Sam Lantinga
91e0a1d094 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Philipp Wiesemann
2a8a7f92b7 Fixed empty parameter list in signatures of internal functions. 2016-11-16 22:08:51 +01:00
Sam Lantinga
c929b6d7b2 Fixed unresolved symbol on Visual Studio 2016-11-13 23:04:47 -08:00
Sam Lantinga
dae32409e9 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
1b032a0419 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga
253cd069c6 Fixed bug 3021 - HapticOpenFromJoystick() problems
Joe Thompson

With Direct Input device (MOMO Steering Wheel w/FF)
with SDL 2.0.3,
SDL_HapticOpenFromJoystick() would fail. (Can't set exclusive mode)
Now with 2.0.4 rc1,
SDL_HapticOpenFromJoystick() succeeds but the the returned SDL_Haptic* cannot be used. Calls to SDL_HapticNewEffect() fail with "Haptic error Unable to create effect"

If SDL_HapticOpen() is used instead of HapticOpenFromJoystick(), the device is usable. Calls to HapticNewEffect() succeed with the exact same parameters as the previous failing call.

I have attached a proposed patch for this issue.

When using SDL_HapticOpenFromJoystick(), the original code did not (re)enumerate the axes. This returned a new haptic device with 0 axes. Later, when a new effect is created, SDL_SYS_SetDirection() would set the flags to include DIEFF_SPHERICAL, regardless of what the caller actually set. (see Line 566 in SDL_dinputhaptic.c). This would cause the SDL_HapticNewEffect() to fail (or interpret the coordinates incorreclty.)

The patch moves the call to IDirectInputDevice8_EnumObjects() outside of the if() block so that the axes are (re)enumerated for the new haptic device.

Note: For steering wheels it is common for the joystick to have multiple axes (ie steering, throttle, brake), but the haptic portion of the joystick usually only applies to steering.
2016-10-04 03:50:28 -07:00
Sam Lantinga
b675802c8c Fixed build warnings and errors 2016-10-01 14:48:18 -07:00
Philipp Wiesemann
1d6a32758b Linux: Fixed memory leak in haptic implementation (thanks, Martin!).
Fixes Bugzilla #3238.
2016-07-20 21:01:14 +02:00
Ryan C. Gordon
591371ded7 Patched to compile on various platforms. 2016-04-12 18:11:36 -04:00
Ryan C. Gordon
2ef7fa3e3a threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default
and the global hint an app might have set), and remove all the macro salsa
for dealing with _beginthreadex and such, as internal threads always set those
to NULL anyhow.

I've taken some guesses on reasonable (and tiny!) stack sizes for our
internal threads, but some of these might turn out to be too small in
practice and need an increase. Most of them are simple functions, though.
2016-04-12 16:45:10 -04:00
Ryan C. Gordon
2503e42a28 Use SDL's stdinc functions instead of C runtime calls.
--HG--
extra : histedit_source : e1d934044bdfa9a54c4f0e0b09f053f6ad2b84c8
2016-01-05 02:29:16 -05:00
Ryan C. Gordon
60493ef8b1 Remove almost all instances of "volatile" keyword.
As Tiffany pointed out in Bugzilla, volatile is not useful for thread safety:

https://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/

Some of these volatiles didn't need to be, some were otherwise protected by
spinlocks or mutexes, and some got moved over to SDL_atomic_t data, etc.

Fixes Bugzilla #3220.
2016-01-03 06:50:50 -05:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
8038b8bb7f Fix crash on controller hotplug on linux.
CR: Sam
2015-09-30 15:38:30 -07:00
Ryan C. Gordon
f9158b31a1 Haptic/Linux: Keep track of device numbers properly to track duplicates.
Fixes Bugzilla #3014.

--HG--
extra : rebase_source : 0f5013166244c9d397acdaf74dcb8dd0187c7c6a
2015-06-16 00:57:45 -04:00
Sam Lantinga
819d3cc707 Fixed bug 2953 - Crash due to a bad cleanup in the SDL_SYS_HapticQuit function
Technically this is caused by the haptic devices not being closed at quit time, which we need to fix anyway, but this is a bandaid for now.
2015-06-14 19:21:13 -07:00
Philipp Wiesemann
e5cdbda294 Linux: Fixed not needed call to close() on error.
It was called if file descriptor was none and -1.
2015-06-08 20:46:09 +02:00
Ryan C. Gordon
1fbe75356d Maybe patched to compile on some Windows configurations.
(Maybe) Fixes Bugzilla #3001.
2015-06-07 18:29:23 -04:00
Ryan C. Gordon
9fd379f1d5 I think this will be the time... 2015-05-28 01:27:24 -04:00
Ryan C. Gordon
f1446b49f2 Still trying to get this to compile... 2015-05-28 01:22:14 -04:00
Ryan C. Gordon
a0d61787af More patching to compile... 2015-05-28 01:16:55 -04:00
Ryan C. Gordon
f6992428b4 Move tests from SDL_config higher up in Windows joystick/haptic code.
Fixes Bugzilla #2932.
2015-05-28 00:54:52 -04:00
Ryan C. Gordon
f9e0e40db2 Whoops, fix the static analysis fix. 2015-05-26 16:14:25 -04:00
Ryan C. Gordon
0f24d58e4e Darwin haptic: Fixed a static analysis warning if axes==0. 2015-05-26 12:47:03 -04:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Philipp Wiesemann
91a602526b Mac: Fixed typo in two error messages. 2015-04-11 20:41:49 +02:00
Ryan C. Gordon
e08e2cd4eb Remove unnecessary parentheses and an unnecessary free() of a NULL pointer.
(Thanks, Simon!)

Fixes Bugzilla #2881.
2015-02-19 13:11:19 -05:00
Philipp Wiesemann
eccf17ae12 Removed extern declaration of not existing SDL_numhaptics from internal header. 2014-12-11 23:38:02 +01:00
Philipp Wiesemann
518802a5c1 Replaced free() with SDL_free() because related allocation also uses wrapper. 2014-12-04 21:41:30 +01:00
Sam Lantinga
ed670a5786 Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification
Elias Vanderstuyft

Remove the dependency of the calculation of Linux "phase" on "period",
currently the "phase" parameter is interpreted as a time shift, instead of a phase shift.
The Linux input documentation is not clear about the exact units of the "phase" parameter (see http://lxr.free-electrons.com/source/include/uapi/linux/input.h?v=3.17#L1075 ),
but we're about to standardize the 'phase shift' interpretation into the Linux input documentation,
since this will ease the job of a driver to recalculate the effect's state when the user dynamically updates the "period" parameter.
2014-11-29 11:51:13 -08:00
Sam Lantinga
11db3a4830 Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification
Elias Vanderstuyft

It's not obvious from the general "haptic direction" description what the SDL direction actually means in terms of force magnitude sign,
currently its meaning is only reflected by the example.
2014-11-29 11:48:43 -08:00
Ryan C. Gordon
5ac5bdcea5 Haptic: Deal with negative periodic magnitudes (thanks, Elias!).
A negative periodic magnitude doesn't exist in Windows' and MacOS' FF APIs

The periodic magnitude parameter of the SDL Haptic API is based on the Linux
 FF API, so it means they are not directly compatible:
    'dwMagnitude' is a 'DWORD', which is unsigned.

Fixes Bugzilla #2701.

--HG--
extra : amend_source : eb0b85870149936fd451ddb0662841112ff93d07
2014-09-17 14:49:36 -04:00
Ryan C. Gordon
ea687875b0 Haptic: Fix clamping bugs on Windows, by using the Darwin haptics code.
Thanks, Elias!

Partially fixes Bugzilla #2686.
2014-08-16 16:49:00 -04:00
Ryan C. Gordon
640631c6dc Haptic: Fix the saturation and deadband parameters' available range.
There was a misconception that Linux's saturation and deadband parameters -
on which the corresponding SDL parameters were based - use only half of the
possible range.

Thanks, Elias!

Partially fixes Bugzilla #2686.
2014-08-16 16:47:42 -04:00
Ryan C. Gordon
f703b1b22c Haptic: Explicitly avoid floating point arithmetic if it's not needed.
Thanks, Elias!

Partially fixes Bugzilla #2686.
2014-08-16 16:42:55 -04:00
Ryan C. Gordon
b9be113196 Haptic: DInput's POLAR direction actually matches Linux's direction.
Thanks, Elias!

Partially fixes Bugzilla #2686.

--HG--
extra : histedit_source : 214ecbc7baaf28e6c7ff1eee687ee66f356446eb
2014-08-16 16:41:25 -04:00
Ryan C. Gordon
a5d019efa3 Haptic: Don't interpret a direction of polar 35999 as "unsupported type".
(or linux-direction 0xFFFF)

Thanks, Elias!

Partially fixes Bugzilla #2686.

--HG--
extra : histedit_source : 767fa48d79fe8dfe8dda1f155ff1e19a470d7efc
2014-08-16 16:40:01 -04:00
Sam Lantinga
bdb4ce60cd Fixed bug 2631 - Mac: minor code cleanup
Alex Szpakowski

Some minor changes to the Mac-specific backend code:

- Fixed up some code style issues (mostly brace style inconsistencies).

- Fixed a compiler warning in SDL_cocoaevents.m.

- Removed some useless code now that the 10.7 SDK is required to build SDL.

- Removed Gestalt(gestaltSystemVersion, ...) call and switched to NSAppKitVersionNumber for version checking code. Using Gestalt with gestaltSystemVersion will give 0x1090 in Mac OS 10.10+, and the whole Gestalt function was deprecated in Mac OS 10.8.
2014-07-07 12:48:25 -07:00
Sam Lantinga
9d42bf534d Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Sam Lantinga
3144954845 Fixed haptic refcount bug (thanks David Ludwig!) 2014-07-04 17:20:22 -07:00
Sam Lantinga
9cdeec59f3 Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
--HG--
rename : src/audio/directsound/directx.h => src/core/windows/SDL_directx.h
rename : src/haptic/windows/SDL_syshaptic.c => src/haptic/windows/SDL_windowshaptic.c
rename : src/haptic/windows/SDL_syshaptic_c.h => src/haptic/windows/SDL_windowshaptic_c.h
rename : src/joystick/windows/SDL_dxjoystick.c => src/joystick/windows/SDL_dinputjoystick.c
rename : src/joystick/windows/SDL_dxjoystick_c.h => src/joystick/windows/SDL_dinputjoystick_c.h
rename : src/joystick/windows/SDL_dxjoystick_c.h => src/joystick/windows/SDL_windowsjoystick_c.h
2014-07-03 15:39:55 -07:00
Sam Lantinga
9c48dd8a60 Fixed compiler warning - HRESULT is set to FFERR_* values, but is an int 2014-06-25 01:43:58 -07:00
Sam Lantinga
8072898dc9 Fixed bug 2562 - SDL_hapticlist/_tail not set correctly
Zachary L

SDL_hapticlist and SDL_hapticlist_tail are not set correctly when quitting the subsystem. This matters because they are represented as global variables. In the case you quit and reinitialize the subsystems, problems with dangling pointers arise.

For instance, SDL_hapticlist_tail will not be null on second initialization and because of the check on line 298, it will fail to set SDL_hapticlist appropriately. This can cause a few things to go wrong, like feeding SDL_strcmp a null fname which can cause a segfault.
2014-06-21 20:40:00 -07:00
Philipp Wiesemann
e68f76da43 Removed empty statements. 2014-04-05 23:50:09 +02:00
Sam Lantinga
492dbb3124 Fixed XInput haptic support on Windows 8
It turns out the XBox 360 controller driver never reports force feedback capability, so we'll try to set 0 state and see if that succeeds.
2014-03-29 12:29:38 -07:00
Ryan C. Gordon
ba24873506 Fixed SDL_HapticNewEffect() failing on various DirectInput devices. 2014-03-18 17:16:28 -04:00
Ryan C. Gordon
15dc860cfe Fixed SDL_HapticOpenFromJoystick() with DirectInput devices. 2014-03-17 19:11:18 -04:00
Ryan C. Gordon
5f11f71362 Windows: Fixed crash if quitting without closing an XInput haptic device.
--HG--
extra : histedit_source : ddde0349ad87c7b525efb7e0b01ee45fef9170af
2014-03-02 00:02:56 -05:00
Jørgen P. Tjernø
ca29983393 Mac: Fix error message for haptic subsystem.
We were calling SDL_Error instead of SDL_SetError when the haptic subsystem
wasn't initialized.
2014-02-25 17:25:49 -08:00
Gabriel Jacobo
9faed54ab1 Zero out haptic linked list items on creation
(thanks to Turo Lamminen for the report!)
2014-02-24 10:25:02 -03:00