Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "Trap Back button" option to Android prelaunch menu #36870

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class SplashScreen extends Activity {
private static final int INSTALL_DIALOG_ID = 0;
private ProgressDialog installDialog;

public CharSequence[] mSettingsNames = { "Software rendering", "Force fullscreen" };
public boolean[] mSettingsValues = { false, false};
public CharSequence[] mSettingsNames = { "Software rendering", "Force fullscreen", "Trap Back button" };
public boolean[] mSettingsValues = { false, false, true };

private String getVersionName() {
try {
Expand Down
6 changes: 6 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,12 @@ void options_manager::add_options_android()

add_empty_line();

add( "ANDROID_TRAP_BACK_BUTTON", "android", translate_marker( "Trap Back button" ),
translate_marker( "If true, the back button will NOT back out of the app and will be passed to the application as SDL_SCANCODE_AC_BACK. Requires restart." ),
// take default setting from pre-game settings screen - important as there are issues with Back button on Android 9 with specific devices
android_get_default_setting( "Trap Back button", true )
);

add( "ANDROID_AUTO_KEYBOARD", "android", translate_marker( "Auto-manage virtual keyboard" ),
translate_marker( "If true, automatically show/hide the virtual keyboard when necessary based on context. If false, virtual keyboard must be toggled manually." ),
true
Expand Down
6 changes: 6 additions & 0 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ static void WinCreate()
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 6 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );

// Fix Back button crash on Android 9
#if defined(SDL_HINT_ANDROID_TRAP_BACK_BUTTON )
const bool trap_back_button = get_option<bool>( "ANDROID_TRAP_BACK_BUTTON" );
SDL_SetHint( SDL_HINT_ANDROID_TRAP_BACK_BUTTON, trap_back_button ? "1" : "0" );
#endif

// Prevent mouse|touch input confusion
#if defined(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH)
SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" );
Expand Down