Commit Graph

133 Commits

Author SHA1 Message Date
Philipp Wiesemann
bef8634446 Linux: Fixed memory leak in haptic implementation (thanks, Martin!).
Fixes Bugzilla #3238.
2016-07-20 21:01:14 +02:00
Ryan C. Gordon
b0c0d27997 Patched to compile on various platforms. 2016-04-12 18:11:36 -04:00
Ryan C. Gordon
5006582bed 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
0170123536 Use SDL's stdinc functions instead of C runtime calls. 2016-01-05 02:29:16 -05:00
Ryan C. Gordon
0e7135739a 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
255c182471 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
077095e25d Fix crash on controller hotplug on linux.
CR: Sam
2015-09-30 15:38:30 -07:00
Ryan C. Gordon
d21c2fcb6b Haptic/Linux: Keep track of device numbers properly to track duplicates.
Fixes Bugzilla #3014.
2015-06-16 00:57:45 -04:00
Sam Lantinga
ad00278cdc 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
89354ffca2 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
3f40271c0e Maybe patched to compile on some Windows configurations.
(Maybe) Fixes Bugzilla #3001.
2015-06-07 18:29:23 -04:00
Ryan C. Gordon
f31caf461b I think this will be the time... 2015-05-28 01:27:24 -04:00
Ryan C. Gordon
0d19c170d8 Still trying to get this to compile... 2015-05-28 01:22:14 -04:00
Ryan C. Gordon
04f8adf125 More patching to compile... 2015-05-28 01:16:55 -04:00
Ryan C. Gordon
5f111141e4 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
4f20aa283f Whoops, fix the static analysis fix. 2015-05-26 16:14:25 -04:00
Ryan C. Gordon
5bf1e0d78f Darwin haptic: Fixed a static analysis warning if axes==0. 2015-05-26 12:47:03 -04:00
Sam Lantinga
78f2198e6c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Philipp Wiesemann
62e57a47cf Mac: Fixed typo in two error messages. 2015-04-11 20:41:49 +02:00
Ryan C. Gordon
22747dfaa8 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
1bc1891db0 Removed extern declaration of not existing SDL_numhaptics from internal header. 2014-12-11 23:38:02 +01:00
Philipp Wiesemann
a3bb9a9af0 Replaced free() with SDL_free() because related allocation also uses wrapper. 2014-12-04 21:41:30 +01:00
Sam Lantinga
330100f40a 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
5b0a60912f 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
4563873c18 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.
2014-09-17 14:49:36 -04:00
Ryan C. Gordon
a61f94f2a4 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
5f4bff4acc 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
913d3c0acb 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
8ba088f60b Haptic: DInput's POLAR direction actually matches Linux's direction.
Thanks, Elias!

Partially fixes Bugzilla #2686.
2014-08-16 16:41:25 -04:00
Ryan C. Gordon
a752aefd59 Haptic: Don't interpret a direction of polar 35999 as "unsupported type".
(or linux-direction 0xFFFF)

Thanks, Elias!

Partially fixes Bugzilla #2686.
2014-08-16 16:40:01 -04:00
Sam Lantinga
d19bc1c3b8 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
0da7ddd120 Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Sam Lantinga
c31088073c Fixed haptic refcount bug (thanks David Ludwig!) 2014-07-04 17:20:22 -07:00
Sam Lantinga
6dd1e2f2f6 Split the XInput and DirectInput code so Windows RT can use the existing XInput support. 2014-07-03 15:39:55 -07:00
Sam Lantinga
3f4d70266b Fixed compiler warning - HRESULT is set to FFERR_* values, but is an int 2014-06-25 01:43:58 -07:00
Sam Lantinga
b52c6ef8b0 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
8cc0a1f080 Removed empty statements. 2014-04-05 23:50:09 +02:00
Sam Lantinga
4ad73f0dda 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
2be5efc8ad Fixed SDL_HapticNewEffect() failing on various DirectInput devices. 2014-03-18 17:16:28 -04:00
Ryan C. Gordon
91cea37295 Fixed SDL_HapticOpenFromJoystick() with DirectInput devices. 2014-03-17 19:11:18 -04:00
Ryan C. Gordon
e3cdc782d7 Windows: Fixed crash if quitting without closing an XInput haptic device. 2014-03-02 00:02:56 -05:00
Jørgen P. Tjernø
2ccfd3e029 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
08e6695494 Zero out haptic linked list items on creation
(thanks to Turo Lamminen for the report!)
2014-02-24 10:25:02 -03:00
Edward Rudd
8c04aaf554 ignore hot plugs in mac haptic layer IF hap tics hasn't been initialized. 2014-02-07 09:35:13 -05:00
Ryan C. Gordon
326bcf7cef Fixed crash on Windows if haptic isn't initialized when controllers are added. 2014-02-06 21:26:41 -05:00
Ryan C. Gordon
1e6f86ee52 Fixed a typo. 2014-02-06 10:00:45 -05:00
Edward Rudd
52bef1a3cf Fix device counting in HapticMouse and JoystickOpen routines. 0 is the first item in the list not the last 2014-02-06 09:35:44 -05:00
Edward Rudd
7123f71d3d fix indentation and spaces 2014-02-06 09:11:05 -05:00
Ryan C. Gordon
97e15d4d3b Wired up haptic hotplugging for Windows DirectInput/XInput code. 2014-02-06 07:37:20 -05:00
Ryan C. Gordon
1aef91f898 Fixed memory leak. 2014-02-05 20:07:25 -05:00