fixed screen orientation support

This commit is contained in:
Sebastian Krzyszkowiak 2017-06-26 03:18:54 +02:00
parent c97e163b31
commit de7311dabf
4 changed files with 21 additions and 4 deletions

View file

@ -3,13 +3,13 @@
package="net.dosowisko.${LIBSUPERDERPY_GAMENAME}" package="net.dosowisko.${LIBSUPERDERPY_GAMENAME}"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">
<uses-sdk android:minSdkVersion="15"/> <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:label="@string/app_name" android:debuggable="true" android:icon="@mipmap/${LIBSUPERDERPY_GAMENAME}"> <application android:label="@string/app_name" android:debuggable="true" android:icon="@mipmap/${LIBSUPERDERPY_GAMENAME}">
<activity android:name="net.dosowisko.${LIBSUPERDERPY_GAMENAME}.SuperDerpyActivity" <activity android:name="net.dosowisko.${LIBSUPERDERPY_GAMENAME}.SuperDerpyActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTask" android:launchMode="singleTask"
android:screenOrientation="unspecified" android:screenOrientation="${LIBSUPERDERPY_ANDROID_ORIENTATION}"
android:configChanges="screenLayout|uiMode|orientation|screenSize"> android:configChanges="screenLayout|uiMode|orientation|screenSize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View file

@ -1,3 +1,3 @@
include $(call my-dir)/localgen.mk include $(call my-dir)/localgen.mk
APP_PLATFORM := android-15 APP_PLATFORM := android-16
APP_ABI := $(TARGET_ARCH_ABI) APP_ABI := $(TARGET_ARCH_ABI)

View file

@ -2,6 +2,8 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
add_definitions(-D_XOPEN_SOURCE=600) add_definitions(-D_XOPEN_SOURCE=600)
add_definitions(-DLIBSUPERDERPY_ORIENTATION_${LIBSUPERDERPY_ORIENTATION}=true)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c11") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c11")
if(APPLE) if(APPLE)
@ -117,7 +119,7 @@ MACRO(add_libsuperderpy_target EXECUTABLE_SRC_LIST)
ENDMACRO() ENDMACRO()
if(ANDROID) if(ANDROID)
set(ANDROID_TARGET "android-15" CACHE STRING "What Android target to compile for.") set(ANDROID_TARGET "android-16" CACHE STRING "What Android target to compile for.")
# The android tool on Windows is a batch file wrapper, which cannot be # The android tool on Windows is a batch file wrapper, which cannot be
# started by MSYS shell directly. We invoke it via cmd.exe instead. # started by MSYS shell directly. We invoke it via cmd.exe instead.
@ -139,6 +141,14 @@ if(ANDROID)
file(REMOVE "${CMAKE_BINARY_DIR}/android/${PATH}.in") file(REMOVE "${CMAKE_BINARY_DIR}/android/${PATH}.in")
ENDMACRO() ENDMACRO()
if (LIBSUPERDERPY_ORIENTATION STREQUAL "PORTRAIT")
set(LIBSUPERDERPY_ANDROID_ORIENTATION "sensorPortrait")
elseif(LIBSUPERDERPY_ORIENTATION STREQUAL "LANDSCAPE")
set(LIBSUPERDERPY_ANDROID_ORIENTATION "sensorLandscape")
else()
set(LIBSUPERDERPY_ANDROID_ORIENTATION "unspecified")
endif()
configure_android_file("AndroidManifest.xml") configure_android_file("AndroidManifest.xml")
configure_android_file("localgen.properties") configure_android_file("localgen.properties")
configure_android_file("build.xml" @ONLY) configure_android_file("build.xml" @ONLY)

View file

@ -143,6 +143,13 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); // TODO: make ALLEGRO_PROGRAMMABLE_PIPELINE game-optional al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); // TODO: make ALLEGRO_PROGRAMMABLE_PIPELINE game-optional
al_set_new_display_option(ALLEGRO_VSYNC, 2-atoi(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1")), ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_VSYNC, 2-atoi(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1")), ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_OPENGL, atoi(GetConfigOptionDefault(game, "SuperDerpy", "opengl", "1")), ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_OPENGL, atoi(GetConfigOptionDefault(game, "SuperDerpy", "opengl", "1")), ALLEGRO_SUGGEST);
#ifdef LIBSUPERDERPY_ORIENTATION_LANDSCAPE
al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS, ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE, ALLEGRO_SUGGEST);
#elif defined(LIBSUPERDERPY_ORIENTATION_PORTRAIT)
al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS, ALLEGRO_DISPLAY_ORIENTATION_PORTRAIT, ALLEGRO_SUGGEST);
#endif
#ifdef ALLEGRO_WINDOWS #ifdef ALLEGRO_WINDOWS
al_set_new_window_position(20, 40); // workaround nasty Windows bug with window being created off-screen al_set_new_window_position(20, 40); // workaround nasty Windows bug with window being created off-screen
#endif #endif