mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-03 17:02:41 +00:00
[Android] Add support for rotation and minimizing the application
This commit is contained in:
parent
6448e5e5ee
commit
5a549ef663
7 changed files with 78 additions and 29 deletions
|
@ -333,10 +333,12 @@ public final class NativeLibrary
|
|||
|
||||
/**
|
||||
* Begins emulation.
|
||||
*
|
||||
* @param surf The surface to render to.
|
||||
*/
|
||||
public static native void Run(Surface surf);
|
||||
public static native void Run();
|
||||
|
||||
// Surface Handling
|
||||
public static native void SurfaceChanged(Surface surf);
|
||||
public static native void SurfaceDestroyed();
|
||||
|
||||
/** Unpauses emulation from a paused state. */
|
||||
public static native void UnPauseEmulation();
|
||||
|
|
|
@ -177,13 +177,16 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
}
|
||||
});
|
||||
|
||||
// Instantiate an EmulationFragment.
|
||||
EmulationFragment emulationFragment = EmulationFragment.newInstance(path);
|
||||
if (savedInstanceState == null)
|
||||
{
|
||||
// Instantiate an EmulationFragment.
|
||||
EmulationFragment emulationFragment = EmulationFragment.newInstance(path);
|
||||
|
||||
// Add fragment to the activity - this triggers all its lifecycle callbacks.
|
||||
getFragmentManager().beginTransaction()
|
||||
.add(R.id.frame_emulation_fragment, emulationFragment, EmulationFragment.FRAGMENT_TAG)
|
||||
.commit();
|
||||
// Add fragment to the activity - this triggers all its lifecycle callbacks.
|
||||
getFragmentManager().beginTransaction()
|
||||
.add(R.id.frame_emulation_fragment, emulationFragment, EmulationFragment.FRAGMENT_TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
if (mDeviceHasTouchScreen)
|
||||
{
|
||||
|
|
|
@ -115,7 +115,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||
public void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
pauseEmulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,12 +159,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||
{
|
||||
Log.d("DolphinEmu", "Surface changed. Resolution: " + width + "x" + height);
|
||||
mSurface = holder.getSurface();
|
||||
NativeLibrary.SurfaceChanged(mSurface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder)
|
||||
{
|
||||
Log.d("DolphinEmu", "Surface destroyed.");
|
||||
NativeLibrary.SurfaceDestroyed();
|
||||
|
||||
if (mEmulationRunning)
|
||||
{
|
||||
|
@ -216,20 +217,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||
mEmulationRunning = true;
|
||||
mEmulationStarted = true;
|
||||
|
||||
// Loop until onSurfaceCreated succeeds
|
||||
while (mSurface == null)
|
||||
{
|
||||
if (!mEmulationRunning)
|
||||
{
|
||||
// So that if the user quits before this gets a surface, we don't loop infinitely.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("DolphinEmu", "Starting emulation: " + mSurface);
|
||||
|
||||
// Start emulation using the provided Surface.
|
||||
NativeLibrary.Run(mSurface);
|
||||
NativeLibrary.Run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue