Commit Graph

297 Commits

Author SHA1 Message Date
Sam Lantinga
f176d7fda0 Added a note not to use XinputUap.dll for XInput support 2020-05-22 16:45:02 -07:00
Sam Lantinga
eadc8693dd Fixed bug 5103 - Port fcitx support to both fcitx 4 & 5
wengxt

Due to the new major fcitx version is coming close, the existing code need to be ported to use new Fcitx dbus interface.

The new dbus interface is supported by both fcitx 4 and 5, and has a good side effect, which is that it will work with flatpak for free. Also the patch remove the dependency on fcitx header. Instead, it just hardcodes a few enum value in the code so need to handle the different header for fcitx4 or 5.
2020-05-11 14:31:04 -07: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
ba95fa6152 Revert "Fix incorrectly terminated MakeThreadHighPriority dbus message"
The first terminator is for input parameters. The second terminator was for the
output parameters.

If an error occurs when calling MakeThreadHighPriority(), e.g. a bad thread id,
then the reply from connection_send_with_reply_and_block() will be null.
2020-04-08 08:42:09 -07: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
Sam Lantinga
f4a56d7e61 Enable thread-safety features in libdbus
There are multiple SDL APIs that internally sink into dbus calls, e.g. battery
status, thread priority. If those calls happen in different threads simultaneously
it can result in dbus crashes.

To abide by dbus's multithreading guidelines we must call dbus_threads_init_default()
to enable dbus's internal locking mechanisms:
https://dbus.freedesktop.org/doc/api/html/group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc

Additionally, access to a DBusMessage must be synchronized between threads.
SDL was already abiding that guideline as the DBusMessage structs aren't shared.

The following email from the dbus mailing list hints that arbitrating access to
the DBusConnection on the SDL may also be required:
https://lists.freedesktop.org/archives/dbus/2017-September/017306.html
2020-03-30 14:26:15 -07:00
Sam Lantinga
2e667a8be9 Fix incorrectly terminated MakeThreadHighPriority dbus message
Currently the message is double terminated, which results in SDL_DBus_CallMethodInternal()
incorrectly assuming that the other party is always returning true.

I'm not super familiar with dbus, so I'm not sure if this could also be the cause of this bug:
https://github.com/ValveSoftware/steam-for-linux/issues/6901
2020-03-30 14:26:10 -07:00
Ryan C. Gordon
369e5f33fb dbus: System bus is optional, we only need a session bus (thanks, tamo!).
Fixes Bugzilla #4795.
2020-03-26 20:28:04 -04:00
Sam Lantinga
b431286471 Resolved conflict and added Android_JNI_RequestPermission() 2020-02-13 10:19:05 -08:00
Sam Lantinga
4bb95e8403 Implemented OpenSL-ES audio recording on Android 2020-02-11 16:14:02 -08:00
Fabrice Fontaine
cbc65ce80d src/core/linux/SDL_threadprio.c: fix build without threads
Add an include on SDL_error.h to avoid the following build failure
without threads:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabihf/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabihf/bin/ld: build/.libs/SDL_threadprio.o: in function `SDL_LinuxSetThreadPriority_REAL':
SDL_threadprio.c:(.text+0x0): undefined reference to `SDL_Unsupported'

Fixes:
 - http://autobuild.buildroot.org/results/7f7712c5bd47de4a3fcec1e0d0526fd5a3ecd532

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-02-10 13:56:53 -08:00
Sylvain Becker
005e2dff21 Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).

Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.

It prevents crashes like:

  #00  pc 000000000000c0d0  /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
  #01  pc 000000000000c7f4  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
  #02  pc 000000000000c390  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
  #03  pc 000000000000bb10  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
  #04  pc 000000000032732c  /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
  #05  pc 0000000000326dd0  /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
  #06  pc 00000000002ae484  /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
  #07  pc 0000000000249680  /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
  #08  pc 00000000002cb52c  /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sylvain Becker
d004cc7050 Android: same way as in nativePause(), resume events are sent from SDL thread 2019-12-21 22:40:33 +01:00
Sylvain Becker
45a9b5fa2e Android: fix call of glFinish without context.
Message in the log, when going to background:
"call to OpenGL ES API with no current context (logged once per thread)"

Because of SDL_WINDOWEVENT_MINIMIZED is sent from the Java Activity thread.
It calls SDL_RendererEventWatch(), _WindowEvent() and glFinish() without context.

Solution is to move sending of SDL_WINDOWEVENT_MINIMIZED to the SDL thread.
2019-12-21 21:18:02 +01:00
Sylvain Becker
13e1015169 Android: use SDL_arraysize() 2019-12-12 20:33:11 +01:00
Sylvain Becker
210f6dda95 Android: use 'RegisterNatives' to export the native methods
"The advantages of RegisterNatives are that you get up-front checking
that the symbols exist, plus you can have smaller and faster shared
libraries by not exporting anything but JNI_OnLoad"

https://developer.android.com/training/articles/perf-jni#native-libraries
2019-12-12 18:38:36 +01:00
Sam Lantinga
2bfcf5cd96 Added Linux controller mapping for the Xbox One Elite Series 2 controller in Bluetooth mode 2019-11-18 14:08:05 -08:00
Sylvain Becker
303646a697 Android: some readability: redundant casts, deads stores, redundant control flow 2019-10-31 15:53:10 +01:00
Ryan C. Gordon
a747106c97 linux: If D-Bus isn't available on the system, don't keep trying to load it.
Fixes Bugzilla #4476.
2019-10-09 19:38:16 -04:00
Sam Lantinga
191fe25b1a Fixed rtkit feature guard 2019-09-27 15:21:31 -07:00
Sam Lantinga
84dc44e24d Fix the RealtimeKit dbus include guards
The SDL_USE_LIBDBUS define is set inside SDL_debug.h, therefore the
circular dependency made it impossible for this feature to be enabled.

Instead, guard SDL_dbus.h based on the autoconf variable HAVE_DBUS_DBUS_H

Additionally, fix one of the rtkit comments. CAP_SYS_NICE isn't required
to achieve high priority. But there is some scheduler config that rtkit
needs the app to setup.
2019-09-27 15:21:27 -07:00
Sam Lantinga
aaec90e5c5 Fixed bug 4789 - Linux accelerometers no longer available as joysticks
Daniel Drake

A long time ago, it was possible to play neverball on Linux using the accelerometer found in HP laptops.

The kernel exposes the accelerometer as a joystick (/dev/input/jsX) as well as an evdev device (/dev/input/eventX). I guess it worked fine when SDL was using the js interface, but then stopped working here: http://hg.libsdl.org/SDL/rev/fdaeea9e7567

Looking at current code which uses udev to discover joysticks, it looks for the udev tag ID_INPUT_JOYSTICK.

However udev's internal input_id logic specifically tags accelerometers as ID_INPUT_ACCELEROMETER and nothing else.

