android: go back to home screen on back button.refactoring

go back to home screen when back button is pressed in content browwser
fix GL2JNIActivity
refactor GL2JNIActivity and NativeGL2Activity into common base class
This commit is contained in:
Flyinghead 2019-03-13 22:20:03 +01:00
parent 69484e4ae8
commit 4fb1cad6ba
10 changed files with 292 additions and 857 deletions

View File

@ -0,0 +1,217 @@
package com.reicast.emulator;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.TextView;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.debug.GenerateLogs;
import com.reicast.emulator.emu.AudioBackend;
import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.periph.InputDeviceManager;
import com.reicast.emulator.periph.SipEmulator;
import java.util.ArrayList;
import java.util.List;
import tv.ouya.console.api.OuyaController;
public class BaseGLActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
protected View mView;
protected SharedPreferences prefs;
protected float[][] vjoy_d_cached; // Used for VJoy editing
private AudioBackend audioBackend;
private Handler handler = new Handler();
public static byte[] syms;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
Emulator app = (Emulator)getApplicationContext();
app.getConfigurationPrefs();
Emulator.setCurrentActivity(this);
OuyaController.init(this);
String home_directory = prefs.getString(Config.pref_home, "");
String result = JNIdc.initEnvironment((Emulator)getApplicationContext(), home_directory);
if (result != null)
showToastMessage("Initialization failed: " + result, Snackbar.LENGTH_LONG);
String android_home_directory = Environment.getExternalStorageDirectory().getAbsolutePath();
List<String> pathList = new ArrayList<>();
pathList.add(android_home_directory);
pathList.addAll(FileBrowser.getExternalMounts());
Log.i("reicast", "External storage dirs: " + pathList);
JNIdc.setExternalStorageDirectories(pathList.toArray());
InputDeviceManager.getInstance().startListening(getApplicationContext());
register(this);
audioBackend = new AudioBackend();
}
@Override
protected void onDestroy() {
super.onDestroy();
InputDeviceManager.getInstance().stopListening();
register(null);
audioBackend.release();
Emulator.setCurrentActivity(null);
stopEmulator();
}
private boolean showMenu() {
JNIdc.guiOpenSettings();
return true;
}
private boolean processJoystickInput(MotionEvent event, int axis) {
float v = event.getAxisValue(axis);
return InputDeviceManager.getInstance().joystickAxisEvent(event.getDeviceId(), axis, (int)Math.round(v * 32767.f));
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK && event.getAction() == MotionEvent.ACTION_MOVE) {
boolean rc = processJoystickInput(event, MotionEvent.AXIS_X);
rc |= processJoystickInput(event, MotionEvent.AXIS_Y);
rc |= processJoystickInput(event, MotionEvent.AXIS_LTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RX);
rc |= processJoystickInput(event, MotionEvent.AXIS_RY);
if (rc)
return true;
}
else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER)
{
if (mView != null) {
float scl = mView.getHeight() / 480.0f;
float tx = (mView.getWidth() - 640.0f * scl) / 2;
int xpos = Math.round((event.getX() - tx) / scl);
int ypos = Math.round(event.getY() / scl);
InputDeviceManager.getInstance().mouseEvent(xpos, ypos, event.getButtonState());
}
}
return super.onGenericMotionEvent(event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, false))
return true;
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (!JNIdc.guiIsOpen()) {
showMenu();
return true;
}
else if (JNIdc.guiIsContentBrowser()) {
// Only if this is the main activity
//finish();
// so for now we hack it
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
return true;
}
}
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, true))
return true;
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
return super.onKeyDown(keyCode, event);
}
private void showToastMessage(String message, int duration) {
View view = findViewById(android.R.id.content);
Snackbar snackbar = Snackbar.make(view, message, duration);
View snackbarLayout = snackbar.getView();
TextView textView = (TextView) snackbarLayout.findViewById(
android.support.design.R.id.snackbar_text);
textView.setGravity(Gravity.CENTER_VERTICAL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_notification, 0, 0, 0);
textView.setCompoundDrawablePadding(getResources()
.getDimensionPixelOffset(R.dimen.snackbar_icon_padding));
snackbar.show();
}
protected void stopEmulator() {
JNIdc.stop();
}
void requestRecordAudioPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
handler.post(new Runnable() {
@Override
public void run() {
mView.setVisibility(View.INVISIBLE);
ActivityCompat.requestPermissions(BaseGLActivity.this,
new String[]{
Manifest.permission.RECORD_AUDIO
},
0);
}
});
}
else
{
onRequestPermissionsResult(0, new String[] { Manifest.permission.RECORD_AUDIO },
new int[] { PackageManager.PERMISSION_GRANTED });
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissions.length > 0 && Manifest.permission.RECORD_AUDIO .equals(permissions[0]) && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
SipEmulator sip = new SipEmulator();
sip.startRecording();
JNIdc.setupMic(sip);
}
}
// Called from native code
private void generateErrorLog() {
try {
new GenerateLogs(this).execute(getFilesDir().getAbsolutePath());
} catch (RuntimeException e) {
showToastMessage("An error occurred retrieving the log file: " + e.getMessage(), Snackbar.LENGTH_LONG);
}
}
private static native void register(BaseGLActivity activity);
}

