Commit Graph

309 Commits

Author SHA1 Message Date
Sam Lantinga
7c2669c9d9 Accept key events from any source
This allows TV remotes to navigate SDL applications (with source HDMI)

Fixes https://github.com/libsdl-org/SDL/issues/8137
2023-08-24 10:09:02 -07:00
Sam Lantinga
1e9d314482 Updated to Android minSdkVersion 19 and targetSdkVersion 34
This is updated to meet the latest requirements for apps on the Google Play store
2023-08-24 08:23:06 -07:00
Ryan C. Gordon
1c074e8d97
android: Fixed audio device detection. 2023-07-30 11:56:42 -04:00
Ryan C. Gordon
5ff87c6d4a
android: Reworked audio backends for SDL3 audio API.
This involved moving an `#ifdef` out of SDL_audio.c for thread priority,
so the default ThreadInit now does the usual stuff for non-Android platforms,
the Android platforms provide an implementatin of ThreadInit with their
side of the `#ifdef` and other platforms that implement ThreadInit
incorporated the appropriate code...which is why WASAPI is touched in here.

The Android bits compile, but have not been tested, and there was some
reworkings in the Java bits, so this might need some further fixes still.
2023-07-30 11:56:41 -04:00
Sam Lantinga
8cf5dc9963 Build on Android targeting the arm64-v8a architecture by default
This speeds up iteration time and covers most customer devices
2023-06-20 09:18:19 -07:00
Sam Lantinga
e6d1ba2a17 Added the concept of display natural orientation
Also renamed SDL_GetDisplayOrientation() SDL_GetDisplayCurrentOrientation()

The natural orientation of the primary display is the frame of reference for accelerometer and gyro sensor readings.
2023-06-17 07:42:16 -07:00
Sylvain
4e0f94ea7d Android: add timeout when waiting the SDL thread to finish
C SDLmain() thread might have started (mSDLThread.start() called)
while the SDL_Init() might not have been called yet,
and so the previous QUIT event will be discarded by SDL_Init() and app is running, not exiting.

This is reprocible by adding instrumentation code in the SDLActivity.

And hopefully, this could fix an ANR, where SDLActivity is in WAITING state (in thread.join()):
  at java.lang.Thread.join (Thread.java:1519)
  at org.libsdl.app.SDLActivity.onDestroy (SDLActivity.java)

while SDLThread seems to be running
2023-06-12 11:53:09 +02:00
Sylvain
8096f7269b Android: add robustness. check that the native code is run for the first time. 2023-06-09 10:13:58 +02:00
Sam Lantinga
bb12c6e03e Added Android hidapi 0.14.0 support 2023-05-26 08:19:04 -07:00
Sam Lantinga
b48b1ce500 Document the Android SDK versions checked in Java code 2023-05-23 08:44:49 -07:00
Sam Lantinga
c971795954 Fixed reporting backspace key if there is no text in the edit buffer (thanks @312937!)
This workaround isn't necessary at API 30 and above.

