android: frontend: menu: Improve in game options, make check boxes.

This commit is contained in:
bunnei 2019-08-31 15:26:23 -04:00 committed by xperia64
parent 07848c7368
commit a927bad573
12 changed files with 172 additions and 119 deletions

View File

@ -15,6 +15,7 @@ import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.citra.citra_android.activities.EmulationActivity; import org.citra.citra_android.activities.EmulationActivity;
import org.citra.citra_android.utils.EmulationMenuSettings;
import org.citra.citra_android.utils.Log; import org.citra.citra_android.utils.Log;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -287,7 +288,7 @@ public final class NativeLibrary {
/** /**
* Swaps the top and bottom screens. * Swaps the top and bottom screens.
*/ */
public static native void SwapScreens(boolean is_portrait_mode); public static native void SwapScreens(boolean swap_screens, boolean is_portrait_mode);
public static boolean isPortraitMode() { public static boolean isPortraitMode() {
return CitraApplication.getAppContext().getResources().getConfiguration().orientation == return CitraApplication.getAppContext().getResources().getConfiguration().orientation ==
@ -295,8 +296,7 @@ public final class NativeLibrary {
} }
public static int landscapeScreenLayout() { public static int landscapeScreenLayout() {
return PreferenceManager.getDefaultSharedPreferences(CitraApplication.getAppContext()) return EmulationMenuSettings.getLandscapeScreenLayout();
.getInt("LandscapeScreenLayout", EmulationActivity.LayoutOption_MobileLandscape);
} }
public static boolean displayAlertMsg(final String caption, final String text, public static boolean displayAlertMsg(final String caption, final String text,

View File

@ -1,5 +1,6 @@
package org.citra.citra_android.activities; package org.citra.citra_android.activities;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -38,18 +39,14 @@ import org.citra.citra_android.model.settings.view.InputBindingSetting;
import org.citra.citra_android.ui.main.MainPresenter; import org.citra.citra_android.ui.main.MainPresenter;
import org.citra.citra_android.utils.Animations; import org.citra.citra_android.utils.Animations;
import org.citra.citra_android.utils.ControllerMappingHelper; import org.citra.citra_android.utils.ControllerMappingHelper;
import org.citra.citra_android.utils.EmulationMenuSettings;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.util.List; import java.util.List;
import static android.view.MotionEvent.AXIS_RZ;
import static android.view.MotionEvent.AXIS_X;
import static android.view.MotionEvent.AXIS_Y;
import static android.view.MotionEvent.AXIS_Z;
import static java.lang.annotation.RetentionPolicy.SOURCE; import static java.lang.annotation.RetentionPolicy.SOURCE;
public final class EmulationActivity extends AppCompatActivity { public final class EmulationActivity extends AppCompatActivity {
public static final int REQUEST_CHANGE_DISC = 1;
public static final String EXTRA_SELECTED_GAME = "SelectedGame"; public static final String EXTRA_SELECTED_GAME = "SelectedGame";
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle"; public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
public static final String EXTRA_SCREEN_PATH = "ScreenPath"; public static final String EXTRA_SCREEN_PATH = "ScreenPath";
@ -58,13 +55,14 @@ public final class EmulationActivity extends AppCompatActivity {
public static final int MENU_ACTION_TOGGLE_CONTROLS = 1; public static final int MENU_ACTION_TOGGLE_CONTROLS = 1;
public static final int MENU_ACTION_ADJUST_SCALE = 2; public static final int MENU_ACTION_ADJUST_SCALE = 2;
public static final int MENU_ACTION_EXIT = 3; public static final int MENU_ACTION_EXIT = 3;
public static final int MENU_ACTION_TOGGLE_PREF_STATS = 4; public static final int MENU_ACTION_SHOW_FPS = 4;
public static final int MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE = 5; public static final int MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE = 5;
public static final int MENU_ACTION_SCREEN_LAYOUT_PORTRAIT = 6; public static final int MENU_ACTION_SCREEN_LAYOUT_PORTRAIT = 6;
public static final int MENU_ACTION_SCREEN_LAYOUT_SINGLE = 7; public static final int MENU_ACTION_SCREEN_LAYOUT_SINGLE = 7;
public static final int MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE = 8; public static final int MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE = 8;
public static final int MENU_ACTION_SWAP_SCREENS = 9; public static final int MENU_ACTION_SWAP_SCREENS = 9;
public static final int MENU_ACTION_RESET_OVERLAY = 10; public static final int MENU_ACTION_RESET_OVERLAY = 10;
public static final int MENU_ACTION_SHOW_OVERLAY = 11;
private static final int EMULATION_RUNNING_NOTIFICATION = 0x1000; private static final int EMULATION_RUNNING_NOTIFICATION = 0x1000;
private static final String BACKSTACK_NAME_MENU = "menu"; private static final String BACKSTACK_NAME_MENU = "menu";
@ -78,8 +76,8 @@ public final class EmulationActivity extends AppCompatActivity {
EmulationActivity.MENU_ACTION_TOGGLE_CONTROLS); EmulationActivity.MENU_ACTION_TOGGLE_CONTROLS);
buttonsActionsMap buttonsActionsMap
.append(R.id.menu_emulation_adjust_scale, EmulationActivity.MENU_ACTION_ADJUST_SCALE); .append(R.id.menu_emulation_adjust_scale, EmulationActivity.MENU_ACTION_ADJUST_SCALE);
buttonsActionsMap.append(R.id.menu_emulation_toggle_perf_stats, buttonsActionsMap.append(R.id.menu_emulation_show_fps,
EmulationActivity.MENU_ACTION_TOGGLE_PREF_STATS); EmulationActivity.MENU_ACTION_SHOW_FPS);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
buttonsActionsMap.append(R.id.menu_screen_layout_landscape, buttonsActionsMap.append(R.id.menu_screen_layout_landscape,
EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE); EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE);
@ -93,6 +91,8 @@ public final class EmulationActivity extends AppCompatActivity {
EmulationActivity.MENU_ACTION_SWAP_SCREENS); EmulationActivity.MENU_ACTION_SWAP_SCREENS);
buttonsActionsMap buttonsActionsMap
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY); .append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
buttonsActionsMap
.append(R.id.menu_emulation_show_overlay, EmulationActivity.MENU_ACTION_SHOW_OVERLAY);
} }
private View mDecorView; private View mDecorView;
@ -248,6 +248,10 @@ public final class EmulationActivity extends AppCompatActivity {
mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
showRunningNotification(); showRunningNotification();
// Override Citra core INI with the one set by our in game menu
NativeLibrary.SwapScreens(EmulationMenuSettings.getSwapScreens(),
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
} }
@Override @Override
@ -365,37 +369,28 @@ public final class EmulationActivity extends AppCompatActivity {
.withEndAction(afterShowingScreenshot); .withEndAction(afterShowingScreenshot);
} }
// These must match what is defined in src/core/settings.h
public static final int LayoutOption_Default = 0;
public static final int LayoutOption_SingleScreen = 1;
public static final int LayoutOption_LargeScreen = 2;
public static final int LayoutOption_SideScreen = 3;
public static final int LayoutOption_MobilePortrait = 4;
public static final int LayoutOption_MobileLandscape = 5;
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_emulation, menu); getMenuInflater().inflate(R.menu.menu_emulation, menu);
int layoutOptionMenuItem = R.id.menu_screen_layout_landscape;
// mPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); switch (EmulationMenuSettings.getLandscapeScreenLayout()) {
int layoutOption = mPreferences.getInt("LandscapeScreenLayout", LayoutOption_MobileLandscape); case EmulationMenuSettings.LayoutOption_SingleScreen:
layoutOptionMenuItem = R.id.menu_screen_layout_single;
int menuItemId = R.id.menu_screen_layout_landscape;
switch (layoutOption) {
case LayoutOption_SingleScreen:
menuItemId = R.id.menu_screen_layout_single;
break; break;
case LayoutOption_SideScreen: case EmulationMenuSettings.LayoutOption_SideScreen:
menuItemId = R.id.menu_screen_layout_sidebyside; layoutOptionMenuItem = R.id.menu_screen_layout_sidebyside;
break; break;
case LayoutOption_MobilePortrait: case EmulationMenuSettings.LayoutOption_MobilePortrait:
menuItemId = R.id.menu_screen_layout_portrait; layoutOptionMenuItem = R.id.menu_screen_layout_portrait;
break; break;
} }
menu.findItem(menuItemId).setChecked(true); menu.findItem(layoutOptionMenuItem).setChecked(true);
menu.findItem(R.id.menu_emulation_show_fps).setChecked(EmulationMenuSettings.getShowFps());
menu.findItem(R.id.menu_emulation_swap_screens).setChecked(EmulationMenuSettings.getSwapScreens());
menu.findItem(R.id.menu_emulation_show_overlay).setChecked(EmulationMenuSettings.getShowOverlay());
return true; return true;
} }
@ -422,40 +417,59 @@ public final class EmulationActivity extends AppCompatActivity {
break; break;
// Toggle the visibility of the Performance stats TextView // Toggle the visibility of the Performance stats TextView
case MENU_ACTION_TOGGLE_PREF_STATS: case MENU_ACTION_SHOW_FPS: {
mEmulationFragment.togglePerfStatsVisibility(); final boolean isEnabled = !EmulationMenuSettings.getShowFps();
break; EmulationMenuSettings.setShowFps(isEnabled);
item.setChecked(isEnabled);
mEmulationFragment.updateShowFpsOverlay();
break;
}
// Sets the screen layout to Landscape // Sets the screen layout to Landscape
case MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE: case MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE:
changeScreenOrientation(LayoutOption_MobileLandscape, item); changeScreenOrientation(EmulationMenuSettings.LayoutOption_MobileLandscape, item);
break; break;
// Sets the screen layout to Portrait // Sets the screen layout to Portrait
case MENU_ACTION_SCREEN_LAYOUT_PORTRAIT: case MENU_ACTION_SCREEN_LAYOUT_PORTRAIT:
changeScreenOrientation(LayoutOption_MobilePortrait, item); changeScreenOrientation(EmulationMenuSettings.LayoutOption_MobilePortrait, item);
break; break;
// Sets the screen layout to Single // Sets the screen layout to Single
case MENU_ACTION_SCREEN_LAYOUT_SINGLE: case MENU_ACTION_SCREEN_LAYOUT_SINGLE:
changeScreenOrientation(LayoutOption_SingleScreen, item); changeScreenOrientation(EmulationMenuSettings.LayoutOption_SingleScreen, item);
break; break;
// Sets the screen layout to Side by Side // Sets the screen layout to Side by Side
case MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE: case MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE:
changeScreenOrientation(LayoutOption_SideScreen, item); changeScreenOrientation(EmulationMenuSettings.LayoutOption_SideScreen, item);
break; break;
// Swap the top and bottom screen locations // Swap the top and bottom screen locations
case MENU_ACTION_SWAP_SCREENS: case MENU_ACTION_SWAP_SCREENS: {
NativeLibrary.SwapScreens(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); final boolean isEnabled = !EmulationMenuSettings.getSwapScreens();
EmulationMenuSettings.setSwapScreens(isEnabled);
item.setChecked(isEnabled);
NativeLibrary.SwapScreens(isEnabled, getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
break; break;
}
// Reset overlay placement // Reset overlay placement
case MENU_ACTION_RESET_OVERLAY: case MENU_ACTION_RESET_OVERLAY:
resetOverlay(); resetOverlay();
break; break;
// Show or hide overlay
case MENU_ACTION_SHOW_OVERLAY: {
final boolean isEnabled = !EmulationMenuSettings.getShowOverlay();
EmulationMenuSettings.setShowOverlay(isEnabled);
item.setChecked(isEnabled);
mEmulationFragment.refreshInputOverlay();
break;
}
case MENU_ACTION_EXIT: case MENU_ACTION_EXIT:
toggleMenu(); // Hide the menu (it will be showing since we just clicked it) toggleMenu(); // Hide the menu (it will be showing since we just clicked it)
mEmulationFragment.stopEmulation(); mEmulationFragment.stopEmulation();
@ -468,13 +482,9 @@ public final class EmulationActivity extends AppCompatActivity {
private void changeScreenOrientation(int layoutOption, MenuItem item) { private void changeScreenOrientation(int layoutOption, MenuItem item) {
item.setChecked(true); item.setChecked(true);
NativeLibrary.NotifyOrientationChange(layoutOption, NativeLibrary.NotifyOrientationChange(layoutOption,
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
EmulationMenuSettings.setLandscapeScreenLayout(layoutOption);
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("LandscapeScreenLayout", layoutOption);
editor.apply();
} }
private void editControlsPlacement() { private void editControlsPlacement() {
@ -538,7 +548,6 @@ public final class EmulationActivity extends AppCompatActivity {
builder.setMultiChoiceItems(R.array.n3dsButtons, enabledButtons, builder.setMultiChoiceItems(R.array.n3dsButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor (dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggle" + indexSelected, isChecked)); .putBoolean("buttonToggle" + indexSelected, isChecked));
builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) ->
{ {
editor.apply(); editor.apply();
@ -705,9 +714,9 @@ public final class EmulationActivity extends AppCompatActivity {
@Retention(SOURCE) @Retention(SOURCE)
@IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE, @IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE,
MENU_ACTION_EXIT, MENU_ACTION_TOGGLE_PREF_STATS, MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE, MENU_ACTION_EXIT, MENU_ACTION_SHOW_FPS, MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE,
MENU_ACTION_SCREEN_LAYOUT_PORTRAIT, MENU_ACTION_SCREEN_LAYOUT_SINGLE, MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE, MENU_ACTION_SCREEN_LAYOUT_PORTRAIT, MENU_ACTION_SCREEN_LAYOUT_SINGLE, MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE,
MENU_ACTION_SWAP_SCREENS, MENU_ACTION_RESET_OVERLAY}) MENU_ACTION_SWAP_SCREENS, MENU_ACTION_RESET_OVERLAY, MENU_ACTION_SHOW_OVERLAY})
public @interface MenuAction { public @interface MenuAction {
} }
} }

View File

@ -27,6 +27,7 @@ import org.citra.citra_android.overlay.InputOverlay;
import org.citra.citra_android.services.DirectoryInitializationService; import org.citra.citra_android.services.DirectoryInitializationService;
import org.citra.citra_android.services.DirectoryInitializationService.DirectoryInitializationState; import org.citra.citra_android.services.DirectoryInitializationService.DirectoryInitializationState;
import org.citra.citra_android.utils.DirectoryStateReceiver; import org.citra.citra_android.utils.DirectoryStateReceiver;
import org.citra.citra_android.utils.EmulationMenuSettings;
import org.citra.citra_android.utils.Log; import org.citra.citra_android.utils.Log;
public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback { public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback {
@ -97,30 +98,17 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
surfaceView.getHolder().addCallback(this); surfaceView.getHolder().addCallback(this);
mInputOverlay = contents.findViewById(R.id.surface_input_overlay); mInputOverlay = contents.findViewById(R.id.surface_input_overlay);
if (mInputOverlay != null) { mPerfStats = contents.findViewById(R.id.show_fps_text);
// If the input overlay was previously disabled, then don't show it.
if (!mPreferences.getBoolean("showInputOverlay", true)) {
mInputOverlay.setVisibility(View.GONE);
}
}
Button doneButton = contents.findViewById(R.id.done_control_config); Button doneButton = contents.findViewById(R.id.done_control_config);
if (doneButton != null) { if (doneButton != null) {
doneButton.setOnClickListener(v -> stopConfiguringControls()); doneButton.setOnClickListener(v -> stopConfiguringControls());
} }
mPerfStats = contents.findViewById(R.id.perf_stats_text); // Show/hide the "Show FPS" overlay
if (mPerfStats != null) { updateShowFpsOverlay();
// If the overlay was previously disabled, then don't show it.
if (!mPreferences.getBoolean("showPerfStats", true)) {
mPerfStats.setVisibility(View.GONE);
} else {
updatePerfStats();
}
}
// The new Surface created here will get passed to the native code via onSurfaceChanged. // The new Surface created here will get passed to the native code via onSurfaceChanged.
return contents; return contents;
} }
@ -193,46 +181,31 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
mInputOverlay.resetButtonPlacement(); mInputOverlay.resetButtonPlacement();
} }
public void togglePerfStatsVisibility() { public void updateShowFpsOverlay() {
SharedPreferences.Editor editor = mPreferences.edit(); if (EmulationMenuSettings.getShowFps()) {
final int SYSTEM_FPS = 0;
final int FPS = 1;
final int FRAMETIME = 2;
final int SPEED = 3;
perfStatsUpdater = () ->
{
final DecimalFormat df = new DecimalFormat("#.#");
double[] perfStats = NativeLibrary.GetPerfStats();
mPerfStats.setText(String.format("FPS: %s Speed: %s%%", df.format(perfStats[FPS]),
df.format(perfStats[SPEED] * 100.0)));
perfStatsUpdateHandler.postDelayed(perfStatsUpdater, 2000 /* 1s */);
};
perfStatsUpdateHandler.post(perfStatsUpdater);
// If the overlay is currently set to INVISIBLE
if (!mPreferences.getBoolean("showPerfStats", false)) {
updatePerfStats();
// Set it to VISIBLE
mPerfStats.setVisibility(View.VISIBLE); mPerfStats.setVisibility(View.VISIBLE);
editor.putBoolean("showPerfStats", true);
} else { } else {
stopPerfStatsUpdates(); if (perfStatsUpdater != null) {
// Set it to INVISIBLE perfStatsUpdateHandler.removeCallbacks(perfStatsUpdater);
}
mPerfStats.setVisibility(View.GONE); mPerfStats.setVisibility(View.GONE);
editor.putBoolean("showPerfStats", false);
}
editor.apply();
}
private void updatePerfStats() {
final int SYSTEM_FPS = 0;
final int FPS = 1;
final int FRAMETIME = 2;
final int SPEED = 3;
perfStatsUpdater = () ->
{
final DecimalFormat df = new DecimalFormat("#.#");
double[] perfStats = NativeLibrary.GetPerfStats();
mPerfStats.setText(String.format("FPS: %s Speed: %s%%", df.format(perfStats[FPS]),
df.format(perfStats[SPEED] * 100.0)));
perfStatsUpdateHandler.postDelayed(perfStatsUpdater, 2000 /* 1s */);
};
perfStatsUpdateHandler.post(perfStatsUpdater);
}
private void stopPerfStatsUpdates() {
if (perfStatsUpdater != null) {
perfStatsUpdateHandler.removeCallbacks(perfStatsUpdater);
} }
} }

View File

@ -19,8 +19,8 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
private static SparseIntArray buttonsActionsMap = new SparseIntArray(); private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static { static {
buttonsActionsMap.append(R.id.menu_emulation_toggle_perf_stats, buttonsActionsMap.append(R.id.menu_emulation_show_fps,
EmulationActivity.MENU_ACTION_TOGGLE_PREF_STATS); EmulationActivity.MENU_ACTION_SHOW_FPS);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
buttonsActionsMap.append(R.id.menu_screen_layout_landscape, buttonsActionsMap.append(R.id.menu_screen_layout_landscape,
EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE); EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_LANDSCAPE);
@ -32,6 +32,8 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE); EmulationActivity.MENU_ACTION_SCREEN_LAYOUT_SIDEBYSIDE);
buttonsActionsMap.append(R.id.menu_emulation_swap_screens, buttonsActionsMap.append(R.id.menu_emulation_swap_screens,
EmulationActivity.MENU_ACTION_SWAP_SCREENS); EmulationActivity.MENU_ACTION_SWAP_SCREENS);
buttonsActionsMap.append(R.id.menu_emulation_show_overlay,
EmulationActivity.MENU_ACTION_SHOW_OVERLAY);
} }
public static MenuFragment newInstance(String title) { public static MenuFragment newInstance(String title) {

View File

@ -29,6 +29,7 @@ import org.citra.citra_android.NativeLibrary;
import org.citra.citra_android.NativeLibrary.ButtonState; import org.citra.citra_android.NativeLibrary.ButtonState;
import org.citra.citra_android.NativeLibrary.ButtonType; import org.citra.citra_android.NativeLibrary.ButtonType;
import org.citra.citra_android.R; import org.citra.citra_android.R;
import org.citra.citra_android.utils.EmulationMenuSettings;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -648,8 +649,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
"-Portrait" : ""; "-Portrait" : "";
if (mPreferences.getBoolean("showInputOverlay", true)) { // Add all the enabled overlay items back to the HashSet.
// Add all the enabled overlay items back to the HashSet. if (EmulationMenuSettings.getShowOverlay()) {
addOverlayControls(orientation); addOverlayControls(orientation);
} }

View File

@ -0,0 +1,58 @@
package org.citra.citra_android.utils;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.citra.citra_android.CitraApplication;
public class EmulationMenuSettings {
private static SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(CitraApplication.getAppContext());
// These must match what is defined in src/core/settings.h
public static final int LayoutOption_Default = 0;
public static final int LayoutOption_SingleScreen = 1;
public static final int LayoutOption_LargeScreen = 2;
public static final int LayoutOption_SideScreen = 3;
public static final int LayoutOption_MobilePortrait = 4;
public static final int LayoutOption_MobileLandscape = 5;
public static int getLandscapeScreenLayout() {
return mPreferences.getInt("EmulationMenuSettings_LandscapeScreenLayout", LayoutOption_MobileLandscape);
}
public static void setLandscapeScreenLayout(int value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("EmulationMenuSettings_LandscapeScreenLayout", value);
editor.apply();
}
public static boolean getShowFps() {
return mPreferences.getBoolean("EmulationMenuSettings_ShowFps", false);
}
public static void setShowFps(boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean("EmulationMenuSettings_ShowFps", value);
editor.apply();
}
public static boolean getSwapScreens() {
return mPreferences.getBoolean("EmulationMenuSettings_SwapScreens", false);
}
public static void setSwapScreens(boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean("EmulationMenuSettings_SwapScreens", value);
editor.apply();
}
public static boolean getShowOverlay() {
return mPreferences.getBoolean("EmulationMenuSettings_ShowOverylay", true);
}
public static void setShowOverlay(boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean("EmulationMenuSettings_ShowOverylay", value);
editor.apply();
}
}

View File

@ -124,7 +124,6 @@ void Config::ReadValues() {
// Layout // Layout
Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger( Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger(
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::MobileLandscape))); "Layout", "layout_option", static_cast<int>(Settings::LayoutOption::MobileLandscape)));
Settings::values.swap_screen = sdl2_config->GetBoolean("Layout", "swap_screen", false);
Settings::values.custom_layout = sdl2_config->GetBoolean("Layout", "custom_layout", false); Settings::values.custom_layout = sdl2_config->GetBoolean("Layout", "custom_layout", false);
Settings::values.custom_top_left = Settings::values.custom_top_left =
static_cast<u16>(sdl2_config->GetInteger("Layout", "custom_top_left", 0)); static_cast<u16>(sdl2_config->GetInteger("Layout", "custom_top_left", 0));

View File

@ -215,9 +215,12 @@ void Java_org_citra_citra_1android_NativeLibrary_NotifyOrientationChange(
} }
void Java_org_citra_citra_1android_NativeLibrary_SwapScreens(JNIEnv* env, jobject obj, void Java_org_citra_citra_1android_NativeLibrary_SwapScreens(JNIEnv* env, jobject obj,
jboolean swap_screens,
jboolean is_portrait_mode) { jboolean is_portrait_mode) {
Settings::values.swap_screen = !Settings::values.swap_screen; Settings::values.swap_screen = swap_screens;
VideoCore::g_renderer->UpdateCurrentFramebufferLayout(is_portrait_mode); if (VideoCore::g_renderer) {
VideoCore::g_renderer->UpdateCurrentFramebufferLayout(is_portrait_mode);
}
} }
void Java_org_citra_citra_1android_NativeLibrary_SetUserDirectory(JNIEnv* env, jobject obj, void Java_org_citra_citra_1android_NativeLibrary_SetUserDirectory(JNIEnv* env, jobject obj,

View File

@ -139,7 +139,7 @@ JNIEXPORT void JNICALL Java_org_citra_citra_1android_NativeLibrary_NotifyOrienta
JNIEnv* env, jobject obj, jint layout_option, jboolean is_portrait_mode); JNIEnv* env, jobject obj, jint layout_option, jboolean is_portrait_mode);
JNIEXPORT void JNICALL Java_org_citra_citra_1android_NativeLibrary_SwapScreens( JNIEXPORT void JNICALL Java_org_citra_citra_1android_NativeLibrary_SwapScreens(
JNIEnv* env, jobject obj, jboolean is_portrait_mode); JNIEnv* env, jobject obj, jboolean swap_screens, jboolean is_portrait_mode);
JNIEXPORT void JNICALL Java_org_citra_citra_1android_NativeLibrary_Run__Ljava_lang_String_2( JNIEXPORT void JNICALL Java_org_citra_citra_1android_NativeLibrary_Run__Ljava_lang_String_2(
JNIEnv* env, jclass type, jstring path_); JNIEnv* env, jclass type, jstring path_);

View File

@ -22,7 +22,7 @@
android:focusableInTouchMode="true"/> android:focusableInTouchMode="true"/>
<TextView <TextView
android:id="@+id/perf_stats_text" android:id="@+id/show_fps_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="false" android:clickable="false"

View File

@ -25,11 +25,6 @@
</menu> </menu>
</item> </item>
<item
android:id="@+id/menu_emulation_toggle_perf_stats"
app:showAsAction="never"
android:title="@string/emulation_toggle_perf_stats"/>
<item <item
android:id="@+id/menu_emulation_switch_screen_layout" android:id="@+id/menu_emulation_switch_screen_layout"
app:showAsAction="never" app:showAsAction="never"
@ -58,6 +53,19 @@
<item <item
android:id="@+id/menu_emulation_swap_screens" android:id="@+id/menu_emulation_swap_screens"
app:showAsAction="never" app:showAsAction="never"
android:title="@string/emulation_swap_screens"/> android:title="@string/emulation_swap_screens"
android:checkable="true"/>
<item
android:id="@+id/menu_emulation_show_fps"
app:showAsAction="never"
android:title="@string/emulation_show_fps"
android:checkable="true"/>
<item
android:id="@+id/menu_emulation_show_overlay"
app:showAsAction="never"
android:title="@string/emulation_show_overlay"
android:checkable="true"/>
</menu> </menu>

View File

@ -55,8 +55,6 @@
<string name="region">Emulated region</string> <string name="region">Emulated region</string>
<!-- Graphics settings strings --> <!-- Graphics settings strings -->
<string name="show_fps">Show FPS</string>
<string name="show_fps_description">Show the number of frames rendered per second as a measure of emulation speed.</string>
<string name="vsync">Enable V-Sync</string> <string name="vsync">Enable V-Sync</string>
<string name="vsync_description">Synchronizes the game frame rate to the refresh rate of your device.</string> <string name="vsync_description">Synchronizes the game frame rate to the refresh rate of your device.</string>
<string name="linear_filtering">Enable linear filtering</string> <string name="linear_filtering">Enable linear filtering</string>
@ -110,11 +108,12 @@
<!-- Emulation Menu --> <!-- Emulation Menu -->
<string name="emulation_screenshot">Take Screenshot</string> <string name="emulation_screenshot">Take Screenshot</string>
<string name="emulation_exit">Exit</string> <string name="emulation_exit">Exit</string>
<string name="emulation_toggle_perf_stats">Toggle Perf Stats</string> <string name="emulation_show_fps">Show FPS</string>
<string name="emulation_configure_controls">Configure Controls</string> <string name="emulation_configure_controls">Configure Controls</string>
<string name="emulation_edit_layout">Edit Layout</string> <string name="emulation_edit_layout">Edit Layout</string>
<string name="emulation_done">Done</string> <string name="emulation_done">Done</string>
<string name="emulation_toggle_controls">Toggle Controls</string> <string name="emulation_toggle_controls">Toggle Controls</string>
<string name="emulation_toggle_all">Toggle All</string>
<string name="emulation_control_scale">Adjust Scale</string> <string name="emulation_control_scale">Adjust Scale</string>
<string name="emulation_choose_controller">Choose Controller</string> <string name="emulation_choose_controller">Choose Controller</string>
<string name="emulation_controller_changed">You may have to reload the game after changing extensions.</string> <string name="emulation_controller_changed">You may have to reload the game after changing extensions.</string>
@ -125,6 +124,7 @@
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string> <string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>
<string name="emulation_swap_screens">Swap Screens</string> <string name="emulation_swap_screens">Swap Screens</string>
<string name="emulation_touch_overlay_reset">Reset Overlay</string> <string name="emulation_touch_overlay_reset">Reset Overlay</string>
<string name="emulation_show_overlay">Show Overlay</string>
<string name="emulation_close_game">Close Game</string> <string name="emulation_close_game">Close Game</string>
<string name="emulation_close_game_message">Are you sure that you would like to close the current game?</string> <string name="emulation_close_game_message">Are you sure that you would like to close the current game?</string>