View File

@ -1,36 +0,0 @@
package com.reicast.emulator;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.SurfaceHolder;
import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.emu.NativeGLView;
public class BaseNativeGLActivity extends Activity {
protected NativeGLView mView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the actual GL view
// mView = new NativeGLView(this);
// setContentView(mView);
setContentView(R.layout.nativegl_content);
mView = (NativeGLView)findViewById(R.id.glView);
}
@Override
protected void onDestroy() {
super.onDestroy();
stopEmulator();
}
protected void stopEmulator() {
JNIdc.stop();
}
}

View File

@ -1,47 +1,17 @@
package com.reicast.emulator;
import android.Manifest;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.PopupWindow;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.emu.GL2JNIView;
import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.emu.OnScreenMenu;
import com.reicast.emulator.periph.Gamepad;
import com.reicast.emulator.periph.InputDeviceManager;
import com.reicast.emulator.periph.SipEmulator;
import java.util.HashMap;
import tv.ouya.console.api.OuyaController;
public class GL2JNIActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
public GL2JNIView mView;
private SharedPreferences prefs;
private Gamepad pad = new Gamepad();
public static byte[] syms;
import com.reicast.emulator.periph.VJoy;
public class GL2JNIActivity extends BaseGLActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
@Override
protected void onCreate(Bundle icicle) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -51,261 +21,73 @@ public class GL2JNIActivity extends Activity implements ActivityCompat.OnRequest
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
InputDeviceManager.getInstance().startListening(getApplicationContext());
Emulator app = (Emulator)getApplicationContext();
app.getConfigurationPrefs();
pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNIActivity.this, false);
/*
* try { //int rID =
* getResources().getIdentifier("fortyonepost.com.lfas:raw/syms.map",
* null, null); //get the file as a stream InputStream is =
* getResources().openRawResource(R.raw.syms);
*
* syms = new byte[(int) is.available()]; is.read(syms); is.close(); }
* catch (IOException e) { e.getMessage(); e.printStackTrace(); }
*/
String fileName = null;
// Call parent onCreate()
super.onCreate(icicle);
OuyaController.init(this);
// Populate device descriptor-to-player-map from preferences
pad.deviceDescriptor_PlayerNum.put(
prefs.getString(Gamepad.pref_player1, null), 0);
pad.deviceDescriptor_PlayerNum.put(
prefs.getString(Gamepad.pref_player2, null), 1);
pad.deviceDescriptor_PlayerNum.put(
prefs.getString(Gamepad.pref_player3, null), 2);
pad.deviceDescriptor_PlayerNum.put(
prefs.getString(Gamepad.pref_player4, null), 3);
pad.deviceDescriptor_PlayerNum.remove(null);
// JNIdc.initControllers(Emulator.maple_devices, Emulator.maple_expansion_devices);
int joys[] = InputDevice.getDeviceIds();
for (int joy: joys) {
String descriptor;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
descriptor = InputDevice.getDevice(joy).getDescriptor();
} else {
descriptor = InputDevice.getDevice(joy).getName();
}
Log.d("reicast", "InputDevice ID: " + joy);
Log.d("reicast",
"InputDevice Name: "
+ InputDevice.getDevice(joy).getName());
Log.d("reicast", "InputDevice Descriptor: " + descriptor);
pad.deviceId_deviceDescriptor.put(joy, descriptor);
}
boolean detected = false;
for (int joy : joys) {
Integer playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(joy));
if (playerNum != null) {
detected = true;
String id = pad.portId[playerNum];
pad.custom[playerNum] = prefs.getBoolean(Gamepad.pref_js_modified + id, false);
pad.compat[playerNum] = prefs.getBoolean(Gamepad.pref_js_compat + id, false);
pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_merged + id, false);
if (InputDevice.getDevice(joy).getName()
.contains(Gamepad.controllers_gamekey)) {
if (pad.custom[playerNum]) {
pad.setCustomMapping(id, playerNum, prefs);
} else {
pad.map[playerNum] = pad.getConsoleController();
}
} else if (!pad.compat[playerNum]) {
if (pad.custom[playerNum]) {
pad.setCustomMapping(id, playerNum, prefs);
} else if (InputDevice.getDevice(joy).getName()
.equals(Gamepad.controllers_sony)) {
pad.map[playerNum] = pad.getConsoleController();
} else if (InputDevice.getDevice(joy).getName()
.equals(Gamepad.controllers_xbox)) {
pad.map[playerNum] = pad.getConsoleController();
} else if (InputDevice.getDevice(joy).getName()
.contains(Gamepad.controllers_shield)) {
pad.map[playerNum] = pad.getConsoleController();
} else if (InputDevice.getDevice(joy).getName()
.startsWith(Gamepad.controllers_moga)) {
pad.map[playerNum] = pad.getMogaController();
} else { // Ouya controller
pad.map[playerNum] = pad.getOUYAController();
}
} else {
pad.getCompatibilityMap(playerNum, id, prefs);
}
pad.initJoyStickLayout(playerNum);
}
}
if (joys.length == 0 || !detected) {
pad.fullCompatibilityMode(prefs);
}
// Create the actual GLES view
// Create the actual GLES view
mView = new GL2JNIView(GL2JNIActivity.this, false,
prefs.getInt(Config.pref_renderdepth, 24), 8, false);
prefs.getInt(Config.pref_renderdepth, 24), 8);
setContentView(mView);
//setup mic
if (Emulator.micPluggedIn()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ActivityCompat.requestPermissions(this,
new String[]{
Manifest.permission.RECORD_AUDIO
},
0);
}
else
{
onRequestPermissionsResult(0, new String[] { Manifest.permission.RECORD_AUDIO }, new int[] { PackageManager.PERMISSION_GRANTED });
}
}
}
public Gamepad getPad() {
return pad;
if (Emulator.micPluggedIn())
requestRecordAudioPermission();
}
public void screenGrab() {
mView.screenGrab();
}
public void displayPopUp(PopupWindow popUp) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayConfig(PopupWindow popUpConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpConfig.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayDebug(PopupWindow popUpDebug) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpDebug.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
private boolean showMenu() {
JNIdc.guiOpenSettings();
return true;
}
private boolean processJoystickInput(MotionEvent event, int axis) {
float v = event.getAxisValue(axis);
return InputDeviceManager.getInstance().joystickAxisEvent(event.getDeviceId(), axis, (int)Math.round(v * 32767.f));
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK && event.getAction() == MotionEvent.ACTION_MOVE) {
boolean rc = processJoystickInput(event, MotionEvent.AXIS_X);
rc |= processJoystickInput(event, MotionEvent.AXIS_Y);
rc |= processJoystickInput(event, MotionEvent.AXIS_LTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RX);
rc |= processJoystickInput(event, MotionEvent.AXIS_RY);
if (rc)
return true;
}
else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER)
{
if (mView != null) {
float scl = mView.getHeight() / 480.0f;
float tx = (mView.getWidth() - 640.0f * scl) / 2;
int xpos = Math.round((event.getX() - tx) / scl);
int ypos = Math.round(event.getY() / scl);
InputDeviceManager.getInstance().mouseEvent(xpos, ypos, event.getButtonState());
}
}
return super.onGenericMotionEvent(event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, false))
return true;
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// FIXME
showMenu();
}
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, true))
return true;
if (keyCode == pad.getSelectButtonCode()) {
return showMenu();
}
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
return super.onKeyDown(keyCode, event);
((GL2JNIView)mView).screenGrab();
}
@Override
protected void onPause() {
super.onPause();
mView.onPause();
((GL2JNIView)mView).onPause();
JNIdc.pause();
}
@Override
protected void onDestroy() {
super.onDestroy();
InputDeviceManager.getInstance().stopListening();
if (mView != null) {
mView.onDestroy();
JNIdc.destroy();
((GL2JNIView)mView).onDestroy();
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
protected void onResume() {
super.onResume();
mView.onResume();
((GL2JNIView)mView).onResume();
JNIdc.resume();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissions.length > 0 && Manifest.permission.RECORD_AUDIO .equals(permissions[0]) && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
SipEmulator sip = new SipEmulator();
sip.startRecording();
JNIdc.setupMic(sip);
}
// Called from native code
private void VJoyStartEditing() {
vjoy_d_cached = VJoy.readCustomVjoyValues(getApplicationContext());
JNIdc.show_osd();
((GL2JNIView)mView).setEditVjoyMode(true);
}
// Called from native code
private void VJoyResetEditing() {
VJoy.resetCustomVjoyValues(getApplicationContext());
((GL2JNIView)mView).readCustomVjoyValues();
((GL2JNIView)mView).resetEditMode();
runOnUiThread(new Runnable() {
@Override
public void run() {
mView.requestLayout();
}
});
}
// Called from native code
private void VJoyStopEditing(final boolean canceled) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (canceled)
((GL2JNIView)mView).restoreCustomVjoyValues(vjoy_d_cached);
((GL2JNIView)mView).setEditVjoyMode(false);
}
});
}
}

View File

@ -156,7 +156,7 @@ public class MainActivity extends AppCompatActivity {
if (gameUri != null)
JNIdc.setGameUri(gameUri.toString());
Intent intent = new Intent("com.reicast.EMULATOR",
// uri, getApplicationContext(), GL2JNIActivity.class);
//gameUri, getApplicationContext(), GL2JNIActivity.class);
gameUri, getApplicationContext(), NativeGLActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

View File

@ -1,235 +1,61 @@
package com.reicast.emulator;
import android.Manifest;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.debug.GenerateLogs;
import com.reicast.emulator.emu.AudioBackend;
import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.periph.InputDeviceManager;
import com.reicast.emulator.periph.SipEmulator;
import com.reicast.emulator.emu.NativeGLView;
import com.reicast.emulator.periph.VJoy;
import java.util.ArrayList;
import java.util.List;
import tv.ouya.console.api.OuyaController;
public final class NativeGLActivity extends BaseNativeGLActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
public static byte[] syms;
private float[][] vjoy_d_cached; // Used for VJoy editing
private AudioBackend audioBackend;
private Handler handler = new Handler();
public final class NativeGLActivity extends BaseGLActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
InputDeviceManager.getInstance().startListening(getApplicationContext());
Emulator app = (Emulator)getApplicationContext();
app.getConfigurationPrefs();
Emulator.setCurrentActivity(this);
OuyaController.init(this);
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String home_directory = prefs.getString(Config.pref_home, "");
String result = JNIdc.initEnvironment((Emulator)getApplicationContext(), home_directory);
if (result != null)
showToastMessage("Initialization failed: " + result, Snackbar.LENGTH_LONG);
String android_home_directory = Environment.getExternalStorageDirectory().getAbsolutePath();
List<String> pathList = new ArrayList<>();
pathList.add(android_home_directory);
pathList.addAll(FileBrowser.getExternalMounts());
Log.i("reicast", "External storage dirs: " + pathList);
JNIdc.setExternalStorageDirectories(pathList.toArray());
register(this);
audioBackend = new AudioBackend();
// Create the actual GL view
// mView = new NativeGLView(this);
// setContentView(mView);
setContentView(R.layout.nativegl_content);
mView = findViewById(R.id.glView);
//setup mic
if (Emulator.micPluggedIn())
requestRecordAudioPermission();
}
private boolean showMenu() {
JNIdc.guiOpenSettings();
return true;
}
private boolean processJoystickInput(MotionEvent event, int axis) {
float v = event.getAxisValue(axis);
return InputDeviceManager.getInstance().joystickAxisEvent(event.getDeviceId(), axis, (int)Math.round(v * 32767.f));
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK && event.getAction() == MotionEvent.ACTION_MOVE) {
boolean rc = processJoystickInput(event, MotionEvent.AXIS_X);
rc |= processJoystickInput(event, MotionEvent.AXIS_Y);
rc |= processJoystickInput(event, MotionEvent.AXIS_LTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RTRIGGER);
rc |= processJoystickInput(event, MotionEvent.AXIS_RX);
rc |= processJoystickInput(event, MotionEvent.AXIS_RY);
if (rc)
return true;
}
else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER)
{
if (mView != null) {
float scl = mView.getHeight() / 480.0f;
float tx = (mView.getWidth() - 640.0f * scl) / 2;
int xpos = Math.round((event.getX() - tx) / scl);
int ypos = Math.round(event.getY() / scl);
InputDeviceManager.getInstance().mouseEvent(xpos, ypos, event.getButtonState());
}
}
return super.onGenericMotionEvent(event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, false))
return true;
return super.onKeyUp(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// FIXME
showMenu();
}
if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, true))
return true;
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onPause() {
super.onPause();
mView.pause();
((NativeGLView)mView).pause();
}
@Override
protected void onResume() {
super.onResume();
mView.resume();
}
@Override
protected void onDestroy() {
super.onDestroy();
InputDeviceManager.getInstance().stopListening();
register(null);
audioBackend.release();
Emulator.setCurrentActivity(null);
}
void requestRecordAudioPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
handler.post(new Runnable() {
@Override
public void run() {
mView.setVisibility(View.INVISIBLE);
ActivityCompat.requestPermissions(NativeGLActivity.this,
new String[]{
Manifest.permission.RECORD_AUDIO
},
0);
}
});
}
else
{
onRequestPermissionsResult(0, new String[] { Manifest.permission.RECORD_AUDIO },
new int[] { PackageManager.PERMISSION_GRANTED });
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissions.length > 0 && Manifest.permission.RECORD_AUDIO .equals(permissions[0]) && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
SipEmulator sip = new SipEmulator();
sip.startRecording();
JNIdc.setupMic(sip);
}
mView.setVisibility(View.VISIBLE);
}
private void showToastMessage(String message, int duration) {
View view = findViewById(android.R.id.content);
Snackbar snackbar = Snackbar.make(view, message, duration);
View snackbarLayout = snackbar.getView();
TextView textView = (TextView) snackbarLayout.findViewById(
android.support.design.R.id.snackbar_text);
textView.setGravity(Gravity.CENTER_VERTICAL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_notification, 0, 0, 0);
textView.setCompoundDrawablePadding(getResources()
.getDimensionPixelOffset(R.dimen.snackbar_icon_padding));
snackbar.show();
((NativeGLView)mView).resume();
}
// Called from native code
private void VJoyStartEditing() {
vjoy_d_cached = VJoy.readCustomVjoyValues(getApplicationContext());
JNIdc.show_osd();
mView.setEditVjoyMode(true);
((NativeGLView)mView).setEditVjoyMode(true);
}
// Called from native code
private void VJoyResetEditing() {
VJoy.resetCustomVjoyValues(getApplicationContext());
mView.readCustomVjoyValues();
mView.resetEditMode();
((NativeGLView)mView).readCustomVjoyValues();
((NativeGLView)mView).resetEditMode();
mView.requestLayout();
}
// Called from native code
private void VJoyStopEditing(boolean canceled) {
if (canceled)
mView.restoreCustomVjoyValues(vjoy_d_cached);
mView.setEditVjoyMode(false);
((NativeGLView)mView).restoreCustomVjoyValues(vjoy_d_cached);
((NativeGLView)mView).setEditVjoyMode(false);
}
// Called from native code
private void generateErrorLog() {
new GenerateLogs(this).execute(getFilesDir().getAbsolutePath());
}
private static native void register(NativeGLActivity activity);
}

