diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index 3ae5d66d..96dc6b41 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -3,7 +3,6 @@ package com.panda3ds.pandroid.app; import android.content.Intent; import android.os.Build; import android.os.Bundle; -import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -17,7 +16,7 @@ import com.panda3ds.pandroid.AlberDriver; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.app.game.AlberInputListener; import com.panda3ds.pandroid.app.game.DrawerFragment; -import com.panda3ds.pandroid.app.game.EmulatorListener; +import com.panda3ds.pandroid.app.game.EmulatorCallback; import com.panda3ds.pandroid.data.config.GlobalConfig; import com.panda3ds.pandroid.input.InputHandler; import com.panda3ds.pandroid.input.InputMap; @@ -28,7 +27,7 @@ import com.panda3ds.pandroid.view.ds.DsLayoutManager; import com.panda3ds.pandroid.view.renderer.ConsoleRenderer; import com.panda3ds.pandroid.view.utils.PerformanceView; -public class GameActivity extends BaseActivity implements EmulatorListener { +public class GameActivity extends BaseActivity implements EmulatorCallback { private final DrawerFragment drawerFragment = new DrawerFragment(); private final AlberInputListener inputListener = new AlberInputListener(this); private ConsoleRenderer renderer; @@ -113,7 +112,7 @@ public class GameActivity extends BaseActivity implements EmulatorListener { } @Override - public void switchDualScreenLayout() { + public void swapScreens() { currentDsLayout = currentDsLayout + 1 < DsLayoutManager.getLayoutCount() ? currentDsLayout + 1 : 0; renderer.setLayout(DsLayoutManager.createLayout(currentDsLayout)); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/AlberInputListener.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/AlberInputListener.java index bc848a8c..4777989d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/AlberInputListener.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/AlberInputListener.java @@ -11,8 +11,8 @@ import java.util.Objects; public class AlberInputListener implements Function { - private final EmulatorListener emulator; - public AlberInputListener(EmulatorListener emulator) { this.emulator = emulator; } + private final EmulatorCallback emulator; + public AlberInputListener(EmulatorCallback emulator) { this.emulator = emulator; } private final Vector2 axis = new Vector2(0.0f, 0.0f); @@ -50,7 +50,7 @@ public class AlberInputListener implements Function { break; case CHANGE_DS_LAYOUT: if (!event.isDown()){ - emulator.switchDualScreenLayout(); + emulator.swapScreens(); } break; default: diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java index 25bcc9ae..cba22e6c 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java @@ -14,7 +14,6 @@ import androidx.appcompat.widget.AppCompatTextView; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import android.content.pm.ActivityInfo; -import android.content.res.Configuration; import com.google.android.material.navigation.NavigationView; import com.panda3ds.pandroid.AlberDriver; @@ -25,10 +24,12 @@ import com.panda3ds.pandroid.view.gamesgrid.GameIconView; public class DrawerFragment extends Fragment implements DrawerLayout.DrawerListener, NavigationView.OnNavigationItemSelectedListener { private DrawerLayout drawerContainer; + private EmulatorCallback emulator; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + emulator = ((EmulatorCallback) requireActivity()); drawerContainer = requireActivity().findViewById(R.id.drawer_container); drawerContainer.removeDrawerListener(this); drawerContainer.addDrawerListener(this); @@ -113,6 +114,9 @@ public class DrawerFragment extends Fragment implements DrawerLayout.DrawerListe int id = item.getItemId(); if (id == R.id.resume) { close(); + } else if (id == R.id.ds_switch) { + emulator.swapScreens(); + close(); } else if (id == R.id.exit) { requireActivity().finish(); } else if (id == R.id.lua_script) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorCallback.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorCallback.java new file mode 100644 index 00000000..1a01af2f --- /dev/null +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorCallback.java @@ -0,0 +1,7 @@ +package com.panda3ds.pandroid.app.game; + +public interface EmulatorCallback { + void onBackPressed(); + + void swapScreens(); +} diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorListener.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorListener.java deleted file mode 100644 index 5c0f7f63..00000000 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/EmulatorListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.panda3ds.pandroid.app.game; - -public interface EmulatorListener { - void onBackPressed(); - - void switchDualScreenLayout(); -} diff --git a/src/pandroid/app/src/main/res/drawable/ic_switch_screen.xml b/src/pandroid/app/src/main/res/drawable/ic_switch_screen.xml new file mode 100644 index 00000000..f577b24f --- /dev/null +++ b/src/pandroid/app/src/main/res/drawable/ic_switch_screen.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/pandroid/app/src/main/res/menu/game_drawer.xml b/src/pandroid/app/src/main/res/menu/game_drawer.xml index 72574d7b..2ac82b68 100644 --- a/src/pandroid/app/src/main/res/menu/game_drawer.xml +++ b/src/pandroid/app/src/main/res/menu/game_drawer.xml @@ -10,6 +10,10 @@ android:id="@+id/resume" android:icon="@drawable/ic_shortcut" android:title="@string/resume" /> + Dual Screen layouts Change layout of console screens. Click to change + Swap screen diff --git a/src/pandroid/app/src/main/res/xml/input_map_preferences.xml b/src/pandroid/app/src/main/res/xml/input_map_preferences.xml index 43a64a90..2af485ec 100644 --- a/src/pandroid/app/src/main/res/xml/input_map_preferences.xml +++ b/src/pandroid/app/src/main/res/xml/input_map_preferences.xml @@ -134,7 +134,7 @@ app:iconSpaceReserved="false"/>