Remove GL2JNINative (deprecated Xperia Play compat)

Saying it only works with a very small set of hardware is no different than saying "please try this with everything and tell me when it doesn't work"
This commit is contained in:
Ender's Games 2018-09-27 02:49:22 -04:00
parent cc217e944f
commit 81c98768e5
20 changed files with 10 additions and 1042 deletions

View File

@ -100,12 +100,6 @@
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name=".GL2JNINative"
android:configChanges="orientation|navigation|screenSize|screenLayout|uiMode|keyboard|keyboardHidden"
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:configChanges="orientation|keyboard"

View File

@ -10,7 +10,6 @@ import com.reicast.emulator.emu.JNIdc;
public class Emulator extends Application {
public static final String pref_nativeact = "enable_native";
public static final String pref_dynarecopt = "dynarec_opt";
public static final String pref_unstable = "unstable_opt";
public static final String pref_dynsafemode = "dyn_safemode";
@ -47,7 +46,6 @@ public class Emulator extends Application {
public static boolean modvols = true;
public static String bootdisk = null;
public static boolean usereios = false;
public static boolean nativeact = false;
/**
* Load the user configuration from preferences
@ -68,7 +66,6 @@ public class Emulator extends Application {
Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
Emulator.bootdisk = mPrefs.getString(pref_bootdisk, bootdisk);
Emulator.usereios = mPrefs.getBoolean(pref_usereios, usereios);
Emulator.nativeact = mPrefs.getBoolean(pref_nativeact, nativeact);
}
/**

View File

@ -1,561 +0,0 @@
package com.reicast.emulator;
import android.annotation.SuppressLint;
import android.app.NativeActivity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
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 android.widget.Toast;
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.emu.OnScreenMenu.FpsPopup;
import com.reicast.emulator.emu.OnScreenMenu.MainPopup;
import com.reicast.emulator.emu.OnScreenMenu.VmuPopup;
import com.reicast.emulator.periph.Gamepad;
import com.reicast.emulator.periph.SipEmulator;
import java.util.Arrays;
import java.util.HashMap;
import tv.ouya.console.api.OuyaController;
public class GL2JNINative extends NativeActivity {
public GL2JNIView mView;
OnScreenMenu menu;
public MainPopup popUp;
VmuPopup vmuPop;
FpsPopup fpsPop;
private SharedPreferences prefs;
private Gamepad pad = new Gamepad();
public static byte[] syms;
static {
System.loadLibrary("sexplay");
}
native int RegisterNative(boolean touchpad);
@Override
protected void onCreate(Bundle icicle) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getInt(Config.pref_rendertype, 2) == 2) {
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
getWindow().takeSurface(null);
pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNINative.this, false);
// isNvidiaShield = Gamepad.IsNvidiaShield();
RegisterNative(false);
Emulator app = (Emulator)getApplicationContext();
app.getConfigurationPrefs(prefs);
menu = new OnScreenMenu(GL2JNINative.this, prefs);
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);
boolean player2connected = false;
boolean player3connected = false;
boolean player4connected = false;
int p1periphs[] = {
1, // Hardcoded VMU
prefs.getBoolean(Gamepad.pref_mic, false) ? 2 : 1
};
int p2periphs[] = {
prefs.getInt(Gamepad.p2_peripheral + 1, 0),
prefs.getInt(Gamepad.p2_peripheral + 2, 0)
};
int p3periphs[] = {
prefs.getInt(Gamepad.p3_peripheral + 1, 0),
prefs.getInt(Gamepad.p3_peripheral + 2, 0)
};
int p4periphs[] = {
prefs.getInt(Gamepad.p4_peripheral + 1, 0),
prefs.getInt(Gamepad.p4_peripheral + 2, 0)
};
for (HashMap.Entry<String, Integer> e : pad.deviceDescriptor_PlayerNum
.entrySet()) {
String descriptor = e.getKey();
Integer playerNum = e.getValue();
switch (playerNum) {
case 1:
if (descriptor != null)
player2connected = true;
break;
case 2:
if (descriptor != null)
player3connected = true;
break;
case 3:
if (descriptor != null)
player4connected = true;
break;
}
}
JNIdc.initControllers(
new boolean[] { player2connected, player3connected, player4connected },
new int[][] { p1periphs, p2periphs, p3periphs, p4periphs });
int joys[] = InputDevice.getDeviceIds();
for (int joy : joys) {
String descriptor = InputDevice.getDevice(joy).getDescriptor();
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)) {
new Handler().post(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(),
R.string.controller_unavailable,
Toast.LENGTH_SHORT).show();
finish();
}
});
} 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);
pad.playerNumX.put(joy, playerNum);
}
}
if (joys.length == 0 || !detected) {
pad.fullCompatibilityMode(prefs);
}
app.loadConfigurationPrefs();
// When viewing a resource, pass its URI to the native code for opening
if (getIntent().getAction().equals("com.reicast.EMULATOR"))
fileName = Uri.decode(getIntent().getData().toString());
// Create the actual GLES view
mView = new GL2JNIView(GL2JNINative.this, fileName, false,
prefs.getInt(Config.pref_renderdepth, 24), 0, false);
setContentView(mView);
//setup mic
boolean micPluggedIn = prefs.getBoolean(Gamepad.pref_mic, false);
if(micPluggedIn){
SipEmulator sip = new SipEmulator();
sip.startRecording();
JNIdc.setupMic(sip);
}
popUp = menu.new MainPopup(this);
vmuPop = menu.new VmuPopup(this);
if(prefs.getBoolean(Config.pref_vmu, false)){
//kind of a hack - if the user last had the vmu on screen
//inverse it and then "toggle"
prefs.edit().putBoolean(Config.pref_vmu, false).apply();
//can only display a popup after onCreate
mView.post(new Runnable() {
public void run() {
toggleVmu();
}
});
}
JNIdc.setupVmu(menu.getVmu());
if (prefs.getBoolean(Config.pref_showfps, false)) {
fpsPop = menu.new FpsPopup(this);
mView.setFpsDisplay(fpsPop);
mView.post(new Runnable() {
public void run() {
displayFPS();
}
});
}
}
public Gamepad getPad() {
return pad;
}
@SuppressLint("RtlHardcoded")
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
public void toggleVmu() {
boolean showFloating = !prefs.getBoolean(Config.pref_vmu, false);
if (showFloating) {
if (popUp.isShowing()) {
popUp.dismiss();
}
//remove from popup menu
popUp.hideVmu();
//add to floating window
vmuPop.showVmu();
vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 4, 4);
vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
} else {
vmuPop.dismiss();
//remove from floating window
vmuPop.hideVmu();
//add back to popup menu
popUp.showVmu();
}
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
}
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() {
if (popUp != null) {
if (menu.dismissPopUps()) {
popUp.dismiss();
} else {
if (!popUp.isShowing()) {
displayPopUp(popUp);
} else {
popUp.dismiss();
}
}
}
return true;
}
float getAxisValues(MotionEvent event, int axis, int historyPos) {
return historyPos < 0 ? event.getAxisValue(axis) :
event.getHistoricalAxisValue(axis, historyPos);
}
private void processJoystickInput(MotionEvent event, Integer playerNum, int historyPos) {
float LS_X = getAxisValues(event, prefs.getInt(
Gamepad.pref_axis_x, MotionEvent.AXIS_X), historyPos);
float LS_Y = getAxisValues(event, prefs.getInt(
Gamepad.pref_axis_y, MotionEvent.AXIS_Y), historyPos);
float RS_X = getAxisValues(event, MotionEvent.AXIS_RX, historyPos);
float RS_Y = getAxisValues(event, MotionEvent.AXIS_RY, historyPos);
float L2 = getAxisValues(event, MotionEvent.AXIS_LTRIGGER, historyPos);
float R2 = getAxisValues(event, MotionEvent.AXIS_RTRIGGER, historyPos);
if (pad.IsOuyaOrTV(GL2JNINative.this, true)) {
LS_X = getAxisValues(event, prefs.getInt(Gamepad.pref_axis_x,
OuyaController.AXIS_LS_X), historyPos);
LS_Y = getAxisValues(event, prefs.getInt(Gamepad.pref_axis_y,
OuyaController.AXIS_LS_Y), historyPos);
RS_X = getAxisValues(event, OuyaController.AXIS_RS_X, historyPos);
RS_Y = getAxisValues(event, OuyaController.AXIS_RS_Y, historyPos);
L2 = getAxisValues(event, OuyaController.AXIS_L2, historyPos);
R2 = getAxisValues(event, OuyaController.AXIS_R2, historyPos);
}
if (!pad.joystick[playerNum]) {
pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum];
pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum];
pad.globalLS_X[playerNum] = LS_X;
pad.globalLS_Y[playerNum] = LS_Y;
}
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
if (prefs.getInt(Gamepad.pref_js_rstick + pad.portId[playerNum], 0) == 1) {
float R2Sum = R2 > 0.25 ? R2 : RS_Y;
GL2JNIView.rt[playerNum] = (int) (R2Sum * 255);
float L2Sum = L2 > 0.25 ? L2 : -(RS_Y);
GL2JNIView.lt[playerNum] = (int) (L2Sum * 255);
} else {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
}
if (prefs.getInt(Gamepad.pref_js_rstick + pad.portId[playerNum], 0) == 2) {
if (RS_Y > 0.25) {
handle_key(playerNum, pad.map[playerNum][0]/* A */, true);
pad.wasKeyStick[playerNum] = true;
} else if (RS_Y < 0.25) {
handle_key(playerNum, pad.map[playerNum][1]/* B */, true);
pad.wasKeyStick[playerNum] = true;
} else if (pad.wasKeyStick[playerNum]) {
handle_key(playerNum, pad.map[playerNum][0], false);
handle_key(playerNum, pad.map[playerNum][1], false);
pad.wasKeyStick[playerNum] = false;
}
}
mView.pushInput();
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
// Log.w("INPUT", event.toString() + " " + event.getSource());
// Get all the axis for the KeyEvent
if (event.getSource() != Gamepad.Xperia_Touchpad) {
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
} else {
playerNum = -1;
}
if (playerNum == null || playerNum == -1) {
return false;
}
if (!pad.compat[playerNum]) {
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) ==
InputDevice.SOURCE_JOYSTICK &&
event.getAction() == MotionEvent.ACTION_MOVE) {
final int historySize = event.getHistorySize();
for (int i = 0; i < historySize; i++) {
processJoystickInput(event, playerNum, i);
}
processJoystickInput(event, playerNum, -1);
}
}
return (pad.joystick[playerNum] || (pad.globalLS_X[playerNum] != pad.previousLS_X[playerNum]
|| pad.globalLS_Y[playerNum] != pad.previousLS_Y[playerNum]))
&& (pad.previousLS_X[playerNum] != 0.0f || pad.previousLS_Y[playerNum] != 0.0f);
}
return false;
}
public boolean simulatedLTouchEvent(int playerNum, float L2) {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
mView.pushInput();
return true;
}
public boolean simulatedRTouchEvent(int playerNum, float R2) {
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
mView.pushInput();
return true;
}
public boolean handle_key(Integer playerNum, int kc, boolean down) {
if (playerNum == null || playerNum == -1)
return false;
if (kc == pad.getSelectButtonCode()) {
return false;
}
boolean rav = false;
for (int i = 0; i < pad.map[playerNum].length; i += 2) {
if (pad.map[playerNum][i] == kc) {
if (down)
GL2JNIView.kcode_raw[playerNum] &= ~pad.map[playerNum][i + 1];
else
GL2JNIView.kcode_raw[playerNum] |= pad.map[playerNum][i + 1];
rav = true;
break;
}
}
mView.pushInput();
return rav;
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
return keyCode != KeyEvent.KEYCODE_VOLUME_UP
&& keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
|| super.onKeyUp(keyCode, event);
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == pad.getSelectButtonCode()) {
return showMenu();
}
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
if (keyCode == KeyEvent.KEYCODE_BACK) {
return showMenu();
}
return keyCode != KeyEvent.KEYCODE_VOLUME_UP
&& keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
|| super.onKeyDown(keyCode, event);
}
public boolean OnNativeKeyPress(int device, int keyCode, int action, int metaState) {
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != -1) {
String id = pad.portId[playerNum];
if (action == KeyEvent.ACTION_DOWN) {
if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1))
return simulatedLTouchEvent(playerNum, 1.0f);
if (keyCode == prefs.getInt(Gamepad.pref_button_r + id, KeyEvent.KEYCODE_BUTTON_R1))
return simulatedRTouchEvent(playerNum, 1.0f);
if (handle_key(playerNum, keyCode, true)) {
if (playerNum == 0)
JNIdc.hide_osd();
return true;
}
}
if (action == KeyEvent.ACTION_UP) {
if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1))
return simulatedLTouchEvent(playerNum, 0.0f);
if (keyCode == prefs.getInt(Gamepad.pref_button_r + id, KeyEvent.KEYCODE_BUTTON_R1))
return simulatedRTouchEvent(playerNum, 0.0f);
return handle_key(playerNum, keyCode, false);
}
}
return false;
}
// public boolean OnNativeMotion(int device, int source, int action, int x,
// int y, boolean newEvent) {
public boolean OnNativeMotion(int device, int source, int action, int x, int y) {
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != -1) {
Log.d("reicast", playerNum + " - " + device + ": " + source);
// if (newEvent && source == Gamepad.Xperia_Touchpad) {
if (source == Gamepad.Xperia_Touchpad) {
if (action == MotionEvent.ACTION_UP) {
x = 0;
y = 0;
}
// Sensitive! Zero out the touchpad release
if (x > 360 && x < 500) {
x = 360;
} else if (x > 500 && x < 640) {
x = 640;
}
if (x >= 640) {
x = x - 640;
}
y = 366 - y;
// Right stick is an extension of left stick
// 360 to 640 is the live gap between sticks
// The y-axis is inverted from normal layout
// Imagine it as a small MacBook touch mouse
GL2JNIView.jx[playerNum] = x * 126;
GL2JNIView.jy[playerNum] = y * 126;
mView.pushInput();
return true;
}
}
return false;
}
@Override
protected void onPause() {
super.onPause();
mView.onPause();
JNIdc.pause();
}
@Override
protected void onDestroy() {
super.onDestroy();
mView.onDestroy();
JNIdc.destroy();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
protected void onResume() {
super.onResume();
mView.onResume();
}
}

View File

@ -262,22 +262,12 @@ public class MainActivity extends AppCompatActivity implements
+ uri.getAuthority() + "/external_files", "/storage"));
}
Emulator.nativeact = PreferenceManager.getDefaultSharedPreferences(
getApplicationContext()).getBoolean(Emulator.pref_nativeact, Emulator.nativeact);
if (Emulator.nativeact) {
Intent intent = new Intent("com.reicast.EMULATOR",
uri, getApplicationContext(), GL2JNINative.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
} else {
Intent intent = new Intent("com.reicast.EMULATOR",
uri, getApplicationContext(), GL2JNIActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
}
public void onFolderSelected(Uri uri) {
FileBrowser browserFrag = (FileBrowser) getSupportFragmentManager()

View File

@ -286,17 +286,6 @@ public class OptionsFragment extends Fragment {
});
OnCheckedChangeListener native_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).apply();
}
};
CompoundButton native_opt = (CompoundButton) getView().findViewById(R.id.native_option);
native_opt.setChecked(mPrefs.getBoolean(Emulator.pref_nativeact, Emulator.nativeact));
native_opt.setOnCheckedChangeListener(native_options);
OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
@ -717,7 +706,6 @@ public class OptionsFragment extends Fragment {
private void resetEmuSettings() {
mPrefs.edit().remove(Emulator.pref_usereios).apply();
mPrefs.edit().remove(Config.pref_gamedetails).apply();
mPrefs.edit().remove(Emulator.pref_nativeact).apply();
mPrefs.edit().remove(Emulator.pref_dynarecopt).apply();
mPrefs.edit().remove(Emulator.pref_unstable).apply();
mPrefs.edit().remove(Emulator.pref_cable).apply();
@ -737,7 +725,6 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Config.pref_button_theme).apply();
Emulator.usereios = false;
Emulator.nativeact = false;
Emulator.dynarecopt = true;
Emulator.unstableopt = false;
Emulator.cable = 3;

View File

@ -27,7 +27,6 @@ import android.widget.Toast;
import com.android.util.FileUtils;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.emu.OnScreenMenu.FpsPopup;
import com.reicast.emulator.periph.Gamepad;
@ -150,13 +149,8 @@ public class GL2JNIView extends GLSurfaceView
// This is the game we are going to run
fileName = newFileName;
if (Emulator.nativeact) {
if (GL2JNINative.syms != null)
JNIdc.data(1, GL2JNINative.syms);
} else {
if (GL2JNIActivity.syms != null)
JNIdc.data(1, GL2JNIActivity.syms);
}
JNIdc.init(fileName);
JNIdc.query(ethd);
@ -674,10 +668,6 @@ public class GL2JNIView extends GLSurfaceView
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNIActivity) context).getPad().joystick[0]);
if (context instanceof GL2JNINative)
((GL2JNINative) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNINative) context).getPad().joystick[0]);
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
}
}