Fixes https://github.com/libsdl-org/SDL/issues/7039
2023-05-22 11:54:46 -07:00
Sam Lantinga
3f6b2d1a61 Use numeric codes for Android versions, to avoid SDK dependencies 2023-05-22 11:51:32 -07:00
Sylvain
dfd80f3d76 Android: control activity re-creation 2023-05-12 07:48:33 -07:00
Sam Lantinga
2e6c48dcb4 Added support for the GameSir-G7 Controller for Xbox 2023-05-11 17:44:56 -07:00
Sam Lantinga
a4b4dff4a2 Added support for the Astro C40 in Xbox 360 mode 2023-04-27 17:10:44 -07:00
Sam Lantinga
b701ac0266 Fixed building with Java 1.7 2023-04-26 14:14:59 -07:00
Sylvain
f38cb0d06f Android: don't add telephony device, as it cannot be opened 2023-04-14 11:31:27 +02:00
Rudolf Polzer
de3909a190 Android: indicate gamepaddb entries where axis order changed.
Axis order was changed in 6f1f586086 to improve
default mappings.
2023-03-11 12:43:48 -08:00
Sam Lantinga
8994878767 Added SDL_GetSystemTheme() to return whether the system is using a dark or light color theme, and SDL_EVENT_SYSTEM_THEME_CHANGED is sent when this changes
Fixes https://github.com/libsdl-org/SDL/issues/5334
Fixes https://github.com/libsdl-org/SDL/issues/6958
Closes https://github.com/libsdl-org/SDL/pull/6440
2023-03-09 03:25:20 -08:00
divVerent
6f1f586086
Fix Xbox One gamepad axis assignment on SDL_JOYSTICK_ANDROID API (#7405) 2023-03-06 15:33:18 -08:00
Sam Lantinga
824b9b0a58 Removed SDL_GetDisplayDPI()
This function wasn't consistently correct across platforms and devices.

If you want the UI scale factor, you can use display_scale in the structure returned by SDL_GetDesktopDisplayMode(). If you need an approximate DPI, you can multiply this value times 160 on iPhone and Android, and 96 on other platforms.
2023-02-08 17:35:54 -08:00
Sam Lantinga
5fded632d6 Added support for the Turtle Beach REACT-R and Recon Xbox controllers 2023-02-06 20:14:12 -08:00
Sylvain
b23d20cd4d Android: display_mode scale: cast to do a float division 2023-01-27 08:17:20 -08:00
Sam Lantinga
162e40c982 Use densityDpi instead of density to more closely match what the UI scale is 2023-01-25 13:06:42 -08:00
Sylvain
73dc327c84 Android get the display Density 2023-01-25 09:28:21 -08:00
Wohlstand
9c7aed74ba SDLAudioManager.java: Fixed the support for Android older than API 23
(cherry picked from commit b425036808)
2023-01-10 20:15:59 -08:00
Sam Lantinga
0357390fc2 Added support for the ThrustMaster eSwap PRO Controller Xbox 2023-01-03 15:23:38 -08:00
Sylvain
4408e9f957
Android: orientation, check for exact match to "Portrait". (see #6959)
(Portrait is also contained in PortraitUpsideDown)
2023-01-01 18:47:13 +01:00
Sylvain
c4982955b2
Android: inverse LandscapeLeft and LandscapeRight (see #6959)
LandscapeLeft has now been set to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE and LandscapeRight to ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE in order to reflect the docs: https://wiki.libsdl.org/SDL2/SDL_HINT_ORIENTATIONS
2023-01-01 18:41:55 +01:00
Sylvain Becker
5bf8bc2241
Android JAVA DetectDevices: 'is_capture' is inverted (#6845)
* Android JAVA DetectDevices: 'is_capture' is inversed
* Android Audio: adding audio device. also inverted capture, from jni side
2022-12-18 16:55:59 +01:00
Maido
abf5cc5203
Android audio device selection (#6824)
Make it possible to select a specific audio device for Android
2022-12-16 16:40:02 +01:00
Sam Lantinga
fcafe40948 Removed balls from the joystick API
They were only used by one joystick decades ago, so removing them for SDL3

Fixes https://github.com/libsdl-org/SDL/issues/6766
2022-12-05 13:17:18 -08:00
Sam Lantinga
5efca283d3 Add 8BitDo to the list of Xbox 360 third party vendors
Allows detection of the 8BitDo Ultimate Wired Controller
2022-11-28 14:54:36 -08:00
Sam James
3e7952ce8a Avoid use of deprecated egrep/fgrep
GNU grep 3.8 emits a deprecation warning on use of egrep/fgrep.

Signed-off-by: Sam James <sam@gentoo.org>
2022-11-24 02:58:20 -08:00
Sam Lantinga
2c4159b99a First pass at changing SDL 2.0 to SDL 3.0 2022-11-21 20:28:58 -08:00
Sam Lantinga
0bfeed061b Updated to version 2.26.0 for release 2022-11-21 16:15:58 -08:00
Sam Lantinga
78ea6af2cd Updated to version 2.25.1 for release candidate 2022-11-17 09:01:35 -08:00
Sam Lantinga
b4aba10154 Reverted game controller buttons from interacting with message box dialogs
These would only work for non-HIDAPI controllers, and other controller input would leak past the dialog, both of which would be confusing.
2022-10-06 12:10:46 -07:00
Sam Lantinga
893c87b27b Fixed game controller buttons being unresponsive when the on-screen keyboard is up
Also mapped controller A and B buttons to interact with messagebox dialogs
2022-10-06 12:10:45 -07:00
Sylvain
fdef96e233
Android: remove "nativeSetComposingText" since it's not used anymore
(and it may fail registering at init if code is cleaned with proguard)
2022-10-04 12:08:09 +02:00
Sam Lantinga
5291e5cb76 Added version checking to SDLActivity.java
Make sure the SDL java and C code match when updating SDL in a game.
Right now we're assuming that we only have to make sure release versions match. We can extend the version string with an interface version if we need more fine grained sanity checking.

Fixes https://github.com/libsdl-org/SDL/issues/1540
2022-10-03 17:36:17 -07:00
Sam Lantinga
6acc7a5622 Mark the editbox as multi-line so the return key is always visible
Fixes https://github.com/libsdl-org/SDL/issues/6170
2022-09-30 17:45:08 -07:00
Sam Lantinga
257cacab18 Android text input now works like iOS, where you get text in progress and then backspaces and new text if autocomplete changes it or the IME commits it. 2022-09-30 17:25:58 -07:00
Sam Lantinga
82e341bc9e Android: use real editable text and mimic the edit operations to generate key events
This fixes issues where the IME and the output would get out of sync
2022-09-30 11:40:29 -07:00
yurii levchenko
3ce3594e38 Split SDLSurface to public class
Add SDLActivity method createSDLSurface
2022-08-22 14:57:15 -07:00
Sam Lantinga
be3a945a8b Added support for the 8BitDo Ultimate Wired Controller for Xbox 2022-07-20 11:05:55 -07:00
Sam Lantinga
986818143d Fixed missing imports in SDLActivity (thanks @guusw!) 2022-07-18 07:20:58 -07:00
Sam Lantinga
27d8cbf026 Added PowerA and Qanba vendors for Android USB device support 2022-07-12 18:18:00 -07:00
Sam Lantinga
209f457ea4 Generate backspaces for the text we're going to replace when committing text 2022-07-01 10:13:19 -07:00
Sam Lantinga
7ac5d616f3 Fixed backspace being delivered after committed text on Android 12
Testing:
Enter "hello ", followed by "?" - the events generated are:
: commitText hello
: Key pressed :  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key released:  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key pressed :  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key released:  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key released:  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key pressed :  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: Key released:  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: INPUT Text (\x68\x65\x6c\x6c\x6f\x20): "hello "
: finishComposingText
: deleteSurroundingText 1 / 0
: Key pressed :  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: Key released:  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: commitText ?
: Key pressed :  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: LSHIFT
: Key pressed :  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: (none)
: INPUT Text (\x3f): "?"
: setComposingText , at 1
: EDIT Text (): ""

Previously, the backspace would be delivered after the "?"
2022-07-01 08:58:08 -07:00