src/joystick/android


Log

Author Commit Date CI Message
Cameron Gutman 1ccfbf96 2021-11-11T11:13:08 joystick: Convert HasLED() into a generic GetCapabilities() function
Sam Lantinga d135c076 2021-07-08T13:22:41 Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers See testgamecontroller.c for an example of a custom PS5 trigger effect
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga fcb21aa8 2020-11-17T10:30:20 Added API for sensors on game controllers Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers Also fixed an issue with the accelerometer on iOS having inverted axes
Sam Lantinga 71e32f5e 2020-11-16T15:00:15 Added SDL_crc32()
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga 009b62f1 2020-11-07T02:22:15 Be explicit about mapping the new game controller paddle buttons
Sam Lantinga 3a3aaac2 2020-11-06T11:30:52 Added 4 auxiliary buttons to the game controller API Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver PS4 and PS5 controllers use AUX1 to represent the touchpad button Nintendo Switch Pro controllers use AUX1 to represent the capture button
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga 345b4d7e 2020-05-29T13:37:21 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification Jan Bujak I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL. Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this: https://www.kernel.org/doc/html/v4.15/input/gamepad.html Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments. Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.) With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga c44473ba 2020-03-12T19:47:30 Unified code to standardize joystick names
Sam Lantinga 6efebf17 2020-02-04T12:48:53 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 46e1377d 2019-12-20T20:12:03 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks. Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()
Sam Lantinga 9da4bfc1 2019-10-22T10:57:07 Added support for the Power A Nintendo Switch Enhanced Wireless Controller
Sylvain Becker 70dc8d16 2019-08-30T08:55:20 Android: fix corresponding warnings
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sylvain Becker 7468d1e0 2018-12-06T15:46:40 Fix warnings detected on Android build
Sam Lantinga 14329256 2018-10-25T16:53:14 Generalized the XInput user index into a player index
Sam Lantinga 63107524 2018-08-15T19:53:34 Fixed input from the Steam Virtual Gamepad on Mac OS X
Sam Lantinga 888bf1af 2018-08-09T16:03:50 Worked around bug with Sony PS Now PS3 controller where DirectInput polling will continue to return success after the controller is unplugged. The code is now reliant on SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() being called correctly when devices are added or removed on Windows
Sam Lantinga d2042e1e 2018-08-09T16:00:17 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms. Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
Sam Lantinga 9e651b69 2018-03-06T14:51:50 Try to dynamically create a default Android game controller mapping based on the buttons and axes on the controller. Include the controller USB VID/PID in the GUID where possible, as we do on other platforms.
Sam Lantinga 7c360027 2018-02-09T16:01:11 Fixed compiler warning on Android
Sam Lantinga f59b9c8b 2018-02-06T15:03:38 Replaced SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS with SDL_HINT_TV_REMOTE_AS_JOYSTICK which controls whether remotes on iOS and Android are interpreted as joysticks (the default) or as return/escape/arrow keys.
Ryan C. Gordon e99daaf8 2018-01-22T09:45:16 android: Fixed compiler warning about nested '/*' comments.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga cc30e1eb 2017-12-16T10:40:43 Added support for the ASUS TV500BG Android gamepad
Sam Lantinga c954b538 2017-11-02T08:48:14 Fixed bug 3935 - Not find joysticks if android run 24-48 days. Alexander Orefkov In src\joystick\android\SDL_sysjoystick.c in SDL_SYS_JoystickDetect when SDL_GetTicks return number grater 2147483648 (after 24.85 days uptime) SDL_TICKS_PASSED(SDL_GetTicks(), timeout) return FALSE and Android_JNI_PollInputDevices is never calling. And in JoystickByDeviceId - when search for newly added joystic - after SDL_SYS_JoystickDetect item not reinitilized, and always stay NULL, cause return NULL instead of added joystick.
Sam Lantinga a90be440 2017-11-01T10:06:58 Added controller mapping for Android TV remotes Also fixed the back button on the remote exiting the application
Sam Lantinga d8286479 2017-09-22T08:30:52 Added stubs for simple Steam Controller support
Sam Lantinga 2a945b44 2017-08-28T10:03:39 Fixed bug 2361 - [Android] Joysticks do not have unique IDs David Brady When I attempted to make a mapping file for Android gamepads, I quickly discovered that most of the ones that I have here show up as the same device (Broadcom Bluetooth HID), meaning that it was impossible to make mappings on Android, since every device looked the same. This patch will check for the existence of the getDescriptor function added in Jelly Bean, and use it if it's there. The Android Dashboard says that the majority of Android phones should support this function, and doing it this way will not force us to bump up our API version.
Sam Lantinga 0d011ec6 2017-08-28T00:22:23 Renaming of guard header names to quiet -Wreserved-id-macro
Sam Lantinga 0a52db54 2017-08-12T08:15:09 Fixed bug 3191 - haptic system on android? Patch provided by jintiao and Milan Nikolic, thanks!
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 26f05ecb 2016-12-02T02:25:12 Fixed missing prototypes on Android, patch from Sylvain
Philipp Wiesemann 97aa5775 2016-11-16T22:08:51 Fixed empty parameter list in signatures of internal functions.
Sam Lantinga ae8ca7c5 2016-10-17T22:09:22 Fixed bug 3444 - Android-TV: no more handling of back button on remote ny00 Unfortunately, simply checking the return codes of "onNativePadDown/Up" as previously done has its own issue: If an SDL joystick is connected *and* opened, then a proper KeyEvent, say with keycode KEYCODE_BUTTON_1, should lead to an SDL joystick button event as expected. If, however, the joystick was *not* opened, then "onNativePadDown/Up" will return a negative value, so before the commit from bug 3426, you could unexpectedly get a keyboard event. (In practice, you'll just get a log message, since KEYCODE_BUTTON_1 has no mapping to a proper SDL_ScanCode value, but it's still an problem). What should still be done, though, is checking the key code itself. We do have the KeyEvent.isGamepadButton method, but according my test, it returns "true" exactly (and only) for the KEYCODE_BUTTON* values, and not for KEYCODE_DPAD* or any other key code. Here is a possible solution: - Do check the return codes of "onNativePadDown/Up" as previously done. - In addition, in "Android_OnPadDown/Up" from src/joystick/android/SDL_sysjoystick.c, 0 should *always* be returned in case the key code can be translated to an SDL_joystick button; Even if no matching joystick can be found.
Sam Lantinga 27d4f099 2016-10-07T23:40:44 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
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.
Philipp Wiesemann e41e185e 2016-08-25T22:31:33 Android: Fixed crash if closing removed joystick (thanks, Sylvain!). Fixes fix for Bugzilla #3408.
Philipp Wiesemann c18ff8d2 2016-08-17T21:04:32 Android: Fixed opening previously closed joystick (thanks, Sylvain!). Fixes Bugzilla #3408.
Ryan C. Gordon dddd6a5a 2016-02-19T00:28:53 Android: Restored Philipp's joystick change, lost in the previous merge. This patch, specifically: https://hg.libsdl.org/SDL/rev/c0976de9c332
Ryan C. Gordon 03f97117 2016-02-19T00:24:00 Merge Android C89 fixes from Eric Wing.
Philipp Wiesemann 9cd9925c 2016-02-16T20:32:22 Android: Changed an internal joystick function to return count instead of id. The returned value is currently not used by the caller. The instance id would also not be needed on Java side and providing it just complicated the function. Partially fixes Bugzilla #3234.
Philipp Wiesemann 7da168db 2016-02-10T19:31:23 Fixed spaces in license comments.
Eric Wing 704298c0 2016-02-09T17:36:42 Android: C89 cleanup to avoid warnings/errors since the default gcc mode on Android is still pre-C99.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
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 3779bf38 2015-06-17T00:00:53 Fixed bug 2948 - [Android] Arrow keys from external keyboard are not received Sylvain http://developer.android.com/reference/android/view/InputDevice.html int SOURCE_CLASS_JOYSTICK Constant Value: 16 (0x00000010) int SOURCE_JOYSTICK Constant Value: 16777232 (0x01000010) int SOURCE_KEYBOARD Constant Value: 257 (0x00000101) int SOURCE_GAMEPAD Constant Value: 1025 (0x00000401) int SOURCE_DPAD Constant Value: 513 (0x00000201) I have an a PC keyboard that I connect to an android device. The issue is that "arrow" keys gets lost. More explanation: This device gets detected twice by the java "pollInputDevices()" both as SOURCE_KEYBOARD and as a composite (0x1000311 == SOURCE_JOYSTICK | SOURCE_KEYBOARD | SOURCE_DPAD). Because of being a SOURCE_CLASS_JOYSTICK, only the second entry is registered, and I opened it. When I press one arrow key, the java method "onKey(...)" is called. The Source "event.getSource()" is "SOURCE_KEYBOARD", so it enters this conditions : if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 || (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) { And then, it enters : SDLActivity.onNativePadDown() (native code in "SDL_sysjoystick.c") Since the "arrows" are viewed as "D-PAD", it gets translated : int button = keycode_to_SDL(keycode); But the android-java "event.getDeviceId()" is wrong: this is the one from the Keyboard, and not the one from the Joystick that I have opened. So I don't get them through the Joystick interface. And since, the keycode has been translated, it returns 0 and assume it was consumed. So I lost the key in the function "Android_OnPadDown()" Notice, It won't happen with other normal "letters" keys because they does not get translated by "keycode_to_SDL", so "Android_OnPadDown()" returns -1. And then java code send the keys to "SDLActivity.onNativeKeyDown()". Possible patch on "Android_OnPadDown" and also "Android_OnPadUp" (and maybe other functons): 85 int 186 Android_OnPadDown(int device_id, int keycode) 187 { 188 SDL_joylist_item *item; 189 int button = keycode_to_SDL(keycode); 190 if (button >= 0) { 191 item = JoystickByDeviceId(device_id); 192 if (item && item->joystick) { 193 SDL_PrivateJoystickButton(item->joystick, button , SDL_PRESSED); 194 } + else return -1; 195 return 0; 196 } 197 198 return -1; 199 } It would allow the java caller function to send the key to "SDLActivity.onNativeKeyDown();" Another solution, would be to replace: if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 || (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) { by if ( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) Because only "SOURCE_CLASS_JOYSTICK" devices are registered/opened.
Sam Lantinga d7975823 2015-06-14T19:26:20 Fixed style
Sam Lantinga 34634082 2015-06-14T19:25:12 Fixed bug 3012 - Android accelerometer joystick axis values overflow when values from Android are larger than gravity Magnus Bjerke Vik This causes issues when for instance using the joystick API to make an Android phone rotate an object by rotating the phone. When the absolute value of an axis reported by android is larger than earth gravity, SDL will overflow the Sint16 value used for joystick axes, causing sporadic movements when close to the gravity. Just holding the phone so that e.g. Y points directly upwards will make it unstable, and even more if you just tap the phone gently from below (increasing the acceleration). More detailed: SDLActivity gets the accelerometer values in onSensorChanged and divides each axis by earth gravity. SDL_SYS_JoystickUpdate takes each of the axis values, multiplies them by 32767.0 (largest Sint16), and the casts them to Sint16. From this you can see that any value from Android that exceeds earth gravity will overflow the joystick axis. A fix is to clamp the values so that they won't overflow the Sint16.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Philipp Wiesemann 9979bab2 2015-04-30T21:45:29 Android: Deactivated debug log messages on joystick device events.
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.
Philipp Wiesemann 3e1d3629 2015-04-15T21:29:55 Fixed typo in internal joystick documentation comments.
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.
Philipp Wiesemann da843f6a 2015-03-11T21:14:21 Updated internal documentation comments.
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 f4b7cf6e 2015-01-31T21:02:56 Fixed including SDL_config.h in implementation for Android. SDL_internal.h should be included to support dynamic API.
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
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 63106e47 2014-03-01T12:21:15 Changed SDL_HINT_ACCEL_AS_JOY to SDL_HINT_ACCELEROMETER_AS_JOYSTICK to be more clear.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
dbrady 109fe0e0 2014-01-28T15:28:20 fixed hat code validation.
Gabriel Jacobo 33479316 2014-01-27T17:59:19 [Android] Fixes Bug 2370, don't send accelerometer changes when Android_JNI_GetAccelerometerValues return SDL_FALSE (thanks to Jairo Luiz)
Gabriel Jacobo 50befa62 2014-01-23T08:44:25 Bug 2358 - [Android] Joystick Button Mappings are strange (fix by David Brady)
Gabriel Jacobo b131e74b 2014-01-21T18:20:12 Fixes 2356, [Android] SDL_JoystickGetAttached does not function Also fix a potential NULL pointer access in android/SDL_SYS_JoystickGetGUID
Philipp Wiesemann b97e077e 2013-12-24T20:00:58 Fixed unused local variable warning in joystick source for Android.
Philipp Wiesemann 28309c1d 2013-12-24T19:59:35 Fixed implicit declaration of SDL_Log() warning in joystick source for Android.
Gabriel Jacobo 2159de66 2013-12-12T14:55:33 [Android] Poll joysticks every three seconds
Gabriel Jacobo bfcd28c1 2013-12-10T16:24:11 [Android] Hotplugging support for joysticks
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.
Philipp Wiesemann 2aa4974b 2013-11-23T18:29:36 Removed include of no more needed header.
Gabriel Jacobo 7a18a674 2013-11-23T09:47:25 [Android] Fixes #2264, handle joystick open/closed state properly
Gabriel Jacobo fdfea4ad 2013-11-19T10:00:05 [Android] Try to improve handling of DPAD|GAMEPAD + KEYBOARD devices It seems some devices report themselves as DPAD or GAMEPAD and KEYBOARD as well, and we need to route different keycodes to different parts of SDL.
Philipp Wiesemann b5c68111 2013-11-18T23:38:59 Fixed implicit function declaration warning in joystick source for Android.
Gabriel Jacobo 45a88b6a 2013-11-11T10:15:35 [Android] Fixes bug 2217, better joystick axes handling on Android.
Gabriel Jacobo d21640e9 2013-11-10T20:13:27 Fixes bugs #2213 and #2214, improves the Android joystick code button handling
Philipp Wiesemann 0ab7624c 2013-11-10T14:47:05 Changed function to return -1 through SDL_Error() instead of plain -1.
Philipp Wiesemann 82b3e7d2 2013-11-10T14:44:50 Changed function to be static. The function keycode_to_SDL() is only used in this file.
Philipp Wiesemann 6e3558cf 2013-11-10T14:42:41 Removed unused local variable to fix warning.
Gabriel Jacobo 0b7c69fe 2013-11-05T20:07:39 Adds Joystick support for Android This bumps the build SDK level to 12 (up from 10). Runtime requirements remain the same (at API level < 12 joystick support is disabled). Also enables building SDL for armv7 and x86.
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.