src/joystick/SDL_joystick.c


Log

Author Commit Date CI Message
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga b647bd06 2017-10-10T17:41:41 The event filter and event watch functions are now thread-safe
Sam Lantinga d90fce3c 2017-10-10T11:10:15 Exposed the joystick locking functions for multi-threaded access to the joystick API
Sam Lantinga 5ab5c9b7 2017-09-22T08:56:09 Avoid duplicate joystick axis events
Sam Lantinga eaab6098 2017-09-21T10:29:17 Only apply the jitter filter to prevent unexpected motion on axes that haven't been touched.
Sam Lantinga de91b124 2017-08-14T06:28:21 Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks Patches contributed by Ozkan Sezer
Sam Lantinga 059d9e46 2017-08-12T17:41:59 Fixed bug 2950 - wrong axes values are set on joystick initialization Edward Rudd Device: Logitech Rumble Gamepad F510 in Xinput mode. Upon opening the joystick the values of the axes are queried via PollAllValues are not actually set on the device all the time. This can easily be seen in the testjoystick or testgamecontroller test programs,as the testjoystick shows all axes in the center until one 'tickles' the triggers., and the testgamecontroller will show the triggers as 'on' until on 'tickles' the triggers. Upon further research the culprit is the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint. In the default value events are ignored until there is an active window, Thus in cases where the joystick system is initialized and controllers opened before the initial window is created & focuses, the initial values will be incorrect. Here is my current workaround in the game I'm working on porting.. SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_GameController* gamepad = SDL_GameControllerOpen(index); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
Sam Lantinga c49fa37c 2017-08-09T11:59:29 Added SDL hints to filter the set of game controllers reported by SDL
Sam Lantinga 1eb92f63 2017-04-06T06:30:43 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
Sam Lantinga 763e1389 2017-03-09T16:09:16 Added an API to get the joystick instance ID before opening the device: SDL_JoystickGetDeviceInstanceID()
Sam Lantinga be28d7c8 2017-01-31T12:30:55 Added support for the Saitek Pro Flight X-56 Rhino
Sam Lantinga 6717a3d3 2017-01-31T12:23:29 Added support for the HOTAS Warthog throttle
Sam Lantinga a156b0d9 2017-01-31T10:20:09 Added the HOTAS Warthog as a flight stick
Sam Lantinga 95ab9dc7 2017-01-27T06:05:50 Added Thrustmaster Wheel FFB entry to the list of wheels
Sam Lantinga 3c90a52a 2017-01-27T05:59:58 Added an API to get the type of a connected joystick
Sam Lantinga 8fa0b088 2017-01-20T08:13:23 Added support for the 8Bitdo Zero GamePad
Sam Lantinga 4938c505 2017-01-04T10:28:07 Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value. This is useful for controller mapping programs to determine an axis' zero state
Sam Lantinga 99e10ef5 2017-01-04T07:06:48 Assume D-pad or thumbstick style axes are centered at 0
Sam Lantinga d2a01b6e 2017-01-04T06:19:56 Added the NEXT SNES Controller to the list of zero-centered joysticks
Sam Lantinga c7780497 2017-01-04T05:56:47 Increased joystick jitter tolerance for PS3 controllers
Sam Lantinga 082132a7 2017-01-03T23:39:28 Fixed binding the D-pad on some Super NES style controllers Fixed a case where partial trigger pull could be bound to another button There is a fundamental problem not resolved by this commit: Some controllers have axes (triggers, pedals, etc.) that don't start at zero, but we're guaranteed that if we get a value that it's correct. For these controllers, the current code works, where we take the first value we get and use that as the zero point and generate axis motion starting from that point on. Other controllers have digital axes (D-pad) that assume a zero starting point, and the first value we get is the min or max axis value when the D-pad is moved. For these controllers, the current code thinks that the zero point is the axis value after the D-pad motion and this doesn't work. My hypothesis is that the first class of devices is more common and that we should solve for that, and add an exception to SDL_JoystickAxesCenteredAtZero() as needed for the second class of devices.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga ca019dad 2016-12-22T17:33:45 Fixed issue where the throttle and other axes on racing wheels don't start at zero and show up as immediate input when the wheel is turned for the first time. Wait until they are actually moved before generating input from them.
Sam Lantinga b4ea63ec 2016-12-14T06:25:09 Fixed crash if there are multiple joysticks closed during the joystick update loop
Sam Lantinga 3b18c796 2016-12-09T01:29:52 Fixed bug 3512 - Memory leak of SDL_Joystick axes_zero array Benjamin Harris Found with valgrind and confirmed in the 2.0.5 source code. One-line fix in SDL_JoystickClose?
Sam Lantinga a5250171 2016-12-08T10:13:45 Protect the game controller API the same way the joystick API is protected from multi-threaded access
Philipp Wiesemann a7655d77 2016-11-30T23:31:23 Fixed warning about storing an unused value. Found by buildbot.
Sam Lantinga 5220759f 2016-11-29T05:04:42 Made it safe to update joysticks from multiple threads, fixes crash in Steam
Sam Lantinga e9983c7b 2016-11-24T11:53:23 We are comparing 16-bit values
Sam Lantinga b6542ab2 2016-11-11T04:30:09 Fixed whitespace
Sam Lantinga ac74e16c 2016-11-10T17:19:34 Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller.
Sam Lantinga 8bc5c57d 2016-10-07T16:13:37 Fixed recentering triggers when the application doesn't have focus
Sam Lantinga ad1bfea5 2016-08-26T12:18:08 Added SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() Updated the removal code to iterate over all joystick add messages instead of just the first one.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Ryan C. Gordon e6ad29ae 2015-11-14T12:35:45 Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
Sam Lantinga a0c4b56f 2015-09-30T15:39:30 SDL - added new SDL_JoystickCurrentPowerLevel() API that returns the battery level of the selected joystick. Currently only implemented for XInput devices, other platforms are a TODO. CR: Sam
Alex Szpakowski 2bf6f1bc 2015-09-20T23:08:36 Added initial support for MFi game controllers on iOS.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Ryan C. Gordon 162ef5ea 2015-03-24T13:52:01 Cleanups in the joystick code. Removed some redundant state and other confusions. Fixes Bugzilla #2738.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 52ec151f 2014-06-24T13:31:25 Fixed bug 2553 - Add support to all XInput devices This adds support for all XInput devices, exposed through the SDL joystick API. The button and axis reporting for XInput devices has been changed to match DirectInput and other platforms. The game controller xinput mapping has been updated so this change is seamless. There is a new hint, SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING, for any applications that have hardcoded the old xinput button and axis set. This hint will be removed in SDL 2.1.
Sam Lantinga 7b7828a4 2014-06-21T21:30:49 You shouldn't get axis and hat events when your application doesn't have focus (unless you use the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint)
Ryan C. Gordon 446d19c4 2014-06-14T23:31:23 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.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 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.
Sam Lantinga 33cf925c 2013-11-09T01:08:21 Fixed signed/unsigned warning
Sam Lantinga b8b9bfbe 2013-10-21T01:16:16 Fixed some warnings building for 64-bit Windows
Sam Lantinga 8f46bcfd 2013-10-06T13:49:23 Check for NULL joystick in SDL_JoystickGetGUID()
J?rgen P. Tjern? f06eeb01 2013-09-05T15:49:57 Fix to buffer overrun in SDL_JoystickGetGUIDString().
Sam Lantinga f79fc33a 2013-08-29T08:29:21 Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Gabriel Jacobo 695344d1 2013-08-21T09:43:09 OCD fixes: Adds a space before */
Gabriel Jacobo 63fe3a77 2013-08-20T19:49:24 Fixes a few non C89 compliant comments
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.