Adds two new parameters that can be passed to the Android version of Retroarch at launch:

QUITFOCUS
If enabled this will cause Retroarch to quit completely when it loses focus (eg. when the home button is pressed). This is useful when you are using an alternative launcher such as Kodi because it will make the home button function as an alternative quit key, return to the alternative launcher, and then allow for a different game to start instead of returning to the current session.

HIDEMOUSE
Normally it is not possible to hide the mouse cursor if you have attached an external mouse to your Android unit. This makes it difficult to implement mouse support in the Android version of Retroarch because you will end up having two mouse cursors on the screen. NVIDIA has implemented extensions on the SHIELD that allows for hiding the mouse cursor. If this parameter is provided when starting Retroarch it will check for these extensions and if available it will hide the mouse cursor.

(I am almost done with adding mouse support to the Android input driver and will be submitting a suggestion for this very soon)
This commit is contained in:
Diablodiab 2017-02-12 13:26:18 +01:00
parent 66ff3db2e2
commit 77e479a8bc

View File

@ -3,9 +3,16 @@ package com.retroarch.browser.retroactivity;
import android.view.View;
import android.view.WindowManager;
import android.content.Intent;
import android.content.Context;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.hardware.input.InputManager;
public final class RetroActivityFuture extends RetroActivityCamera {
// If set to true then Retroarch will completely exit when it loses focus
private boolean quitfocus = false;
@Override
public void onResume() {
super.onResume();
@ -28,7 +35,7 @@ public final class RetroActivityFuture extends RetroActivityCamera {
| API_SYSTEM_UI_FLAG_FULLSCREEN
| API_SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// Check for REFRESH parameter
// Check for Android UI specific parameters
Intent retro = getIntent();
String refresh = retro.getStringExtra("REFRESH");
@ -38,7 +45,40 @@ public final class RetroActivityFuture extends RetroActivityCamera {
params.preferredRefreshRate = Integer.parseInt(refresh);
getWindow().setAttributes(params);
}
// If QUITFOCUS parameter is provided then enable that Retroarch quits when focus is lost
quitfocus = retro.hasExtra("QUITFOCUS");
// If HIDEMOUSE parameters is provided then hide the mourse cursor
// This requires NVIDIA Android extensions (available on NVIDIA Shield), if they are not
// available then nothing will be done
if (retro.hasExtra("HIDEMOUSE")) hideMouseCursor();
}
}
public void hideMouseCursor() {
// Check for NVIDIA extensions and minimum SDK version
Method mInputManager_setCursorVisibility;
try { mInputManager_setCursorVisibility =
InputManager.class.getMethod("setCursorVisibility", boolean.class);
}
catch (NoSuchMethodException ex) {
return; // Extensions were not available so do nothing
}
// Hide the mouse cursor
InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
try { mInputManager_setCursorVisibility.invoke(inputManager, false); }
catch (InvocationTargetException ite) { }
catch (IllegalAccessException iae) { }
}
@Override
public void onStop() {
super.onStop();
// If QUITFOCUS parameter was set then completely exit Retroarch when focus is lost
if (quitfocus) System.exit(0);
}
}