View File

@ -205,7 +205,6 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
@Override
protected void onPostExecute(final String response) {
if (response != null) {
showToastMessage(mContext.get().getString(R.string.log_saved), Snackbar.LENGTH_LONG);
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mContext.get()
.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("logcat", response);
@ -214,34 +213,4 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
mContext.get().startActivity(browserIntent);
}
}
private void showToastMessage(String message, int duration) {
View layout =
((Activity) mContext.get()).findViewById(android.R.id.content);
Snackbar snackbar = Snackbar.make(layout, message, duration);
View snackbarLayout = snackbar.getView();
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT
);
lp.setMargins(0, 0, 0, 0);
snackbarLayout.setLayoutParams(lp);
TextView textView = (TextView) snackbarLayout.findViewById(
android.support.design.R.id.snackbar_text);
textView.setGravity(Gravity.CENTER_VERTICAL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
Drawable drawable;
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
drawable = mContext.get().getResources().getDrawable(
R.drawable.ic_send, ((Activity) mContext.get()).getTheme());
} else {
drawable = VectorDrawableCompat.create(mContext.get().getResources(),
R.drawable.ic_send, ((Activity) mContext.get()).getTheme());
}
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
textView.setCompoundDrawablePadding(mContext.get().getResources()
.getDimensionPixelOffset(R.dimen.snackbar_icon_padding));
snackbar.show();
}
}

