Android: Get game metadata from core
Trying to get it from a GameFile before emulation starts is unreliable.
This commit is contained in:
parent
b6fcfcb9c9
commit
0dc29c743b
|
@ -447,6 +447,40 @@ public final class NativeLibrary
|
||||||
|
|
||||||
public static native void SetObscuredPixelsTop(int height);
|
public static native void SetObscuredPixelsTop(int height);
|
||||||
|
|
||||||
|
public static native boolean IsGameMetadataValid();
|
||||||
|
|
||||||
|
public static boolean IsEmulatingWii()
|
||||||
|
{
|
||||||
|
CheckGameMetadataValid();
|
||||||
|
return IsEmulatingWiiUnchecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetCurrentGameID()
|
||||||
|
{
|
||||||
|
CheckGameMetadataValid();
|
||||||
|
return GetCurrentGameIDUnchecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetCurrentTitleDescription()
|
||||||
|
{
|
||||||
|
CheckGameMetadataValid();
|
||||||
|
return GetCurrentTitleDescriptionUnchecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CheckGameMetadataValid()
|
||||||
|
{
|
||||||
|
if (!IsGameMetadataValid())
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("No game is running");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native boolean IsEmulatingWiiUnchecked();
|
||||||
|
|
||||||
|
private static native String GetCurrentGameIDUnchecked();
|
||||||
|
|
||||||
|
private static native String GetCurrentTitleDescriptionUnchecked();
|
||||||
|
|
||||||
public static boolean displayAlertMsg(final String caption, final String text,
|
public static boolean displayAlertMsg(final String caption, final String text,
|
||||||
final boolean yesNo, final boolean isWarning)
|
final boolean yesNo, final boolean isWarning)
|
||||||
{
|
{
|
||||||
|
@ -537,6 +571,19 @@ public final class NativeLibrary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void onTitleChanged()
|
||||||
|
{
|
||||||
|
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||||
|
if (emulationActivity == null)
|
||||||
|
{
|
||||||
|
Log.warning("[NativeLibrary] EmulationActivity is null.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emulationActivity.runOnUiThread(emulationActivity::onTitleChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static float getRenderSurfaceScale()
|
public static float getRenderSurfaceScale()
|
||||||
{
|
{
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
|
|
@ -139,6 +139,6 @@ public class AppLinkActivity extends FragmentActivity
|
||||||
mAfterDirectoryInitializationRunner.cancel();
|
mAfterDirectoryInitializationRunner.cancel();
|
||||||
mAfterDirectoryInitializationRunner = null;
|
mAfterDirectoryInitializationRunner = null;
|
||||||
}
|
}
|
||||||
EmulationActivity.launch(this, game);
|
EmulationActivity.launch(this, GameFileCacheService.findSecondDiscAndGetPaths(game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,20 +80,13 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
private boolean mMenuVisible;
|
private boolean mMenuVisible;
|
||||||
|
|
||||||
private static boolean sIgnoreLaunchRequests = false;
|
private static boolean sIgnoreLaunchRequests = false;
|
||||||
private static boolean sIsGameCubeGame;
|
|
||||||
|
|
||||||
private boolean activityRecreated;
|
private boolean activityRecreated;
|
||||||
private String mSelectedTitle;
|
|
||||||
private String mSelectedGameId;
|
|
||||||
private int mPlatform;
|
|
||||||
private String[] mPaths;
|
private String[] mPaths;
|
||||||
private boolean mIgnoreWarnings;
|
private boolean mIgnoreWarnings;
|
||||||
private static boolean sUserPausedEmulation;
|
private static boolean sUserPausedEmulation;
|
||||||
|
|
||||||
public static final String EXTRA_SELECTED_GAMES = "SelectedGames";
|
public static final String EXTRA_SELECTED_GAMES = "SelectedGames";
|
||||||
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
|
|
||||||
public static final String EXTRA_SELECTED_GAMEID = "SelectedGameId";
|
|
||||||
public static final String EXTRA_PLATFORM = "Platform";
|
|
||||||
public static final String EXTRA_IGNORE_WARNINGS = "IgnoreWarnings";
|
public static final String EXTRA_IGNORE_WARNINGS = "IgnoreWarnings";
|
||||||
public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation";
|
public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation";
|
||||||
|
|
||||||
|
@ -176,34 +169,7 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
EmulationActivity.MENU_ACTION_MOTION_CONTROLS);
|
EmulationActivity.MENU_ACTION_MOTION_CONTROLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] scanForSecondDisc(GameFile gameFile)
|
public static void launch(FragmentActivity activity, String[] filePaths)
|
||||||
{
|
|
||||||
GameFile secondFile = GameFileCacheService.findSecondDisc(gameFile);
|
|
||||||
if (secondFile == null)
|
|
||||||
return new String[]{gameFile.getPath()};
|
|
||||||
else
|
|
||||||
return new String[]{gameFile.getPath(), secondFile.getPath()};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void launch(FragmentActivity activity, GameFile gameFile)
|
|
||||||
{
|
|
||||||
if (sIgnoreLaunchRequests)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sIgnoreLaunchRequests = true;
|
|
||||||
|
|
||||||
Intent launcher = new Intent(activity, EmulationActivity.class);
|
|
||||||
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile));
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle());
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_GAMEID, gameFile.getGameId());
|
|
||||||
launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform());
|
|
||||||
|
|
||||||
new AfterDirectoryInitializationRunner().run(activity, true,
|
|
||||||
() -> activity.startActivity(launcher));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void launchFile(FragmentActivity activity, String[] filePaths)
|
|
||||||
{
|
{
|
||||||
if (sIgnoreLaunchRequests)
|
if (sIgnoreLaunchRequests)
|
||||||
return;
|
return;
|
||||||
|
@ -213,30 +179,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
Intent launcher = new Intent(activity, EmulationActivity.class);
|
Intent launcher = new Intent(activity, EmulationActivity.class);
|
||||||
launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths);
|
launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths);
|
||||||
|
|
||||||
// Try parsing a GameFile first. This should succeed for disc images.
|
|
||||||
GameFile gameFile = GameFile.parse(filePaths[0]);
|
|
||||||
if (gameFile != null)
|
|
||||||
{
|
|
||||||
// We don't want to pollute the game file cache with this new file,
|
|
||||||
// so we can't just call launch() and let it handle the setup.
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle());
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_GAMEID, gameFile.getGameId());
|
|
||||||
launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Display the path to the file as the game title in the menu.
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_TITLE, filePaths[0]);
|
|
||||||
|
|
||||||
// Use 00000000 as the game ID. This should match the Desktop version behavior.
|
|
||||||
// TODO: This should really be pulled from the Core.
|
|
||||||
launcher.putExtra(EXTRA_SELECTED_GAMEID, "00000000");
|
|
||||||
|
|
||||||
// GameFile might be a FIFO log. Assume GameCube for the platform. It doesn't really matter
|
|
||||||
// anyway, since this only controls the input, and the FIFO player doesn't take any input.
|
|
||||||
launcher.putExtra(EXTRA_PLATFORM, Platform.GAMECUBE);
|
|
||||||
}
|
|
||||||
|
|
||||||
new AfterDirectoryInitializationRunner().run(activity, true,
|
new AfterDirectoryInitializationRunner().run(activity, true,
|
||||||
() -> activity.startActivity(launcher));
|
() -> activity.startActivity(launcher));
|
||||||
}
|
}
|
||||||
|
@ -272,9 +214,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
// Get params we were passed
|
// Get params we were passed
|
||||||
Intent gameToEmulate = getIntent();
|
Intent gameToEmulate = getIntent();
|
||||||
mPaths = gameToEmulate.getStringArrayExtra(EXTRA_SELECTED_GAMES);
|
mPaths = gameToEmulate.getStringArrayExtra(EXTRA_SELECTED_GAMES);
|
||||||
mSelectedTitle = gameToEmulate.getStringExtra(EXTRA_SELECTED_TITLE);
|
|
||||||
mSelectedGameId = gameToEmulate.getStringExtra(EXTRA_SELECTED_GAMEID);
|
|
||||||
mPlatform = gameToEmulate.getIntExtra(EXTRA_PLATFORM, 0);
|
|
||||||
mIgnoreWarnings = gameToEmulate.getBooleanExtra(EXTRA_IGNORE_WARNINGS, false);
|
mIgnoreWarnings = gameToEmulate.getBooleanExtra(EXTRA_IGNORE_WARNINGS, false);
|
||||||
sUserPausedEmulation = gameToEmulate.getBooleanExtra(EXTRA_USER_PAUSED_EMULATION, false);
|
sUserPausedEmulation = gameToEmulate.getBooleanExtra(EXTRA_USER_PAUSED_EMULATION, false);
|
||||||
activityRecreated = false;
|
activityRecreated = false;
|
||||||
|
@ -293,9 +232,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
|
|
||||||
updateOrientation();
|
updateOrientation();
|
||||||
|
|
||||||
// TODO: The accurate way to find out which console we're emulating is to first
|
|
||||||
// launch emulation and then ask the core which console we're emulating
|
|
||||||
sIsGameCubeGame = Platform.fromNativeInt(mPlatform) == Platform.GAMECUBE;
|
|
||||||
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
||||||
mMotionListener = new MotionListener(this);
|
mMotionListener = new MotionListener(this);
|
||||||
|
|
||||||
|
@ -317,7 +253,8 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(mSelectedTitle);
|
if (NativeLibrary.IsGameMetadataValid())
|
||||||
|
setTitle(NativeLibrary.GetCurrentTitleDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -329,9 +266,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
mEmulationFragment.saveTemporaryState();
|
mEmulationFragment.saveTemporaryState();
|
||||||
}
|
}
|
||||||
outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths);
|
outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths);
|
||||||
outState.putString(EXTRA_SELECTED_TITLE, mSelectedTitle);
|
|
||||||
outState.putString(EXTRA_SELECTED_GAMEID, mSelectedGameId);
|
|
||||||
outState.putInt(EXTRA_PLATFORM, mPlatform);
|
|
||||||
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, mIgnoreWarnings);
|
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, mIgnoreWarnings);
|
||||||
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation);
|
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
@ -340,9 +274,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
protected void restoreState(Bundle savedInstanceState)
|
protected void restoreState(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
mPaths = savedInstanceState.getStringArray(EXTRA_SELECTED_GAMES);
|
mPaths = savedInstanceState.getStringArray(EXTRA_SELECTED_GAMES);
|
||||||
mSelectedTitle = savedInstanceState.getString(EXTRA_SELECTED_TITLE);
|
|
||||||
mSelectedGameId = savedInstanceState.getString(EXTRA_SELECTED_GAMEID);
|
|
||||||
mPlatform = savedInstanceState.getInt(EXTRA_PLATFORM);
|
|
||||||
mIgnoreWarnings = savedInstanceState.getBoolean(EXTRA_IGNORE_WARNINGS);
|
mIgnoreWarnings = savedInstanceState.getBoolean(EXTRA_IGNORE_WARNINGS);
|
||||||
sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION);
|
sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION);
|
||||||
}
|
}
|
||||||
|
@ -361,8 +292,8 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (!sIsGameCubeGame && IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings) != 2)
|
if (NativeLibrary.IsGameMetadataValid())
|
||||||
mMotionListener.enable();
|
updateMotionListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -378,6 +309,23 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onTitleChanged()
|
||||||
|
{
|
||||||
|
setTitle(NativeLibrary.GetCurrentTitleDescription());
|
||||||
|
updateMotionListener();
|
||||||
|
|
||||||
|
if (mDeviceHasTouchScreen)
|
||||||
|
mEmulationFragment.refreshInputOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMotionListener()
|
||||||
|
{
|
||||||
|
if (NativeLibrary.IsEmulatingWii() && IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings) != 2)
|
||||||
|
mMotionListener.enable();
|
||||||
|
else
|
||||||
|
mMotionListener.disable();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy()
|
protected void onDestroy()
|
||||||
{
|
{
|
||||||
|
@ -459,7 +407,7 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
if (!closeMenu())
|
if (!closeMenu())
|
||||||
{
|
{
|
||||||
// Removing the menu failed, so that means it wasn't visible. Add it.
|
// Removing the menu failed, so that means it wasn't visible. Add it.
|
||||||
Fragment fragment = MenuFragment.newInstance(mSelectedTitle);
|
Fragment fragment = MenuFragment.newInstance();
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.setCustomAnimations(
|
.setCustomAnimations(
|
||||||
R.animator.menu_slide_in_from_start,
|
R.animator.menu_slide_in_from_start,
|
||||||
|
@ -478,7 +426,8 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
PopupMenu popup = new PopupMenu(this, anchor);
|
PopupMenu popup = new PopupMenu(this, anchor);
|
||||||
Menu menu = popup.getMenu();
|
Menu menu = popup.getMenu();
|
||||||
|
|
||||||
int id = sIsGameCubeGame ? R.menu.menu_overlay_controls_gc : R.menu.menu_overlay_controls_wii;
|
boolean wii = NativeLibrary.IsEmulatingWii();
|
||||||
|
int id = wii ? R.menu.menu_overlay_controls_wii : R.menu.menu_overlay_controls_gc;
|
||||||
popup.getMenuInflater().inflate(id, menu);
|
popup.getMenuInflater().inflate(id, menu);
|
||||||
|
|
||||||
// Populate the checkbox value for joystick center on touch
|
// Populate the checkbox value for joystick center on touch
|
||||||
|
@ -748,7 +697,7 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
{
|
{
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
|
||||||
builder.setTitle(R.string.emulation_toggle_controls);
|
builder.setTitle(R.string.emulation_toggle_controls);
|
||||||
if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
|
if (!NativeLibrary.IsEmulatingWii() || mPreferences.getInt("wiiController", 3) == 0)
|
||||||
{
|
{
|
||||||
boolean[] gcEnabledButtons = new boolean[11];
|
boolean[] gcEnabledButtons = new boolean[11];
|
||||||
String gcSettingBase = "MAIN_BUTTON_TOGGLE_GC_";
|
String gcSettingBase = "MAIN_BUTTON_TOGGLE_GC_";
|
||||||
|
@ -972,7 +921,7 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
private void setIRSensitivity()
|
private void setIRSensitivity()
|
||||||
{
|
{
|
||||||
// IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
|
// IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
|
||||||
File file = SettingsFile.getCustomGameSettingsFile(mSelectedGameId);
|
File file = SettingsFile.getCustomGameSettingsFile(NativeLibrary.GetCurrentGameID());
|
||||||
IniFile ini = new IniFile(file);
|
IniFile ini = new IniFile(file);
|
||||||
|
|
||||||
int ir_pitch = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, 15);
|
int ir_pitch = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, 15);
|
||||||
|
@ -1214,16 +1163,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSelectedTitle()
|
|
||||||
{
|
|
||||||
return mSelectedTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isGameCubeGame()
|
|
||||||
{
|
|
||||||
return sIsGameCubeGame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActivityRecreated()
|
public boolean isActivityRecreated()
|
||||||
{
|
{
|
||||||
return activityRecreated;
|
return activityRecreated;
|
||||||
|
|
|
@ -138,7 +138,8 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||||
{
|
{
|
||||||
GameViewHolder holder = (GameViewHolder) view.getTag();
|
GameViewHolder holder = (GameViewHolder) view.getTag();
|
||||||
|
|
||||||
EmulationActivity.launch((FragmentActivity) view.getContext(), holder.gameFile);
|
String[] paths = GameFileCacheService.findSecondDiscAndGetPaths(holder.gameFile);
|
||||||
|
EmulationActivity.launch((FragmentActivity) view.getContext(), paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,6 +26,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||||
private View mUnpauseEmulation;
|
private View mUnpauseEmulation;
|
||||||
|
|
||||||
private static final String KEY_TITLE = "title";
|
private static final String KEY_TITLE = "title";
|
||||||
|
private static final String KEY_WII = "wii";
|
||||||
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
|
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -55,12 +56,16 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||||
EmulationActivity.MENU_ACTION_SETTINGS_GRAPHICS);
|
EmulationActivity.MENU_ACTION_SETTINGS_GRAPHICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MenuFragment newInstance(String title)
|
public static MenuFragment newInstance()
|
||||||
{
|
{
|
||||||
MenuFragment fragment = new MenuFragment();
|
MenuFragment fragment = new MenuFragment();
|
||||||
|
|
||||||
Bundle arguments = new Bundle();
|
Bundle arguments = new Bundle();
|
||||||
arguments.putSerializable(KEY_TITLE, title);
|
if (NativeLibrary.IsGameMetadataValid())
|
||||||
|
{
|
||||||
|
arguments.putString(KEY_TITLE, NativeLibrary.GetCurrentTitleDescription());
|
||||||
|
arguments.putBoolean(KEY_WII, NativeLibrary.IsEmulatingWii());
|
||||||
|
}
|
||||||
fragment.setArguments(arguments);
|
fragment.setArguments(arguments);
|
||||||
|
|
||||||
return fragment;
|
return fragment;
|
||||||
|
@ -93,7 +98,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||||
options.findViewById(R.id.menu_overlay_controls).setVisibility(View.GONE);
|
options.findViewById(R.id.menu_overlay_controls).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EmulationActivity.isGameCubeGame())
|
if (!getArguments().getBoolean(KEY_WII, true))
|
||||||
{
|
{
|
||||||
options.findViewById(R.id.menu_refresh_wiimotes).setVisibility(View.GONE);
|
options.findViewById(R.id.menu_refresh_wiimotes).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +136,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||||
rootView.findViewById(R.id.menu_exit).setOnClickListener(this);
|
rootView.findViewById(R.id.menu_exit).setOnClickListener(this);
|
||||||
|
|
||||||
mTitleText = rootView.findViewById(R.id.text_game_title);
|
mTitleText = rootView.findViewById(R.id.text_game_title);
|
||||||
String title = getArguments().getString(KEY_TITLE);
|
String title = getArguments().getString(KEY_TITLE, null);
|
||||||
if (title != null)
|
if (title != null)
|
||||||
{
|
{
|
||||||
mTitleText.setText(title);
|
mTitleText.setText(title);
|
||||||
|
|
|
@ -124,17 +124,20 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||||
if (!mPreferences.getBoolean("OverlayInitV3", false))
|
if (!mPreferences.getBoolean("OverlayInitV3", false))
|
||||||
defaultOverlay();
|
defaultOverlay();
|
||||||
|
|
||||||
// Load the controls.
|
// Load the controls if we can. If not, EmulationActivity has to do it later.
|
||||||
if (NativeLibrary.IsRunning())
|
if (NativeLibrary.IsGameMetadataValid())
|
||||||
{
|
{
|
||||||
// We would've needed a refreshControls call here in addition to the initTouchPointer call
|
if (NativeLibrary.IsRunning())
|
||||||
// if it wasn't for initTouchPointer calling refreshControls.
|
{
|
||||||
initTouchPointer();
|
// We would've needed a refreshControls call here in addition to the initTouchPointer call
|
||||||
}
|
// if it wasn't for initTouchPointer calling refreshControls.
|
||||||
else
|
initTouchPointer();
|
||||||
{
|
}
|
||||||
// We can't call initTouchPointer yet because it needs the aspect ratio of the running game.
|
else
|
||||||
refreshControls();
|
{
|
||||||
|
// We can't call initTouchPointer yet because it needs the aspect ratio of the running game.
|
||||||
|
refreshControls();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the on touch listener.
|
// Set the on touch listener.
|
||||||
|
@ -152,7 +155,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||||
// Refresh before starting the pointer
|
// Refresh before starting the pointer
|
||||||
refreshControls();
|
refreshControls();
|
||||||
|
|
||||||
if (!EmulationActivity.isGameCubeGame())
|
if (!NativeLibrary.IsEmulatingWii())
|
||||||
{
|
{
|
||||||
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal();
|
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal();
|
||||||
|
|
||||||
|
@ -715,7 +718,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||||
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal())
|
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal())
|
||||||
{
|
{
|
||||||
// Add all the enabled overlay items back to the HashSet.
|
// Add all the enabled overlay items back to the HashSet.
|
||||||
if (EmulationActivity.isGameCubeGame())
|
if (!NativeLibrary.IsEmulatingWii())
|
||||||
{
|
{
|
||||||
IniFile dolphinIni = new IniFile(SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN));
|
IniFile dolphinIni = new IniFile(SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN));
|
||||||
|
|
||||||
|
@ -775,7 +778,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||||
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
|
|
||||||
// Values for these come from R.array.controllersEntries
|
// Values for these come from R.array.controllersEntries
|
||||||
if (EmulationActivity.isGameCubeGame() || mPreferences.getInt("wiiController", 3) == 0)
|
if (!NativeLibrary.IsEmulatingWii() || mPreferences.getInt("wiiController", 3) == 0)
|
||||||
{
|
{
|
||||||
if (isLandscape)
|
if (isLandscape)
|
||||||
gcDefaultOverlay();
|
gcDefaultOverlay();
|
||||||
|
|
|
@ -86,6 +86,15 @@ public final class GameFileCacheService extends IntentService
|
||||||
return matchWithoutRevision;
|
return matchWithoutRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] findSecondDiscAndGetPaths(GameFile gameFile)
|
||||||
|
{
|
||||||
|
GameFile secondFile = findSecondDisc(gameFile);
|
||||||
|
if (secondFile == null)
|
||||||
|
return new String[]{gameFile.getPath()};
|
||||||
|
else
|
||||||
|
return new String[]{gameFile.getPath(), secondFile.getPath()};
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasLoadedCache()
|
public static boolean hasLoadedCache()
|
||||||
{
|
{
|
||||||
return hasLoadedCache.get();
|
return hasLoadedCache.get();
|
||||||
|
|
|
@ -201,7 +201,7 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_GAME_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
EmulationActivity.launch(this, FileBrowserHelper.getSelectedFiles(result));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
|
|
|
@ -142,7 +142,8 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||||
TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder;
|
TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder;
|
||||||
|
|
||||||
// Start the emulation activity and send the path of the clicked ISO to it.
|
// Start the emulation activity and send the path of the clicked ISO to it.
|
||||||
EmulationActivity.launch(TvMainActivity.this, holder.gameFile);
|
String[] paths = GameFileCacheService.findSecondDiscAndGetPaths(holder.gameFile);
|
||||||
|
EmulationActivity.launch(TvMainActivity.this, paths);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_GAME_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
EmulationActivity.launch(this, FileBrowserHelper.getSelectedFiles(result));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
|
|
|
@ -48,7 +48,7 @@ public final class StartupHandler
|
||||||
if (start_files != null && start_files.length > 0)
|
if (start_files != null && start_files.length > 0)
|
||||||
{
|
{
|
||||||
// Start the emulation activity, send the ISO passed in and finish the main activity
|
// Start the emulation activity, send the ISO passed in and finish the main activity
|
||||||
EmulationActivity.launchFile(parent, start_files);
|
EmulationActivity.launch(parent, start_files);
|
||||||
parent.finish();
|
parent.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ static JavaVM* s_java_vm;
|
||||||
static jclass s_native_library_class;
|
static jclass s_native_library_class;
|
||||||
static jmethodID s_display_alert_msg;
|
static jmethodID s_display_alert_msg;
|
||||||
static jmethodID s_do_rumble;
|
static jmethodID s_do_rumble;
|
||||||
static jmethodID s_get_update_touch_pointer;
|
static jmethodID s_update_touch_pointer;
|
||||||
|
static jmethodID s_on_title_changed;
|
||||||
|
|
||||||
static jclass s_game_file_class;
|
static jclass s_game_file_class;
|
||||||
static jfieldID s_game_file_pointer;
|
static jfieldID s_game_file_pointer;
|
||||||
|
@ -85,7 +86,12 @@ jmethodID GetDoRumble()
|
||||||
|
|
||||||
jmethodID GetUpdateTouchPointer()
|
jmethodID GetUpdateTouchPointer()
|
||||||
{
|
{
|
||||||
return s_get_update_touch_pointer;
|
return s_update_touch_pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
jmethodID GetOnTitleChanged()
|
||||||
|
{
|
||||||
|
return s_on_title_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetAnalyticsClass()
|
jclass GetAnalyticsClass()
|
||||||
|
@ -212,8 +218,9 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||||
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;ZZ)Z");
|
"(Ljava/lang/String;Ljava/lang/String;ZZ)Z");
|
||||||
s_do_rumble = env->GetStaticMethodID(s_native_library_class, "rumble", "(ID)V");
|
s_do_rumble = env->GetStaticMethodID(s_native_library_class, "rumble", "(ID)V");
|
||||||
s_get_update_touch_pointer =
|
s_update_touch_pointer =
|
||||||
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
||||||
|
s_on_title_changed = env->GetStaticMethodID(s_native_library_class, "onTitleChanged", "()V");
|
||||||
env->DeleteLocalRef(native_library_class);
|
env->DeleteLocalRef(native_library_class);
|
||||||
|
|
||||||
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
||||||
|
|
|
@ -16,6 +16,7 @@ jclass GetNativeLibraryClass();
|
||||||
jmethodID GetDisplayAlertMsg();
|
jmethodID GetDisplayAlertMsg();
|
||||||
jmethodID GetDoRumble();
|
jmethodID GetDoRumble();
|
||||||
jmethodID GetUpdateTouchPointer();
|
jmethodID GetUpdateTouchPointer();
|
||||||
|
jmethodID GetOnTitleChanged();
|
||||||
|
|
||||||
jclass GetAnalyticsClass();
|
jclass GetAnalyticsClass();
|
||||||
jmethodID GetSendAnalyticsReport();
|
jmethodID GetSendAnalyticsReport();
|
||||||
|
|
|
@ -80,6 +80,7 @@ std::mutex s_host_identity_lock;
|
||||||
Common::Event s_update_main_frame_event;
|
Common::Event s_update_main_frame_event;
|
||||||
Common::Event s_emulation_end_event;
|
Common::Event s_emulation_end_event;
|
||||||
bool s_have_wm_user_stop = false;
|
bool s_have_wm_user_stop = false;
|
||||||
|
bool s_game_metadata_is_valid = false;
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
void UpdatePointer()
|
void UpdatePointer()
|
||||||
|
@ -149,6 +150,10 @@ void Host_YieldToUI()
|
||||||
|
|
||||||
void Host_TitleChanged()
|
void Host_TitleChanged()
|
||||||
{
|
{
|
||||||
|
s_game_metadata_is_valid = true;
|
||||||
|
|
||||||
|
JNIEnv* env = IDCache::GetEnvForThread();
|
||||||
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnTitleChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType style)
|
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType style)
|
||||||
|
@ -608,6 +613,7 @@ static void Run(JNIEnv* env, const std::vector<std::string>& paths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_game_metadata_is_valid = false;
|
||||||
Core::Shutdown();
|
Core::Shutdown();
|
||||||
ButtonManager::Shutdown();
|
ButtonManager::Shutdown();
|
||||||
guard.unlock();
|
guard.unlock();
|
||||||
|
@ -752,6 +758,31 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetObscuredP
|
||||||
OSD::SetObscuredPixelsTop(height);
|
OSD::SetObscuredPixelsTop(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_IsGameMetadataValid(JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return s_game_metadata_is_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_IsEmulatingWiiUnchecked(JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return SConfig::GetInstance().bWii;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentGameIDUnchecked(JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(env, SConfig::GetInstance().GetGameID());
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentTitleDescriptionUnchecked(JNIEnv* env,
|
||||||
|
jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(env, SConfig::GetInstance().GetTitleDescription());
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue