Commit graph

11247 commits

Author SHA1 Message Date
Charlie Birks
36bc67cf2a Emscripten: Use EMSCRIPTEN_EVENT_TARGET_* 2019-05-09 12:09:45 +01:00
Charlie Birks
6715912ca3 Emscripten: Switch from canvas[XY] to target[XY]
Allows mouse/touch events to work on non-default canvases
2019-05-09 12:09:40 +01:00
Charlie Birks
e7bc640ec4 Emscripten: Store canvas id in WindowData
Also replace all hardcoded uses of "#canvas" or NULL
2019-05-09 12:09:34 +01:00
Sam Lantinga
efee635e24 Fixed bug 4608 - Android: not getting SDL_WINDOWEVENT_FOCUS_GAINED on start of our app
Dan Ginsburg

I've seen this on several devices including Moto Z running Android 7 and a Snapdragon 845 running Android 9.

What happens is as follows:

SDLActivity.onWindowFocusChanged(true) happens pretty early on, but it's before we've done SDL_CreateWindow and so Android_Window is 0x0 thus this message does not get sent:

JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)(
                                    JNIEnv *env, jclass cls, jboolean hasFocus)
{
    SDL_LockMutex(Android_ActivityMutex);

    if (Android_Window) {
        __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeFocusChanged()");
        SDL_SendWindowEvent(Android_Window, (hasFocus ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST), 0, 0);
    }

    SDL_UnlockMutex(Android_ActivityMutex);
}

When the window does get created, in Android_CreateWindow it does this:

 window->flags &= ~SDL_WINDOW_RESIZABLE;     /* window is NEVER resizeable */
    window->flags &= ~SDL_WINDOW_HIDDEN;
    window->flags |= SDL_WINDOW_SHOWN;          /* only one window on Android */
    window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */

    /* One window, it always has focus */
    SDL_SetMouseFocus(window);
    SDL_SetKeyboardFocus(window);

The SDL_SetKeyboardFocus does send an SDL_WINDOWEVENT_FOCUS_GAINED message, but it gets eaten in SDL_SendWindowEvent because we've forced SDL_WINDOW_INPUT_FOCUS beforehand:

 case SDL_WINDOWEVENT_FOCUS_GAINED:
        if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
            return 0;
        }
        window->flags |= SDL_WINDOW_INPUT_FOCUS;
        SDL_OnWindowFocusGained(window);
        break;

I can fix the problem if I comment out this line from Android_CreateWindow:

    window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */

I would propose that as a fix unless there is a reason not to.
2019-04-25 14:17:07 -07:00
Sam Lantinga
e1571a9923 Fixed bug 4566 - Hot-plugging Bluetooth controller causes force-quit on Android
Anthony @ POW Games

I tried adding different configChanges and sure enough, "navigation" worked! Now bluetooth controllers hot-plug nicely. So shall we add it as a default to the AndroidManifest.xml?

Funny that this is how this activity is described:

	"navigation" The navigation type (trackball/dpad) has changed. (This should never normally happen.)

I think the reason behind this is because the bluetooth game controller I was testing doubles-up as a keyboard, which probably comes with a DPAD? It's a MOCUTE-032X_B63-88CE
2019-04-24 12:53:15 -07:00
Sam Lantinga
ec88d33573 Don't redefine __SSE__ and related macros if they're already defined 2019-04-23 16:57:34 -07:00
Sam Lantinga
1b77525040 Change my previous fix based on feedback from dev @saml 2019-04-23 14:08:14 -07:00
Sam Lantinga
8227163786 Created Xcode schemes for building on iOS and tvOS 2019-04-23 14:08:09 -07:00
Sam Lantinga
597de77bf3 Fix compile errors I hit when building org.libsdl in source2 (part 2 of 2) @saml 2019-04-23 12:59:28 -07:00
Sam Lantinga
e117f3c8fa Fix compile errors I hit when building org.libsdl in source2 (part 1 of 2) 2019-04-23 12:59:20 -07:00
Sam Lantinga
0f77e6c119 Use _Exit() when available 2019-04-23 07:59:31 -07:00
Hugh McMaster
da3ddaf8fa Add a configure option allowing users to choose whether to install sdl2-config
sdl2-config is installed by default if no flag is specified.
2019-04-07 23:01:07 +10:00
Sylvain Becker
2ae3c2cc55 Android: add static variable initialization in non blocking event loop 2019-04-23 14:24:58 +02:00
Sam Lantinga
d3bb4f2da6 Added a helper function to tell whether or not a window can be minimized 2019-04-22 16:34:42 -07:00
Sam Lantinga
66f65d77f5 Only leave fullscreen mode if we're actually going to minimize 2019-04-22 16:25:49 -07:00
Sam Lantinga
3524165d24 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/8703488687ca/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/8703488687ca/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
Ryan C. Gordon
7057d3fa91 configure: Cleaned up audio/video summaries when building for Windows. 2019-04-21 21:34:14 -04:00
Alex Szpakowski
930c7c8632 iOS: Remove code trying to support compilation on the iOS 7 SDK, the deployment target has been set to iOS 8 for years and there's other unconditionally compiled code that depends on newer SDKs so that code is useless. 2019-04-17 20:41:05 -03:00
Alex Szpakowski
022c7f0ac5 macOS: Fix compilation when using the 10.9 SDK or older. 2019-04-17 20:14:40 -03:00
Sam Lantinga
10186659df Explicitly load hidapi as a dependency of the SDL library
This fixes loading on Android 4.2
2019-04-16 20:00:14 -07:00
Ethan Lee
4d0dd1384b hidapi: Add GCN L/R buttons, just in case someone wants them... 2019-03-17 12:36:40 -04:00
Sylvain Becker
7a8bcac27b Android: when event loop is not blocking in pause, backup EGL context (Bug 4578)
Backup the EGL context when SDL_APP_DIDENTERBACKGROUND has been removed from the
event queue.
2019-04-12 23:15:26 +02:00
Alex Szpakowski
d82ed4186e Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575). 2019-04-10 22:30:58 -03:00
Sylvain Becker
60832b7b71 Fixed bug 4581 - generate synthetic mouse events at window boundaries
when real touch events are actually outside the window.
2019-04-10 10:59:53 +02:00
Sylvain Becker
98eeaf9bc5 Fixed bug 4581 - mouse events with SDL_TOUCH_MOUSEID make window lost focus
Virtual mouse events should never leave the window or change focus for single window applications.
2019-04-08 21:27:24 +02:00
Sylvain Becker
9e9ef0bf36 Fixed bug 4582 - Maximize/Resize not working on Windows 10
When viewport is set, projectionAndView changes, but ID3D11DeviceContext_UpdateSubresource was not called.
2019-04-08 13:43:48 +02:00
Sylvain Becker
ad0b1b7b34 SDL_HINT_MOUSE_TOUCH_EVENTS: move tracking appart in case of 'window' is null 2019-04-06 21:52:51 +02:00
Sylvain Becker
7e59dbabda Bug 4581: move tracking appart so it doesn't require the window to have focus 2019-04-06 21:43:16 +02:00
Sam Lantinga
173b3a5113 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
Sam Lantinga
973c06f2a5 Set SDL_HINT_MOUSE_TOUCH_EVENTS for iPhone and iPad as well 2019-04-05 08:10:12 -07:00
Sam Lantinga
c9a297db4f https://bugzilla.libsdl.org/show_bug.cgi?id=4577
SDL_GetWindowDisplayMode was returning an incorrect result on iPhone Plus devices (tested on iOS 12.1/12.2).  The problem was that the value returned by UIScreenMode was assumed to be the physical pixels on the display, rather than the scaled retina pixels.  The fix is to use the scale returned by UIScreen.scale rather than the nativeScale.
2019-04-05 07:51:11 -07:00
Sylvain Becker
102108aea3 Android: add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE
to set whether the event loop will block itself when the app is paused.
2019-04-05 09:16:30 +02:00
Sylvain Becker
cbc5a31a9f Android: default SDL_HINT_MOUSE_TOUCH_EVENTS to 1 as previous behaviour 2019-04-05 08:36:31 +02:00
Sylvain Becker
a86fca805f Update WhatsNew.txt 2019-04-04 20:24:22 +02:00
Sylvain Becker
b8d46cbace Update WhatsNew.txt 2019-04-04 20:10:55 +02:00
Sylvain Becker
e20e39b3d9 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
1d1eceb6ab Add hint SDL_HINT_MOUSE_TOUCH_EVENTS for mouse events to generate touch events
controlling whether mouse events should generate synthetic touch events
By default SDL will *not* generate touch events for mouse events
2019-04-04 16:51:50 +02:00
Sylvain Becker
d16648f8ce Bug 4576: track both FingerId and TrackId 2019-04-04 15:19:00 +02:00
Sylvain Becker
066a2112b3 Bug 4576: fix wrong scaling 2019-04-03 10:14:42 +02:00
Sylvain Becker
46212a1fa2 Bug 4576: one more warning 2019-04-02 18:07:27 +02:00
Sylvain Becker
9fc58c044c Bug 4576: fix warning and compile 2019-04-02 17:57:27 +02:00
Sylvain Becker
489c8573c2 Bug 4576: remove touch/mouse duplication for Android 2019-04-02 17:23:55 +02:00
Sylvain Becker
fb49e85bf6 Bug 4576: remove touch/mouse duplication for IOS 2019-04-02 17:18:47 +02:00
Sylvain Becker
d29be58504 Bug 4576: remove touch/mouse duplication for WinRT 2019-04-02 17:13:22 +02:00
Sylvain Becker
9e69244d5d Bug 4576: remove touch/mouse duplication for Emscripten 2019-04-02 17:10:29 +02:00
Sylvain Becker
e8431d6d53 Bug 4576: remove touch/mouse duplication for Wayland 2019-04-02 17:07:54 +02:00
Sylvain Becker
a25d2bcfc5 Bug 4576: remove touch/mouse duplication for linux/EVDEV 2019-04-02 17:03:58 +02:00
Sylvain Becker
2c8b5f513a Bug 4576: remove touch/mouse duplication for Windows 2019-04-02 16:58:11 +02:00
Sylvain Becker
fb5d1a1602 Bug 4576: handle mapping of TouchEvents to MouseEvents at higher level 2019-04-02 16:46:17 +02:00
Sam Lantinga
0b8f778883 configure.in: Rename configure.ac to fix an 'aclocal' warning
--HG--
rename : test/configure.in => test/configure.ac
2019-04-02 05:31:08 -07:00