This looks like a good fit for SDL_HINT_ACCELEROMETER_AS_JOYSTICK.
2019-09-06 08:42:54 -07:00
Ozkan Sezer
9c8e403f6b use 'U' suffix on constants instead of (unsigned int) cast. 2019-08-30 11:35:20 +03:00
Sylvain Becker
70dc8d1648 Android: fix corresponding warnings 2019-08-30 08:55:20 +02:00
Alex Szpakowski
109cbd6e8b Fix touch-related compile errors on Linux. 2019-08-04 16:56:40 -03:00
Sam Lantinga
63197c4338 Fix bug where the wrong button was the default in the old message box because buttons were added backwards, breaking the indexing used by GetButtonIndex.
Add messagebox flags to explicilty request left-to-right button order or right-to-left.  If neither is specified it'll be some platform default.
2019-08-02 17:19:50 -07:00
Alex Szpakowski
d5ec735a33 Add a windowID field to SDL_TouchFingerEvent (bug #4331).
This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
2019-08-01 18:22:12 -03:00
Sylvain Becker
18bcafffce Fixed bug 4739 - Android: loading native libs, generated by bundletool (Thanks akk0rd87) 2019-07-27 20:21:42 +02:00
Sam Lantinga
67bb882e13 Fixed bug 4707 - SDL_SetRelativeMouseMode fails on Vivante
Cameron Gutman

The bugfix in https://hg.libsdl.org/SDL/rev/ca9417a52f18 caused SDL_SetRelativeMouseMode() to begin failing on Vivante (Steam Link). Even though Vivante doesn't have a SetRelativeMouseMode() or WarpMouse() function, it's in relative mode already (because it uses evdev) so the function was actually working as intended.

I think providing a no-op SetRelativeMouseMode() function for Vivante is a reasonable fix. Since it's already getting relative events through evdev, it really is a no-op to "enter relative mode".

In fact, this is probably the right thing to do for all backends that use evdev (vivante, raspberry, and kmsdrm). Raspberry and kmsdrm both have WarpMouse() implementations so SDL_SetRelativeMouseMode() isn't failing there, but it still seems to make sense not to have to do the fake warping if they're evdev-based anyway.
2019-07-03 15:57:55 -07:00
Ryan C. Gordon
d5ebbcb4e5 dbus: Don't SimulateUserActivity if we're already inhibiting the screensaver. 2019-07-02 09:43:26 -04:00
Ryan C. Gordon
94658099e5 dbus: Add org.freedesktop.ScreenSaver.SimulateUserActivity support. 2019-07-02 09:38:31 -04:00
Sylvain Becker
22a2decf64 Android: concurrency issues, make sure Activity is in running State when calling
functions like SDL_CreateWindow, SDL_CreateRenderer, Android_GLES_CreateContext

Bugs 4694, 4681, 4142
2019-06-28 16:38:42 +02:00
Sylvain Becker
ccba8d4691 Android: export Lock/Unlock activity API 2019-06-24 18:08:11 +02:00
Sylvain Becker
a55c0e1479 Android: revert previous commit (Bug 4669)
(Refs #1)
2019-06-18 10:23:19 +02:00
Sylvain Becker
f2157b6c25 Fixed bug 4669: Android software renderer, black screen when window resizes
Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes
2019-06-17 22:31:36 +02:00
Sam Lantinga
6c4765a17a Removed extraneous fprintf() call 2019-06-17 11:10:20 -07:00
Sam Lantinga
93a5e4ce06 Fixed bug 4667 - Build errors on Linux when building without Threads support
Manuel Sabogal

There is an issue on the latest commit of the mercurial repo when SDL_THREADS_DISABLED is set:

src/core/linux/SDL_threadprio.c:79:28: error: unknown type name 'Sint64'; did you mean 'int'
2019-06-17 08:38:33 -07:00
Sam Lantinga
d01150abc2 Fixed bug 4665 - Add support for single touch evdev devices
Jan Martin Mikkelsen

The attached patch adds support for single-touch evdev devices.

These devices report ABS_X, ABS_Y and BTN_TOUCH events. This patch sets them up as MT devices with a single slot and handles the appropriate messages.
2019-06-12 07:55:48 -07:00
Sylvain Becker
f9a9193e2c Android: add MinimizeWindow function (Bug 4580, 4657)
shouldMinimizeOnFocusLoss is un-activated (return false)
2019-06-10 21:58:03 +02:00
Sam Lantinga
b1100ec18c Fixed Android build warning 2019-06-08 10:23:52 -07:00
Sam Lantinga
23569362dc Use SDL sized types 2019-06-05 12:01:26 -07:00
Sam Lantinga
3e3294645f Fixed bug 4656 - SDL_evdev.c uses Linux specific integer types
Jan Martin Mikkelsen

The file src/core/linux/SDL_evdev.c uses the Linux specific types __u32 and __s32. This breaks things on FreeBSD when building with evdev.
2019-06-05 08:54:07 -07:00
Sam Lantinga
dce56ab9fa Added a function to get the current Android SDK version at runtime 2019-05-23 14:19:00 -07:00
Sam Lantinga
8b57331e71 Fixed hiding the Android virtual keyboard when the return key is pressed 2019-05-23 11:05:43 -07:00
Sam Lantinga
9950271bb6 Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC

Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.

- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.

- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.

So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.


I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634

So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
Sam Lantinga
a46af76b07 Fixed bug 4579 - SDL_android.c s_active not being atomic
Isaias Brunet

This bug cause a false assert due to multiple threads modifying the same variable without any atomic operation.
2019-04-05 08:15:01 -07:00
Sylvain Becker
bfdd0b228a Android: remove SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH
java layer runs as if separate mouse and touch was 1,
Use SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS
for generating synthetic touch/mouse events
2019-04-04 17:01:02 +02:00
Sylvain Becker
ab03892ddf Bug 4576: track both FingerId and TrackId 2019-04-04 15:19:00 +02:00
Sylvain Becker
6bc2d9de1f Bug 4576: remove touch/mouse duplication for linux/EVDEV 2019-04-02 17:03:58 +02:00
Sam Lantinga
b2e76d860f Fixed Windows RT build 2019-03-19 16:52:09 -07:00
Sam Lantinga
de82759c84 Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
Sylvain Becker
063c0c2a73 Android: check SDL is initialized before sending the event
Avoid error message:
SDLActivity thread ends (error=Video subsystem has not been initialized)
2019-03-13 09:39:30 +01:00
Sam Lantinga
d05eec7207 Fixed initial display orientation at Android app start 2019-03-12 14:44:25 -07:00
Sylvain Becker
052b4f2969 SDL_EVDEV_kbd_init: uninitialized data for ioctl (Bug 4530)
Only two chars are used but the full prototype is:

int tioclinux(struct tty_struct *tty, unsigned long arg)

==5010== Syscall param ioctl(TIOCLINUX) points to uninitialised byte(s)
==5010==    at 0x53E73C7: ioctl (syscall-template.S:78)
==5010==    by 0x4A887DA: SDL_EVDEV_Init (SDL_evdev.c:163)
==5010==    by 0x4A7D157: KMSDRM_VideoInit (SDL_kmsdrmvideo.c:509)
==5010==    by 0x497D959: SDL_VideoInit_REAL (SDL_video.c:529)
==5010==    by 0x487ACBC: SDL_InitSubSystem_REAL (SDL.c:171)
==5010==    by 0x487B052: SDL_Init_REAL (SDL.c:256)
==5010==    by 0x488F7D6: SDL_Init (SDL_dynapi_procs.h:85)
2019-03-12 14:20:37 +01:00
Sylvain Becker
8ad4000ce2 Android: some typos 2019-01-20 22:17:41 +01:00
Sylvain Becker
b9aa3768ac Android: automatically attach to the JVM non-SDL threads
It allows a thread created with pthread_create() to access the JNI Env
2019-01-20 22:11:56 +01:00
Sylvain Becker
e5f8801f55 Android: prevent concurrency in Android_SetScreenResolution() when exiting
by checking Android_Window validity

- SDLThread: user application is exiting:
    SDL_VideoQuit() and clearing SDL_GetVideoDevice()

- ActivityThread is changing orientation/size
    surfaceChanged() > Android_SetScreenResolution() > SDL_GetVideoDevice()

- Separate function into Android_SetScreenResolution() and Android_SendResize(),
    formating, and mark Android_DeviceWidth/Heigh as static
2019-01-17 11:05:05 +01:00
Sylvain Becker
8a19ff3e2d Android: add mutex protection to onNativeOrientationChanged
it's possible receive try to send an event between the check first for SDL_GetVideoDevice
and SDL_VideoQuit is called
2019-01-16 10:48:28 +01:00
Sylvain Becker
e994be5833 Android: move static variable isPaused/isPausing to SDL_VideoData structure
- remove unneed check to Android_Window->driverdata
- add window check into context_backup/restore
2019-01-16 10:31:51 +01:00
Ryan C. Gordon
861a21f98b evdev: don't debug log on a BTN_TOUCH from a non-touch device. 2019-01-14 19:43:25 -05:00
Ryan C. Gordon
2755a505a3 evdev: Add touchscreen mouse emulation and pressure support (thanks, Zach!).
This also solves reports of this log message:

"INFO: The key you just pressed is not recognized by SDL. To help get this
fixed, please report this to the SDL forums/mailing list
<https://discourse.libsdl.org/> EVDEV KeyCode 330"

(EVDEV KeyCode 330 is BTN_TOUCH.)

Fixes Bugzilla #4147.
2019-01-14 19:36:54 -05:00
Sylvain Becker
dc263450ff Android: create Pause/ResumeSem semaphore at higher level than CreateWindow()
- If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background.

- If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids.

SDLActivity.java: the first resume() starts the SDLThread, don't call
nativeResume() as it would post ResumeSem. And the first pause would
automatically be resumed.
2019-01-14 23:33:48 +01:00
Sylvain Becker
7b42f03fd9 Android: move and group JNIEnv helper functions 2019-01-11 21:52:43 +01:00
Sylvain Becker
7f3478305f Android: change the way JNIEnv is retrieved
- Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations.
  Now, it simply gives back the JNI Env stored for the thread.

- Android_JNI_SetupThreadi() should only be used for external.
  For internal SDL thread, it's already called in RunThread() (SDL_systhread.c),
  and other thread are Java threads which don't need to be attached. i
  (even if it doesn't hurt to do it, since it's a no-op).

- JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread...
  It's called for all shared libraries which may don't want this setup,
  and loading libraries can be also modified to be done from a static context,
  or with relinker. So it's not really clear how, who and what it sets up.
  => Reduce this function to the minimal
2019-01-11 21:42:52 +01:00
Sylvain Becker
dc10d96cde Android: use the same naming for JNI env local variables 2019-01-11 15:36:16 +01:00
Sylvain Becker
3cfd907df7 Android: Audio thread is already setup for the JVM
In 'src/thread/pthread/SDL_systhread.c' RunThread() calls first 'Android_JNI_SetupThread()'
2019-01-11 15:33:02 +01:00
Sylvain Becker
9d82f4e985 Android: use pthread_once for creating thread key 'mThreadKey' 2019-01-11 15:27:53 +01:00
Sylvain Becker
9a98e5afe1 Android: don't call Android_JNI_ThreadDestroyed() for Java SDLThread
SDLThread is a Java Thread, it's not needed to call 'Detach' from the JVM.
Clear mThreadKey, so that the pthread_create destructor is not called for this
thread.
2019-01-11 14:50:43 +01:00
Sylvain Becker
b44a7aea8f Android: fix prototype of Android_JNI_InitTouch 2019-01-10 21:49:00 +01:00
Sylvain Becker
7a1d1baefc Android: add name for Touch devices and simplification, from bug 3958 2019-01-10 21:40:57 +01:00
Sylvain Becker
d23c2f07e3 Fixed bug 3930 - Android, set thread priorities and names
SDLActivity thread priority is unchanged, by default -10 (THREAD_PRIORITY_VIDEO).

SDLAudio thread priority was -4 (SDL_SetThreadPriority was ignored) and is now -16 (THREAD_PRIORITY_AUDIO).

SDLThread thread priority was 0 (THREAD_PRIORITY_DEFAULT) and is -4 (THREAD_PRIORITY_DISPLAY).
2019-01-10 18:05:56 +01:00
Sylvain Becker
66fbfe1d00 Android: nativeQuit for SDLActivity thread
- destroy Android_ActivityMutex
- display any SDL error message that may have occured in this thread,
  since SDL_GetError() is thread specific, and user has no access to it.
2019-01-10 15:43:07 +01:00
Sylvain Becker
dad8161103 Android: only send Quit event to SDLThread if it's not already terminated
And it avoids reporting errors using Android_Pause/ResumeSem that are NULL.
2019-01-10 15:35:46 +01:00
Sylvain Becker
8dd915507e Android: prevent a dummy error message sending SDL_DISPLAYEVENT_ORIENTATION
In the usual case, first call to onNativeOrientationChanged() is done before
SDL has been initialised and would just set an error message
"Video subsystem has not been initialized" without sending the event.
2019-01-09 23:19:26 +01:00
Sylvain Becker
68c0e69f0a Android: native_window validity is guaranteed between surfaceCreated and Destroyed
It's currently still available after surfaceDestroyed().
And available (but invalid) between surfaceCreated() and surfaceChanged().

Which means ANativewindow_getWidth/Height/Format() fail in those cases.

https://developer.android.com/reference/android/view/SurfaceHolder.html#getSurface()
2019-01-09 22:41:52 +01:00
Sylvain Becker
cfe2924d07 Android: some robustness when quitting application from onDestroy()
Make sure there is not pending Pause accumulated, so the the application doesn't
remain paused and stucked in onDestroy().

Can be tested by adding:
 SDLActivity.nativePause();
 SDLActivity.nativePause();
 mSingleton.finish();
2019-01-07 11:35:31 +01:00
Sylvain Becker
462e62e154 Android: better fix for bug 3186. Run those commands from SDL thread. 2019-01-06 20:25:54 +01:00
Sylvain Becker
9f23d1815f Android: allow multiple calls to nativeResume()
Doesn't seem to happen manually, but symetrical to the pause handling.

Can be tested by adding:

mNextNativeState = SDLActivity.NativeState.PAUSED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.RESUMED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.PAUSED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.RESUMED;
handleNativeState();

Before, it ends in 'paused' state.
Now, it ends in 'resumed' state.
2019-01-06 17:35:42 +01:00
Sylvain Becker
35722b6423 Android: fix wrong state after immediate sequence pause() / resume() / pause()
It may happen to have the sequence pause()/resume()/pause(), before polling
any events.

Before, it ends in 'resumed' state because as the check is greedy.
Now, always increase the Pause semaphore, and stop at each pause.
It ends in 'paused' state.

Related to bug 3250: set up a reconfiguration of SurfaceView holder.
Turn the screen off manually before the app starts
(repro rate is not 100%..)
2019-01-05 22:27:25 +01:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sylvain Becker
2e19343df6 Android: use Mutex instead of Semphore for bug 4142 2019-01-03 20:18:29 +01:00
Sylvain Becker
cc8f1136b6 Fixed bug 4142 - Concurrency issues in Android backend
Use a semaphore to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
(Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
2019-01-03 14:18:06 +01:00
Sylvain Becker
5dc25fef3b Android: preparation bug 4142, reduce usage of global variable Android_Window 2019-01-03 13:14:16 +01:00
Sylvain Becker
a95f91bcea Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565
Use the egl format to reconfigure java SurfaceView holder format.
If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
2019-01-02 18:06:33 +01:00
Sylvain Becker
03b0e1dee0 Android: on rare occasion, prevent Android_JNI_GetNativeWindow() from crashing
If Java getNativeSurface() returns null, then ANativeWindow_fromSurface() would crash().
2018-12-30 22:44:25 +01:00
Sylvain Becker
1e22fc1513 Android: fixed comments and spaces 2018-12-30 15:41:28 +01:00
Sylvain Becker
2a412eb94c Fixed bug 3186 - Android SW keyboard not restored when app becomes foreground. 2018-12-30 15:39:37 +01:00
Sylvain Becker
7468d1e096 Fix warnings detected on Android build 2018-12-06 15:46:40 +01:00
Ryan C. Gordon
c7b713714a Whoops, forgot to add a new source file. :/ 2018-12-05 17:53:38 -05:00
Ryan C. Gordon
1689e9f910 linux: Move SDL_LinuxSetThreadPriority() elsewhere to fix build.
Fixes Bugzilla #4393.
2018-12-05 16:51:22 -05:00
Ryan C. Gordon
fac40f8e4c Patched to compile on Linux with threads enabled. (whoops!) 2018-12-01 11:14:20 -05:00
Ryan C. Gordon
c4bc59a50e Patched to compile on Linux with --disable-threads.
Fixes Bugzilla #4393.
2018-12-01 10:36:26 -05:00
Alex Szpakowski
5029d50ea8 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id).
Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates).

Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
2018-11-10 16:15:48 -04:00
Sam Lantinga
47fb450beb Fixed bug 4315 - little Warning in Android_JNI_CaptureAudioBuffer
Sylvain

SDL_android.c
src/core/android/SDL_android.c:1302:5: warning: variable 'br' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
    default:
    ^~~~~~~
src/core/android/SDL_android.c:1306:12: note: uninitialized use occurs here
    return br;
           ^~
src/core/android/SDL_android.c:1270:12: note: initialize the variable 'br' to silence this warning
    jint br;
           ^


Maybe we could add some basics warning flags, not to see all warnings, but so that new warnings are caught sooner.

I would go for -Wall -Wextra, and some -Wno-warning for the allowed warnings.
2018-11-02 17:18:03 -07:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Sam Lantinga
9af581bd75 Fixed bug 4347 - Keyboard LEDs don't work on linux console
Rainer Sabelka

When using SLD2 on a Linux console with the KMS/DRM video backend and Linux evdev keyboard support, the caps lock, scroll lock, and num lock leds do not work.

The attached patch adds ioctls for setting the LED state in SDL_evdev_kbd.c
2018-10-31 15:01:20 -07:00
Micha? Janiszewski
91820998fc Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00