View File

@ -61,29 +61,16 @@ public class GL2JNIView extends GLSurfaceView
public static final int LAYER_TYPE_SOFTWARE = 1;
public static final int LAYER_TYPE_HARDWARE = 2;
private Handler handler = new Handler();
Vibrator vib;
private boolean editVjoyMode = false;
private int selectedVjoyElement = -1;
private ScaleGestureDetector scaleGestureDetector;
public float[][] vjoy_d_custom;
private static final float[][] vjoy = VJoy.baseVJoy();
VirtualJoystickDelegate vjoyDelegate;
Renderer rend;
Context context;
public void restoreCustomVjoyValues(float[][] vjoy_d_cached) {
vjoy_d_custom = vjoy_d_cached;
VJoy.writeCustomVjoyValues(vjoy_d_cached, context);
resetEditMode();
requestLayout();
vjoyDelegate.restoreCustomVjoyValues(vjoy_d_cached);
}
public GL2JNIView(Context context) {
@ -96,10 +83,9 @@ public class GL2JNIView extends GLSurfaceView
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public GL2JNIView(final Context context, boolean translucent,
int depth, int stencil, boolean editVjoyMode) {
int depth, int stencil) {
super(context);
this.context = context;
this.editVjoyMode = editVjoyMode;
setKeepScreenOn(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@ -115,11 +101,10 @@ public class GL2JNIView extends GLSurfaceView
}
});
}
vjoyDelegate = new VirtualJoystickDelegate(this);
setPreserveEGLContextOnPause(true);
vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
DisplayMetrics dm = context.getResources().getDisplayMetrics();
@ -127,10 +112,6 @@ public class GL2JNIView extends GLSurfaceView
this.setLayerType(prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE), null);
vjoy_d_custom = VJoy.readCustomVjoyValues(context);
scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener());
if (GL2JNIActivity.syms != null)
JNIdc.data(1, GL2JNIActivity.syms);
@ -163,338 +144,29 @@ public class GL2JNIView extends GLSurfaceView
return rend;
}
private void reset_analog()
{
int j=11;
vjoy[j+1][0]=vjoy[j][0]+vjoy[j][2]/2-vjoy[j+1][2]/2;
vjoy[j+1][1]=vjoy[j][1]+vjoy[j][3]/2-vjoy[j+1][3]/2;
JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1], vjoy[j+1][2], vjoy[j+1][3]);
}
int get_anal(int j, int axis)
{
return (int) (((vjoy[j+1][axis]+vjoy[j+1][axis+2]/2) - vjoy[j][axis] - vjoy[j][axis+2]/2)*254/vjoy[j][axis+2]);
}
float vbase(float p, float m, float scl)
{
return (int) ( m - (m -p)*scl);
}
float vbase(float p, float scl)
{
return (int) (p*scl );
}
public boolean isTablet() {
return (getContext().getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
super.onLayout(changed, left, top, right, bottom);
//dcpx/cm = dcpx/px * px/cm
float magic = isTablet() ? 0.8f : 0.7f;
float scl = 480.0f/getHeight() * getContext().getResources().getDisplayMetrics().density * magic;
float scl_dc = getHeight()/480.0f;
float tx = ((getWidth()-640.0f*scl_dc)/2)/scl_dc;
float a_x = -tx+ 24*scl;
float a_y=- 24*scl;
float[][] vjoy_d = VJoy.getVjoy_d(vjoy_d_custom);
for (int i=0;i<vjoy.length;i++)
{
if (vjoy_d[i][0] == 288)
vjoy[i][0] = vjoy_d[i][0];
else if (vjoy_d[i][0]-vjoy_d_custom[getElementIdFromButtonId(i)][0] < 320)
vjoy[i][0] = a_x + vbase(vjoy_d[i][0],scl);
else
vjoy[i][0] = -a_x + vbase(vjoy_d[i][0],640,scl);
vjoy[i][1] = a_y + vbase(vjoy_d[i][1],480,scl);
vjoy[i][2] = vbase(vjoy_d[i][2],scl);
vjoy[i][3] = vbase(vjoy_d[i][3],scl);
}
for (int i=0;i<VJoy.VJoyCount;i++)
JNIdc.vjoy(i,vjoy[i][0],vjoy[i][1],vjoy[i][2],vjoy[i][3]);
reset_analog();
VJoy.writeCustomVjoyValues(vjoy_d_custom, context);
vjoyDelegate.layout(getWidth(), getHeight());
}
int anal_id=-1, lt_id=-1, rt_id=-1;
public void resetEditMode() {
editLastX = 0;
editLastY = 0;
vjoyDelegate.resetEditMode();
}
private static int getElementIdFromButtonId(int buttonId) {
if (buttonId <= 3)
return 0; // DPAD
else if (buttonId <= 7)
return 1; // X, Y, B, A Buttons
else if (buttonId == 8)
return 2; // Start
else if (buttonId == 9)
return 3; // Left Trigger
else if (buttonId == 10)
return 4; // Right Trigger
else if (buttonId <= 12)
return 5; // Analog
else
return 0; // DPAD diagonials
}
public static int left_trigger = 0;
public static int right_trigger = 0;
public static int[] mouse_pos = { -32768, -32768 };
public static int mouse_btns = 0;
float editLastX = 0, editLastY = 0;
@Override public boolean onTouchEvent(final MotionEvent event)
{
if (event.getSource() != InputDevice.SOURCE_TOUCHSCREEN)
// Ignore real mice, trackballs, etc.
return false;
JNIdc.show_osd();
scaleGestureDetector.onTouchEvent(event);
float ty = 0.0f;
float scl = getHeight()/480.0f;
float tx = (getWidth()-640.0f*scl)/2;
int rv = 0xFFFF;
int aid = event.getActionMasked();
int pid = event.getActionIndex();
if (!JNIdc.guiIsOpen()) {
if (editVjoyMode && selectedVjoyElement != -1 && aid == MotionEvent.ACTION_MOVE && !scaleGestureDetector.isInProgress()) {
float x = (event.getX() - tx) / scl;
float y = (event.getY() - ty) / scl;
if (editLastX != 0 && editLastY != 0) {
float deltaX = x - editLastX;
float deltaY = y - editLastY;
vjoy_d_custom[selectedVjoyElement][0] += isTablet() ? deltaX * 2 : deltaX;
vjoy_d_custom[selectedVjoyElement][1] += isTablet() ? deltaY * 2 : deltaY;
requestLayout();
}
editLastX = x;
editLastY = y;
return true;
}
for (int i = 0; i < event.getPointerCount(); i++) {
float x = (event.getX(i) - tx) / scl;
float y = (event.getY(i) - ty) / scl;
if (anal_id != event.getPointerId(i)) {
if (aid == MotionEvent.ACTION_POINTER_UP && pid == i)
continue;
for (int j = 0; j < vjoy.length; j++) {
if (x > vjoy[j][0] && x <= (vjoy[j][0] + vjoy[j][2])) {
/*
//Disable pressure sensitive R/L
//Doesn't really work properly
int pre=(int)(event.getPressure(i)*255);
if (pre>20)
{
pre-=20;
pre*=7;
}
if (pre>255) pre=255;
*/
int pre = 255;
if (y > vjoy[j][1] && y <= (vjoy[j][1] + vjoy[j][3])) {
if (vjoy[j][4] >= -2) {
if (vjoy[j][5] == 0)
if (!editVjoyMode && Emulator.vibrationDuration > 0)
vib.vibrate(Emulator.vibrationDuration);
vjoy[j][5] = 2;
}
if (vjoy[j][4] == -3) {
if (editVjoyMode) {
selectedVjoyElement = 5; // Analog
resetEditMode();
} else {
vjoy[j + 1][0] = x - vjoy[j + 1][2] / 2;
vjoy[j + 1][1] = y - vjoy[j + 1][3] / 2;
JNIdc.vjoy(j + 1, vjoy[j + 1][0], vjoy[j + 1][1], vjoy[j + 1][2], vjoy[j + 1][3]);
anal_id = event.getPointerId(i);
}
} else if (vjoy[j][4] != -4) {
if (vjoy[j][4] == -1) {
if (editVjoyMode) {
selectedVjoyElement = 3; // Left Trigger
resetEditMode();
} else {
left_trigger = pre;
lt_id = event.getPointerId(i);
}
} else if (vjoy[j][4] == -2) {
if (editVjoyMode) {
selectedVjoyElement = 4; // Right Trigger
resetEditMode();
} else {
right_trigger = pre;
rt_id = event.getPointerId(i);
}
} else {
if (editVjoyMode) {
selectedVjoyElement = getElementIdFromButtonId(j);
resetEditMode();
} else
rv &= ~(int) vjoy[j][4];
}
}
}
}
}
} else {
if (x < vjoy[11][0])
x = vjoy[11][0];
else if (x > (vjoy[11][0] + vjoy[11][2]))
x = vjoy[11][0] + vjoy[11][2];
if (y < vjoy[11][1])
y = vjoy[11][1];
else if (y > (vjoy[11][1] + vjoy[11][3]))
y = vjoy[11][1] + vjoy[11][3];
int j = 11;
vjoy[j + 1][0] = x - vjoy[j + 1][2] / 2;
vjoy[j + 1][1] = y - vjoy[j + 1][3] / 2;
JNIdc.vjoy(j + 1, vjoy[j + 1][0], vjoy[j + 1][1], vjoy[j + 1][2], vjoy[j + 1][3]);
}
}
for (int j = 0; j < vjoy.length; j++) {
if (vjoy[j][5] == 2)
vjoy[j][5] = 1;
else if (vjoy[j][5] == 1)
vjoy[j][5] = 0;
}
}
switch(aid)
{
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
selectedVjoyElement = -1;
reset_analog();
anal_id = -1;
rv = 0xFFFF;
right_trigger = 0;
left_trigger = 0;
lt_id = -1;
rt_id = -1;
for (int j= 0 ;j < vjoy.length; j++)
vjoy[j][5] = 0;
mouse_btns = 0;
break;
case MotionEvent.ACTION_POINTER_UP:
if (event.getPointerId(event.getActionIndex())==anal_id)
{
reset_analog();
anal_id = -1;
}
else if (event.getPointerId(event.getActionIndex())==lt_id)
{
left_trigger = 0;
lt_id = -1;
}
else if (event.getPointerId(event.getActionIndex())==rt_id)
{
right_trigger = 0;
rt_id = -1;
}
break;
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
if (event.getPointerCount() != 1)
{
mouse_btns = 0;
}
else
{
MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
event.getPointerCoords(0, pointerCoords);
mouse_pos[0] = Math.round((pointerCoords.x - tx) / scl);
mouse_pos[1] = Math.round(pointerCoords.y / scl);
mouse_btns = MotionEvent.BUTTON_PRIMARY; // Mouse left button down
}
break;
case MotionEvent.ACTION_MOVE:
if (event.getPointerCount() == 1)
{
MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
event.getPointerCoords(0, pointerCoords);
mouse_pos[0] = Math.round((pointerCoords.x - tx) / scl);
mouse_pos[1] = Math.round(pointerCoords.y / scl);
}
break;
}
if (getResources().getString(R.string.flavor).equals("naomi")) // FIXME
{
if (left_trigger != 0)
rv &= ~VJoy.key_CONT_C; // Service key/coin
}
int joyx = get_anal(11, 0);
int joyy = get_anal(11, 1);
InputDeviceManager.getInstance().virtualGamepadEvent(rv, joyx, joyy, left_trigger, right_trigger);
// Only register the mouse event if no virtual gamepad button is down
if ((!editVjoyMode && rv == 0xFFFF) || JNIdc.guiIsOpen())
InputDeviceManager.getInstance().mouseEvent(mouse_pos[0], mouse_pos[1], mouse_btns);
return(true);
return vjoyDelegate.onTouchEvent(event, getWidth(), getHeight());
}
private class OscOnScaleGestureListener extends
SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (editVjoyMode && selectedVjoyElement != -1) {
vjoy_d_custom[selectedVjoyElement][2] *= detector.getScaleFactor();
requestLayout();
return true;
}
return false;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
selectedVjoyElement = -1;
}
public void setEditVjoyMode(boolean editVjoyMode) {
vjoyDelegate.setEditVjoyMode(editVjoyMode);
}
public void readCustomVjoyValues() {
vjoyDelegate.readCustomVjoyValues();
}
private static class Renderer implements GLSurfaceView.Renderer
{

View File

@ -39,6 +39,7 @@ public final class JNIdc
public static native void screenDpi(int screenDpi);
public static native void guiOpenSettings();
public static native boolean guiIsOpen();
public static native boolean guiIsContentBrowser();
public static void show_osd() {
JNIdc.vjoy(13, 1,0,0,0);

View File

@ -67,7 +67,6 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback
private void startRendering() {
// Continuously render frames
//Log.i("reicast", "NativeGLView.startRendering in 500 ms");
handler.removeCallbacksAndMessages(null);
handler.postAtTime(new Runnable() {
@Override
@ -113,7 +112,6 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.i("reicast", "NativeGLView.surfaceDestroyed");
JNIdc.rendinitNative(null, 0, 0);
paused = true;
}
public void pause() {
@ -127,8 +125,8 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback
//Log.i("reicast", "NativeGLView.resume");
paused = false;
JNIdc.resume();
startRendering();
}
startRendering();
}
@TargetApi(19)

View File

@ -109,6 +109,7 @@ SETTINGS_ACCESSORS(VirtualGamepadVibration, input.VirtualGamepadVibration, jint)
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_screenDpi(JNIEnv *env,jobject obj, jint screenDpi) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_guiOpenSettings(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsOpen(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsContentBrowser(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_init(JNIEnv *env, jobject obj) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickAdded(JNIEnv *env, jobject obj, jint id, jstring name, jint maple_port) __attribute__((visibility("default")));
@ -120,7 +121,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_mouse
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_AudioBackend_setInstance(JNIEnv *env, jobject obj, jobject instance) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_NativeGLActivity_register(JNIEnv *env, jobject obj, jobject activity) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_BaseGLActivity_register(JNIEnv *env, jobject obj, jobject activity) __attribute__((visibility("default")));
};
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_screenDpi(JNIEnv *env,jobject obj, jint screenDpi)
@ -511,6 +512,11 @@ JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsOpen(JNIEnv
return gui_is_open();
}
JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsContentBrowser(JNIEnv *env,jobject obj)
{
return gui_is_content_browser();
}
// Audio Stuff
u32 androidaudio_push(void* frame, u32 amt, bool wait)
{
@ -678,7 +684,7 @@ static jmethodID VJoyStartEditingMID;
static jmethodID VJoyStopEditingMID;
static jmethodID VJoyResetEditingMID;
JNIEXPORT void JNICALL Java_com_reicast_emulator_NativeGLActivity_register(JNIEnv *env, jobject obj, jobject activity)
JNIEXPORT void JNICALL Java_com_reicast_emulator_BaseGLActivity_register(JNIEnv *env, jobject obj, jobject activity)
{
if (g_activity != NULL)
{