mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed initial display orientation at Android app start
This commit is contained in:
parent
1a8e3a0270
commit
d05eec7207
@ -284,6 +284,7 @@ static jmethodID midHapticStop;
|
|||||||
static jfieldID fidSeparateMouseAndTouch;
|
static jfieldID fidSeparateMouseAndTouch;
|
||||||
|
|
||||||
/* Accelerometer data storage */
|
/* Accelerometer data storage */
|
||||||
|
static SDL_DisplayOrientation displayOrientation;
|
||||||
static float fLastAccelerometer[3];
|
static float fLastAccelerometer[3];
|
||||||
static SDL_bool bHasNewData;
|
static SDL_bool bHasNewData;
|
||||||
|
|
||||||
@ -399,7 +400,7 @@ Android_JNI_ThreadDestroyed(void *value)
|
|||||||
|
|
||||||
/* Creation of local storage mThreadKey */
|
/* Creation of local storage mThreadKey */
|
||||||
static void
|
static void
|
||||||
Android_JNI_CreateKey()
|
Android_JNI_CreateKey(void)
|
||||||
{
|
{
|
||||||
int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed);
|
int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
@ -408,7 +409,7 @@ Android_JNI_CreateKey()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Android_JNI_CreateKey_once()
|
Android_JNI_CreateKey_once(void)
|
||||||
{
|
{
|
||||||
int status = pthread_once(&key_once, Android_JNI_CreateKey);
|
int status = pthread_once(&key_once, Android_JNI_CreateKey);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
@ -423,7 +424,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkJNIReady()
|
void checkJNIReady(void)
|
||||||
{
|
{
|
||||||
if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) {
|
if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) {
|
||||||
/* We aren't fully initialized, let's just return. */
|
/* We aren't fully initialized, let's just return. */
|
||||||
@ -739,11 +740,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
|
|||||||
{
|
{
|
||||||
SDL_LockMutex(Android_ActivityMutex);
|
SDL_LockMutex(Android_ActivityMutex);
|
||||||
|
|
||||||
if (Android_Window)
|
displayOrientation = (SDL_DisplayOrientation)orientation;
|
||||||
{
|
SDL_SendDisplayEvent(SDL_GetDisplay(0), SDL_DISPLAYEVENT_ORIENTATION, orientation);
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplay(0);
|
|
||||||
SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_UnlockMutex(Android_ActivityMutex);
|
SDL_UnlockMutex(Android_ActivityMutex);
|
||||||
}
|
}
|
||||||
@ -1418,6 +1416,11 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_DisplayOrientation Android_JNI_GetDisplayOrientation(void)
|
||||||
|
{
|
||||||
|
return displayOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi)
|
int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
@ -2263,7 +2266,7 @@ void Android_JNI_HideTextInput(void)
|
|||||||
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
|
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_IsScreenKeyboardShown()
|
SDL_bool Android_JNI_IsScreenKeyboardShown(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
jboolean is_shown = 0;
|
jboolean is_shown = 0;
|
||||||
@ -2595,7 +2598,7 @@ SDL_bool Android_JNI_SetSystemCursor(int cursorID)
|
|||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SupportsRelativeMouse()
|
SDL_bool Android_JNI_SupportsRelativeMouse(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
|
||||||
|
@ -33,6 +33,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "SDL_audio.h"
|
#include "SDL_audio.h"
|
||||||
#include "SDL_rect.h"
|
#include "SDL_rect.h"
|
||||||
|
#include "SDL_video.h"
|
||||||
|
|
||||||
/* Interface from the SDL library into the Android Java activity */
|
/* Interface from the SDL library into the Android Java activity */
|
||||||
extern void Android_JNI_SetActivityTitle(const char *title);
|
extern void Android_JNI_SetActivityTitle(const char *title);
|
||||||
@ -46,6 +47,7 @@ extern SDL_bool Android_JNI_IsScreenKeyboardShown(void);
|
|||||||
extern ANativeWindow* Android_JNI_GetNativeWindow(void);
|
extern ANativeWindow* Android_JNI_GetNativeWindow(void);
|
||||||
extern void Android_JNI_SetSurfaceViewFormat(int format);
|
extern void Android_JNI_SetSurfaceViewFormat(int format);
|
||||||
|
|
||||||
|
extern SDL_DisplayOrientation Android_JNI_GetDisplayOrientation(void);
|
||||||
extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi);
|
extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi);
|
||||||
|
|
||||||
/* Audio support */
|
/* Audio support */
|
||||||
@ -58,8 +60,8 @@ extern void Android_JNI_CloseAudioDevice(const int iscapture);
|
|||||||
extern void Android_JNI_AudioSetThreadPriority(int iscapture, int device_id);
|
extern void Android_JNI_AudioSetThreadPriority(int iscapture, int device_id);
|
||||||
|
|
||||||
/* Detecting device type */
|
/* Detecting device type */
|
||||||
extern SDL_bool Android_IsDeXMode();
|
extern SDL_bool Android_IsDeXMode(void);
|
||||||
extern SDL_bool Android_IsChromebook();
|
extern SDL_bool Android_IsChromebook(void);
|
||||||
|
|
||||||
#include "SDL_rwops.h"
|
#include "SDL_rwops.h"
|
||||||
|
|
||||||
|
@ -172,8 +172,10 @@ VideoBootStrap Android_bootstrap = {
|
|||||||
int
|
int
|
||||||
Android_VideoInit(_THIS)
|
Android_VideoInit(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||||
SDL_DisplayMode mode;
|
int display_index;
|
||||||
|
SDL_VideoDisplay *display;
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
|
||||||
videodata->isPaused = SDL_FALSE;
|
videodata->isPaused = SDL_FALSE;
|
||||||
videodata->isPausing = SDL_FALSE;
|
videodata->isPausing = SDL_FALSE;
|
||||||
@ -184,9 +186,12 @@ Android_VideoInit(_THIS)
|
|||||||
mode.refresh_rate = Android_ScreenRate;
|
mode.refresh_rate = Android_ScreenRate;
|
||||||
mode.driverdata = NULL;
|
mode.driverdata = NULL;
|
||||||
|
|
||||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
display_index = SDL_AddBasicVideoDisplay(&mode);
|
||||||
|
if (display_index < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
display = SDL_GetDisplay(display_index);
|
||||||
|
display->orientation = Android_JNI_GetDisplayOrientation();
|
||||||
|
|
||||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user