Commit graph

171 commits

Author SHA1 Message Date
Sylvain a2f3711c80 SDL_AndroidGetExternalStorageState(): return 0 on success, and fills *state with flags 2023-02-10 09:30:31 +01:00
Sylvain cee245b6a9 SDL_*SceenSaver(): change return value to int. // add SDL_Unsupported() errors 2023-02-09 08:16:46 -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 22c69bccdf Displays are now referenced by instance ID instead of index 2023-01-29 19:25:15 -08:00
Sylvain 73dc327c84 Android get the display Density 2023-01-25 09:28:21 -08:00
Sylvain 78cc95e34e Rename internal GetDisplayDPI to GetDisplayPhysicalDPI 2023-01-25 00:04:00 -08:00
Sam Lantinga 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Anonymous Maarten 4676d1d31e android: register all methods using JNI_OnLoad 2022-12-21 23:00:58 -08:00
Anonymous Maarten 3b8548cdcf android: fix java fingerprint fo nativeAddJoystick 2022-12-21 09:39:22 -08:00
Maido 94a0e5ea8d
Android active driver check (#6850)
Check if a driver is active before attempting to handle the devices.
Otherwise an assertion will fail.
2022-12-19 16:02:10 +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
Sylvain Becker 186687bda9
Android: make Detect devices common between aaudio and android driver. (#6828)
remove VLA, dynamic alloc, check max length get using GetIntArrayRegion
2022-12-18 12:07:38 +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
Ryan C. Gordon 72c1f73bc5
rwops: Make read and write work like POSIX, not stdio.
This simplifies some things, clarifies some things, and also allows
for the possibility of RWops that offer non-blocking i/o (although
none of the current built-in ones do, intentionally, we could add this
later if we choose, or people could provide things like network socket
RWops implementations now, etc.

Fixes #6729.
2022-12-14 15:47:13 -05: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 0a3262e819 Pass the OS event timestamp for keyboard, mouse, and touch events where possible
Currently implemented for Windows and Apple platforms
2022-12-02 12:37:41 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sylvain Becker 6a2200823c
Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08: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 0ad65277ce Refactored code to send scancodes for an ASCII on-screen keyboard key 2022-06-29 17:26:09 -07:00
Sam Lantinga fd2a2eea10 Fixed declaration-after-statement warning 2022-05-28 07:49:18 -07:00
Guus Waals 7495b98141 Make SDL_VIDEO_OPENGL_EGL optional on Android 2022-03-14 13:38:12 +01:00
Sylvain fe2ed6cf6f
Fixed bug #5221 - Add SDL_AndroidSendMessage() 2022-02-01 11:30:43 +01:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain a1e992b110
Fixed bug #5118 - [Android] PointerIcon leak in Cursor API 2021-12-21 22:07:17 +01:00
Sam Lantinga be5b4d980d Added nativeGetHintBoolean for Java code 2021-11-15 16:52:54 -08:00
Sam Lantinga c2dd50a9a0 Fixed whitespace 2021-11-12 08:28:02 -08:00
Sylvain 8b1a2fe860
backout SDL_AndroidSetInputType() 2021-10-17 23:47:59 +02:00
Sylvain ccb12457f9
Fixed bug #4843 - Can not get the ime candidatelist like chinese/japaness input method 2021-10-17 23:17:54 +02:00
Sylvain 98a966d1c2
Android: don't need to set the SurfaceHolder format from java code
It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface.
 - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken:
   calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen.
 - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
2021-04-22 18:06:17 +02:00
Amir 1a924bc0bb add SDL_AndroidShowToast for https://developer.android.com/reference/android/widget/Toast 2021-02-20 23:05:09 -08:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 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.
2020-12-09 07:16:22 -08:00
Ryan C. Gordon 2d82cf78e1 url: put the Android bits in core/android 2020-10-05 13:59:03 -04:00
Ryan C. Gordon efd665e2c7 Backed out changeset a43cb4e54949
Trying this a different way.
2020-10-05 13:56:45 -04:00
Ryan C. Gordon 5f68812249 url: patched to compile on Android. 2020-10-05 13:52:52 -04:00
Ryan C. Gordon 77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
Sylvain Becker dd55bfe89c Android: add helper function to open an URL/URI (see bug 2783) 2020-10-01 14:41:09 +02:00
Sylvain Becker 97fad04551 Fixed bug 5278 - export SDL_AndroidRequestPermission() (Thanks Huki!) 2020-09-02 19:38:03 +02:00
Sylvain Becker 965b466ee8 Fixed bug 4297 - Android StrictMode policy. Remove APK expansion support
"In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play"
(see https://developer.android.com/guide/app-bundle)
And "Android App Bundles don't support APK expansion (*.obb) files".
2020-08-17 19:50:20 +02:00
Sylvain Becker 2491f16f85 Android: send SDL_LOCALECHANGED when locale changes 2020-05-08 21:40:28 +02:00
Sylvain Becker 0059ace0b4 Android: factorize asset manager code (bug 2131 and 4297) 2020-05-08 11:00:51 +02:00
Ryan C. Gordon fa23e3d00b locale: Implemented SDL_GetPreferredLocales().
This was something I proposed a long time ago, Sylvain Becker did
additional work on it, then back to me.

Fixes Bugzilla #2131.
2020-05-04 02:27:29 -04:00
Sam Lantinga b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00