mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
added aspect ratio options
This commit is contained in:
@@ -693,6 +693,8 @@ static bool WriteConfigToml(const std::string& config_path,
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" void xemu_android_set_display_mode_setting(int mode);
|
||||
|
||||
static SetupFiles SyncSetupFiles() {
|
||||
SetupFiles out{};
|
||||
JNIEnv* env = GetEnv();
|
||||
@@ -800,6 +802,9 @@ static SetupFiles SyncSetupFiles() {
|
||||
}
|
||||
out.audio_driver = GetPrefString(env, activity, "setting_audio_driver");
|
||||
|
||||
int displayMode = GetPrefInt(env, activity, "setting_display_mode", 0);
|
||||
xemu_android_set_display_mode_setting(displayMode);
|
||||
|
||||
out.config_path = base + "/xemu.toml";
|
||||
WriteConfigToml(out.config_path, out.mcpx, out.flash, out.hdd, out.dvd, out.eeprom, emuSettings);
|
||||
LogInfoFmt("SyncSetupFiles: config %s", out.config_path.c_str());
|
||||
|
||||
@@ -20,6 +20,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
val btn1x = findViewById<MaterialButton>(R.id.btn_scale_1x)
|
||||
val btn2x = findViewById<MaterialButton>(R.id.btn_scale_2x)
|
||||
val btn3x = findViewById<MaterialButton>(R.id.btn_scale_3x)
|
||||
val toggleDisplayMode = findViewById<MaterialButtonToggleGroup>(R.id.toggle_display_mode)
|
||||
val toggleThread = findViewById<MaterialButtonToggleGroup>(R.id.toggle_tcg_thread)
|
||||
val btnMulti = findViewById<MaterialButton>(R.id.btn_thread_multi)
|
||||
val btnSingle = findViewById<MaterialButton>(R.id.btn_thread_single)
|
||||
@@ -38,6 +39,13 @@ class SettingsActivity : AppCompatActivity() {
|
||||
else -> toggleScale.check(R.id.btn_scale_1x)
|
||||
}
|
||||
|
||||
val displayMode = prefs.getInt("setting_display_mode", 0)
|
||||
when (displayMode) {
|
||||
1 -> toggleDisplayMode.check(R.id.btn_display_4_3)
|
||||
2 -> toggleDisplayMode.check(R.id.btn_display_16_9)
|
||||
else -> toggleDisplayMode.check(R.id.btn_display_stretch)
|
||||
}
|
||||
|
||||
val tcgThread = prefs.getString("setting_tcg_thread", "multi") ?: "multi"
|
||||
if (tcgThread == "single") {
|
||||
toggleThread.check(R.id.btn_thread_single)
|
||||
@@ -58,6 +66,11 @@ class SettingsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
btnSave.setOnClickListener {
|
||||
val selectedDisplayMode = when (toggleDisplayMode.checkedButtonId) {
|
||||
R.id.btn_display_4_3 -> 1
|
||||
R.id.btn_display_16_9 -> 2
|
||||
else -> 0
|
||||
}
|
||||
val selectedScale = when (toggleScale.checkedButtonId) {
|
||||
R.id.btn_scale_2x -> 2
|
||||
R.id.btn_scale_3x -> 3
|
||||
@@ -74,6 +87,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
prefs.edit()
|
||||
.putInt("setting_display_mode", selectedDisplayMode)
|
||||
.putInt("setting_surface_scale", selectedScale)
|
||||
.putString("setting_tcg_thread", selectedThread)
|
||||
.putBoolean("setting_use_dsp", switchDsp.isChecked)
|
||||
|
||||
@@ -97,6 +97,49 @@
|
||||
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:text="@string/settings_display_mode"
|
||||
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:textColor="@color/xemu_text_muted" />
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/toggle_display_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_display_stretch"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/settings_display_mode_stretch" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_display_4_3"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/settings_display_mode_4_3" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_display_16_9"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/settings_display_mode_16_9" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<!-- ── PERFORMANCE ── -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -80,6 +80,11 @@
|
||||
<string name="settings_save">Save</string>
|
||||
|
||||
<string name="settings_section_display">Display</string>
|
||||
<string name="settings_display_mode">Aspect Ratio</string>
|
||||
<string name="settings_display_mode_stretch">Stretch</string>
|
||||
<string name="settings_display_mode_4_3">4:3</string>
|
||||
<string name="settings_display_mode_16_9">16:9</string>
|
||||
|
||||
<string name="settings_resolution_scale">Internal Resolution Scale</string>
|
||||
<string name="settings_resolution_scale_1x">1x (Native 480p)</string>
|
||||
<string name="settings_resolution_scale_2x">2x (960p)</string>
|
||||
|
||||
@@ -137,6 +137,7 @@ static GLuint g_android_blit_vao;
|
||||
static GLuint g_android_blit_vbo;
|
||||
static GLint g_android_blit_tex_loc = -1;
|
||||
static GLint g_android_blit_flip_loc = -1;
|
||||
static int g_android_display_mode = 0; /* 0=stretch, 1=4:3, 2=16:9 */
|
||||
static GLuint g_android_cpu_tex = 0;
|
||||
static int g_android_cpu_tex_w = 0;
|
||||
static int g_android_cpu_tex_h = 0;
|
||||
@@ -202,6 +203,11 @@ static GLuint android_gl_compile_shader(GLenum type, const char *src)
|
||||
return shader;
|
||||
}
|
||||
|
||||
void xemu_android_set_display_mode_setting(int mode)
|
||||
{
|
||||
g_android_display_mode = mode;
|
||||
}
|
||||
|
||||
static bool android_blit_init(void)
|
||||
{
|
||||
if (g_android_blit_prog) {
|
||||
@@ -291,8 +297,21 @@ static void android_blit_frame(GLuint tex, bool flip)
|
||||
if (w <= 0) w = 1;
|
||||
if (h <= 0) h = 1;
|
||||
|
||||
int vx = 0, vy = 0, vw = w, vh = h;
|
||||
if (g_android_display_mode != 0) {
|
||||
float target = (g_android_display_mode == 1) ? (4.0f / 3.0f) : (16.0f / 9.0f);
|
||||
float screen = (float)w / (float)h;
|
||||
if (screen > target) {
|
||||
vw = (int)(h * target);
|
||||
vx = (w - vw) / 2;
|
||||
} else {
|
||||
vh = (int)(w / target);
|
||||
vy = (h - vh) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, w, h);
|
||||
glViewport(vx, vy, vw, vh);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
Reference in New Issue
Block a user