View File

@ -19,7 +19,6 @@ import android.widget.TextView;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.MainActivity;
import com.reicast.emulator.R;
import com.reicast.emulator.config.Config;
@ -44,9 +43,6 @@ public class OnScreenMenu {
private boolean syncedrender;
public OnScreenMenu(Activity context, SharedPreferences prefs) {
if (context instanceof GL2JNINative) {
this.mContext = context;
}
if (context instanceof GL2JNIActivity) {
this.mContext = context;
}
@ -59,9 +55,6 @@ public class OnScreenMenu {
vmuLcd = new VmuLcd(mContext);
vmuLcd.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) OnScreenMenu.this.mContext).toggleVmu();
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) OnScreenMenu.this.mContext).toggleVmu();
}
@ -70,9 +63,6 @@ public class OnScreenMenu {
}
private void displayDebugPopup() {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).displayDebug(new DebugPopup(mContext));
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).displayDebug(new DebugPopup(mContext));
}
@ -103,10 +93,6 @@ public class OnScreenMenu {
private void removePopUp(PopupWindow window) {
window.dismiss();
popups.remove(window);
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext)
.displayPopUp(((GL2JNINative) OnScreenMenu.this.mContext).popUp);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext)
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
@ -174,9 +160,6 @@ public class OnScreenMenu {
}
private void displayConfigPopup() {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).displayConfig(new ConfigPopup(mContext));
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext)
.displayConfig(new ConfigPopup(mContext));
@ -276,10 +259,6 @@ public class OnScreenMenu {
OnClickListener clickAudio = new OnClickListener() {
public void onClick(View v) {
if (audio) {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView
.audioDisable(true);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView
.audioDisable(true);
@ -287,10 +266,6 @@ public class OnScreenMenu {
audio = false;
addimg(audiosetting, R.drawable.enable_sound, this);
} else {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView
.audioDisable(false);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView
.audioDisable(false);
@ -313,10 +288,6 @@ public class OnScreenMenu {
OnClickListener clickTurbo = new OnClickListener() {
public void onClick(View v) {
if (boosted) {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView
.audioDisable(!audio);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView
.audioDisable(!audio);
@ -327,9 +298,6 @@ public class OnScreenMenu {
framelimit.setEnabled(true);
JNIdc.frameskip(frames);
enableState(fdown, fup);
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView.fastForward(false);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView
.fastForward(false);
@ -337,9 +305,6 @@ public class OnScreenMenu {
boosted = false;
addimg(fastforward, R.drawable.star, this);
} else {
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView.audioDisable(true);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView
.audioDisable(true);
@ -351,9 +316,6 @@ public class OnScreenMenu {
JNIdc.frameskip(5);
fdown.setEnabled(false);
fup.setEnabled(false);
if (mContext instanceof GL2JNINative) {
((GL2JNINative) mContext).mView.fastForward(true);
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) mContext).mView.fastForward(true);
}
@ -541,10 +503,6 @@ public class OnScreenMenu {
OnClickListener clickScreenshot = new OnClickListener() {
public void onClick(View v) {
// screenshot
if (mContext instanceof GL2JNINative) {
((GL2JNINative) OnScreenMenu.this.mContext)
.screenGrab();
}
if (mContext instanceof GL2JNIActivity) {
((GL2JNIActivity) OnScreenMenu.this.mContext)
.screenGrab();

View File

@ -13,8 +13,6 @@
# limitations under the License.
#
LOCAL_CERTIFICATE := shared
LOCAL_PATH:= $(call my-dir)/..
include $(CLEAR_VARS)
@ -102,14 +100,3 @@ endif
#endif
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := sexplay
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jni/src/XperiaPlay.c)
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

View File

@ -1,310 +0,0 @@
/*
* Copyright (c) 2011, Sony Ericsson Mobile Communications AB.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sony Ericsson Mobile Communications AB nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <dlfcn.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <android/log.h>
#include <jni.h>
#include <errno.h>
#include <android_native_app_glue.h>
#include <time.h>
#include <unistd.h>
#include <sys/system_properties.h>
#define EXPORT_XPLAY __attribute__ ((visibility("default")))
#define TAG "reicast"
#define LOGW(...) ((void)__android_log_print( ANDROID_LOG_WARN, TAG, __VA_ARGS__ ))
#undef NUM_METHODS
#define NUM_METHODS(x) (sizeof(x)/sizeof(*(x)))
static JavaVM *jVM;
typedef unsigned char BOOL;
#define FALSE 0
#define TRUE 1
static jobject g_pActivity = 0;
static jmethodID javaOnNDKTouch = 0;
static jmethodID javaOnNDKKey = 0;
static bool isXperiaPlay;
/**
* Our saved state data.
*/
struct TOUCHSTATE
{
int down;
int x;
int y;
};
/**
* Shared state for our app.
*/
struct ENGINE
{
struct android_app* app;
int render;
int width;
int height;
int has_focus;
//ugly way to track touch states
struct TOUCHSTATE touchstate_screen[64];
struct TOUCHSTATE touchstate_pad[64];
};
void attach(){
}
/**
* Process the next input event.
*/
static
int32_t
engine_handle_input( struct android_app* app, AInputEvent* event )
{
JNIEnv *jni;
(*jVM)->AttachCurrentThread(jVM, &jni, NULL);
struct ENGINE* engine = (struct ENGINE*)app->userData;
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY){
int device = AInputEvent_getDeviceId(event);
int action = AKeyEvent_getAction(event);
int keyCode = AKeyEvent_getKeyCode(event);
if(jni && g_pActivity){
if((*jni)->ExceptionCheck(jni)) {
(*jni)->ExceptionDescribe(jni);
(*jni)->ExceptionClear(jni);
}
(*jni)->CallIntMethod(jni, g_pActivity, javaOnNDKKey, device, keyCode, action, AKeyEvent_getMetaState(event));
if (!(keyCode == AKEYCODE_MENU || keyCode == AKEYCODE_BACK || keyCode == AKEYCODE_BUTTON_THUMBR || keyCode == AKEYCODE_VOLUME_UP || keyCode == AKEYCODE_VOLUME_DOWN || keyCode == AKEYCODE_BUTTON_SELECT)) {
return 1;
}
}
} else if( AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION ) {
int device = AInputEvent_getDeviceId( event );
int nSourceId = AInputEvent_getSource( event );
int nPointerCount = AMotionEvent_getPointerCount( event );
int n;
jboolean newTouch = JNI_TRUE;
for( n = 0 ; n < nPointerCount ; ++n )
{
int nPointerId = AMotionEvent_getPointerId( event, n );
int nAction = AMOTION_EVENT_ACTION_MASK & AMotionEvent_getAction( event );
int nRawAction = AMotionEvent_getAction( event );
struct TOUCHSTATE *touchstate = 0;
if( nSourceId == AINPUT_SOURCE_TOUCHPAD ) {
touchstate = engine->touchstate_pad;
} else {
touchstate = engine->touchstate_screen;
}
if( nAction == AMOTION_EVENT_ACTION_POINTER_DOWN || nAction == AMOTION_EVENT_ACTION_POINTER_UP )
{
int nPointerIndex = (AMotionEvent_getAction( event ) & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
nPointerId = AMotionEvent_getPointerId( event, nPointerIndex );
}
if( nAction == AMOTION_EVENT_ACTION_DOWN || nAction == AMOTION_EVENT_ACTION_POINTER_DOWN )
{
touchstate[nPointerId].down = 1;
}
else if( nAction == AMOTION_EVENT_ACTION_UP || nAction == AMOTION_EVENT_ACTION_POINTER_UP || nAction == AMOTION_EVENT_ACTION_CANCEL )
{
touchstate[nPointerId].down = 0;
}
if (touchstate[nPointerId].down == 1)
{
touchstate[nPointerId].x = AMotionEvent_getX( event, n );
touchstate[nPointerId].y = AMotionEvent_getY( event, n );
}
if( jni && g_pActivity && isXperiaPlay) {
// (*jni)->CallVoidMethod( jni, g_pActivity, javaOnNDKTouch, device, nSourceId, nRawAction, touchstate[nPointerId].x, touchstate[nPointerId].y, newTouch);
(*jni)->CallVoidMethod( jni, g_pActivity, javaOnNDKTouch, device, nSourceId, nRawAction, touchstate[nPointerId].x, touchstate[nPointerId].y);
}
newTouch = JNI_FALSE;
}
if( isXperiaPlay ) {
return 1;
} else {
return 0;
}
}
return 0;
}
/**
* Process the next main command.
*/
static
void
engine_handle_cmd( struct android_app* app, int32_t cmd )
{
struct ENGINE* engine = (struct ENGINE*)app->userData;
switch( cmd )
{
case APP_CMD_SAVE_STATE:
// The system has asked us to save our current state. Do so if needed
break;
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
if( engine->app->window != NULL )
{
engine->has_focus = 1;
}
break;
case APP_CMD_GAINED_FOCUS:
engine->has_focus = 1;
break;
case APP_CMD_LOST_FOCUS:
// When our app loses focus, we stop rendering.
engine->render = 0;
engine->has_focus = 0;
//engine_draw_frame( engine );
break;
}
}
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things (rendering).
*/
void
android_main( struct android_app* state )
{
struct ENGINE engine;
memset( &engine, 0, sizeof(engine) );
state->userData = &engine;
state->onAppCmd = engine_handle_cmd;
state->onInputEvent = engine_handle_input;
engine.app = state;
//setup(state);
//JNIEnv *env;
//(*jVM)->AttachCurrentThread(jVM, &env, NULL);
if( state->savedState != NULL )
{
// We are starting with a previous saved state; restore from it.
}
// our 'main loop'
while( 1 )
{
// Read all pending events.
int ident;
int events;
struct android_poll_source* source;
// If not rendering, we will block forever waiting for events.
// If rendering, we loop until all events are read, then continue
// to draw the next frame.
while( (ident = ALooper_pollAll( 250, NULL, &events, (void**)&source) ) >= 0 )
{
// Process this event.
// This will call the function pointer android_app:nInputEvent() which in our case is
// engine_handle_input()
if( source != NULL )
{
source->process( state, source );
}
// Check if we are exiting.
if( state->destroyRequested != 0 )
{
return;
}
//usleep(20000); //20 miliseconds
}
}
}
static
int
RegisterNative( JNIEnv* env, jobject clazz, jboolean touchpad )
{
g_pActivity = (jobject)(*env)->NewGlobalRef( env, clazz );
isXperiaPlay = (bool) touchpad;
return 0;
}
static const JNINativeMethod activity_methods[] =
{
{ "RegisterNative", "(Z)I", (void*)RegisterNative },
};
jint EXPORT_XPLAY JNICALL JNI_OnLoad(JavaVM * vm, void * reserved)
{
JNIEnv *env;
jVM = vm;
if((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK)
{
LOGW("%s - Failed to get the environment using GetEnv()", __FUNCTION__);
return -1;
}
const char* interface_path = "com/reicast/emulator/GL2JNINative";
jclass java_activity_class = (*env)->FindClass( env, interface_path );
if( !java_activity_class )
{
LOGW( "%s - Failed to get %s class reference", __FUNCTION__, interface_path );
return -1;
}
if( (*env)->RegisterNatives( env, java_activity_class, activity_methods, NUM_METHODS(activity_methods) ) != JNI_OK )
{
LOGW( "%s - Failed to register native activity methods", __FUNCTION__ );
return -1;
}
char device_type[PROP_VALUE_MAX];
__system_property_get("ro.product.model", device_type);
if( isXperiaPlay ) {
LOGW( "%s touchpad enabled", device_type );
} else {
LOGW( "%s touchpad ignored", device_type );
}
// javaOnNDKTouch = (*env)->GetMethodID( env, java_activity_class, "OnNativeMotion", "(IIIIIZ)Z");
javaOnNDKTouch = (*env)->GetMethodID( env, java_activity_class, "OnNativeMotion", "(IIIII)Z");
javaOnNDKKey = (*env)->GetMethodID( env, java_activity_class, "OnNativeKeyPress", "(IIII)Z");
return JNI_VERSION_1_4;
}

View File

@ -246,34 +246,6 @@
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/native_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_native" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/native_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >

View File

@ -25,7 +25,7 @@
android:layout_marginRight="6dp"
android:layout_marginTop="2dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/gdi" />
app:srcCompat="@drawable/disk_unknown" />
<TextView
android:id="@+id/item_name"

View File

@ -246,34 +246,6 @@
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/native_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_native" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/native_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >

View File

@ -24,7 +24,6 @@
<string name="optimization_opts">Optimerings- og fejlfindingsopsætninger</string>
<string name="experimental_opts">Eksperimentel (Kan medføre vidtspredt panik)</string>
<string name="select_details">Aktiver spil detaljer</string>
<string name="select_native">Aktiver native interface</string>
<string name="select_dynarec">Dynarec option</string>
<string name="select_unstable">Ustabile optimeringer</string>
<string name="select_region">DC region</string>

View File

@ -31,7 +31,6 @@
<string name="select_reios">Verwende reios-BIOS</string>
<string name="select_bios">BIOS-Region (dc_flash[X].bin)</string>
<string name="select_details">Aktiviere Spiele-Details</string>
<string name="select_native">Nativer Modus [Kein OSD]</string>
<string name="select_dynarec">Dynarec-Optionen</string>
<string name="select_unstable">Instabile Optimierungen</string>
<string name="select_cable">Kabeltyp</string>

View File

@ -30,7 +30,6 @@ Last Edit: 21 May 2014
<string name="optimization_opts">Options d\'optimisations et de débogage</string>
<string name="experimental_opts">Experimental (peut causer des crashs)</string>
<string name="select_details">Activer le détail des jeux</string>
<string name="select_native">Activer l\'interface native</string>
<string name="select_dynarec">Dynarec</string>
<string name="select_unstable">Optimisations instables</string>
<string name="select_region">Région du bios</string>

View File

@ -30,7 +30,6 @@
<string name="optimization_opts">Opzioni di Ottimizzazione e di Debugging </string>
<string name="experimental_opts">Opzioni Sperimentali (Possono causare problemi)</string>
<string name="select_details">Abilita i Dettagli del Gioco</string>
<string name="select_native">Abilita Interfaccia Nativa</string>
<string name="select_dynarec">Dynarec</string>
<string name="select_unstable">Ottimizzazioni Instabili</string>
<string name="select_region">Regione del DC</string>

View File

@ -21,7 +21,6 @@
<string name="optimization_opts">最適化とデバッグの設定</string>
<string name="experimental_opts">実験的</string>
<string name="select_native">ネイティブインタフェースを使用</string>
<string name="select_dynarec">Dynarecの設定</string>
<string name="select_unstable">不安定な最適化</string>
<string name="select_region">DC地域</string>

View File

@ -31,7 +31,6 @@
<string name="select_reios">Usar reios BIOS</string>
<string name="select_bios">Região da BIOS (dc_flash[X].bin)</string>
<string name="select_details">Habilitar detalhes do jogo</string>
<string name="select_native">Modo nativo [Sem OSD]</string>
<string name="select_dynarec">Habilitar Recompilador Dinâmico (Dynarec)</string>
<string name="select_unstable">Otimizações instáveis</string>
<string name="select_cable">Tipo de cabo</string>

View File

@ -33,7 +33,6 @@
<string name="select_reios">Использовать reios BIOS</string>
<string name="select_bios">Регион BIOS (dc_flash[X].bin)</string>
<string name="select_details">Информация об игре</string>
<string name="select_native">Нативный режим (без индикации)</string>
<string name="select_dynarec">Динамическая рекомпиляция</string>
<string name="select_unstable">Нестабильные оптимизации</string>
<string name="select_cable">Тип кабеля</string>

View File

@ -36,7 +36,6 @@
<string name="select_reios">Use reios BIOS</string>
<string name="select_bios">BIOS Region (dc_flash[X].bin)</string>
<string name="select_details">Enable Game Details</string>
<string name="select_native">Native Gamepad Mode [No OSD]</string>
<string name="select_dynarec">Dynamic Recompiler</string>
<string name="select_unstable">Unstable Optimisations</string>
<string name="select_safemode">Bypass Div Matching</string>