Increase minSDK according to NDK minimum (16)

Remove proprietary Xperia Play support (API 9 - 14)
This commit is contained in:
TwistedUmbrella 2018-04-19 16:13:44 -04:00
parent 3183b3185a
commit b4762106ef
13 changed files with 351 additions and 564 deletions

View File

@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.reicast.emulator"
minSdkVersion 9
minSdkVersion 16
targetSdkVersion 21
versionCode="7"
versionName="r7"

View File

@ -8,14 +8,9 @@
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -48,10 +43,6 @@
android:logo="@drawable/ic_banner"
android:hardwareAccelerated="true"
android:isGame="true">
<meta-data
android:name="xperiaplayoptimized_content"
android:resource="@drawable/ic_xperia_play" />
<activity
android:name=".MainActivity"

View File

@ -1,6 +1,5 @@
package com.reicast.emulator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@ -35,7 +34,6 @@ import java.util.HashMap;
import tv.ouya.console.api.OuyaController;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class GL2JNIActivity extends Activity {
public GL2JNIView mView;
OnScreenMenu menu;
@ -62,7 +60,6 @@ public class GL2JNIActivity extends Activity {
app.getConfigurationPrefs(prefs);
menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
pad.isXperiaPlay = pad.IsXperiaPlay();
pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNIActivity.this);
// pad.isNvidiaShield = pad.IsNvidiaShield();
@ -107,8 +104,7 @@ public class GL2JNIActivity extends Activity {
boolean controllerThreeConnected = false;
boolean controllerFourConnected = false;
for (HashMap.Entry<String, Integer> e : pad.deviceDescriptor_PlayerNum
.entrySet()) {
for (HashMap.Entry<String, Integer> e : pad.deviceDescriptor_PlayerNum.entrySet()) {
String descriptor = e.getKey();
Integer playerNum = e.getValue();
@ -128,72 +124,64 @@ public class GL2JNIActivity extends Activity {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
int joys[] = InputDevice.getDeviceIds();
for (int joy: joys) {
String descriptor = null;
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);
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
int joys[] = InputDevice.getDeviceIds();
for (int joy: joys) {
String descriptor = null;
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);
}
for (int joy :joys) {
Integer playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(joy));
for (int joy :joys) {
Integer playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(joy));
if (playerNum != null) {
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()
.contains(Gamepad.controllers_play)) {
pad.map[playerNum] = pad.getXPlayController();
} else if (!pad.isActiveMoga[playerNum]) { // Ouya controller
pad.map[playerNum] = pad.getOUYAController();
}
if (playerNum != null) {
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.getCompatibilityMap(playerNum, id, prefs);
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 (!pad.isActiveMoga[playerNum]) { // Ouya controller
pad.map[playerNum] = pad.getOUYAController();
}
pad.initJoyStickLayout(playerNum);
} else {
pad.runCompatibilityMode(joy, prefs);
pad.getCompatibilityMap(playerNum, id, prefs);
}
pad.initJoyStickLayout(playerNum);
} else {
pad.runCompatibilityMode(joy, prefs);
}
if (joys.length == 0) {
pad.fullCompatibilityMode(prefs);
}
} else {
}
if (joys.length == 0) {
pad.fullCompatibilityMode(prefs);
}
@ -243,92 +231,21 @@ public class GL2JNIActivity extends Activity {
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
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]) {
// Joystick
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
// do other things with joystick
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y);
float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X);
float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y);
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
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);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) {
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;
}
} else {
if (RS_Y > 0.25) {
GL2JNIView.rt[playerNum] = (int) (RS_Y * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
} else if (RS_Y < 0.25) {
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
}
}
}
}
mView.pushInput();
if (!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))
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
return false;
else
return true;
} else {
return false;
playerNum = -1;
}
}
public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if (playerNum == null || playerNum == -1)
return false;
if (playerNum == null || playerNum == -1)
return false;
if (!pad.compat[playerNum]) {
if (!pad.compat[playerNum]) {
// Joystick
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
// do other things with joystick
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
@ -372,21 +289,75 @@ public class GL2JNIActivity extends Activity {
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
}
}
}
mView.pushInput();
if (!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))
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
return false;
else
return true;
} else {
return false;
}
mView.pushInput();
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
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));
}
public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) {
if (playerNum == null || playerNum == -1)
return false;
if (!pad.compat[playerNum]) {
// do other things with joystick
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y);
float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X);
float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y);
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
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);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) {
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;
}
} else {
if (RS_Y > 0.25) {
GL2JNIView.rt[playerNum] = (int) (RS_Y * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
} else if (RS_Y < 0.25) {
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
}
}
}
mView.pushInput();
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
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));
}
public boolean simulatedTouchEvent(int playerNum, float L2, float R2) {
@ -478,7 +449,7 @@ public class GL2JNIActivity extends Activity {
public boolean onKeyUp(int keyCode, KeyEvent event) {
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
if (playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
} else {
@ -503,7 +474,7 @@ public class GL2JNIActivity extends Activity {
public boolean onKeyDown(int keyCode, KeyEvent event) {
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
if (playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
} else {
@ -531,19 +502,13 @@ public class GL2JNIActivity extends Activity {
if (keyCode == pad.getSelectButtonCode()) {
return showMenu();
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
&& ViewConfiguration.get(this).hasPermanentMenuKey())) {
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (pad.isXperiaPlay) {
return true;
} else {
return showMenu();
}
return showMenu();
}
return super.onKeyDown(keyCode, event);
}

View File

@ -1,6 +1,5 @@
package com.reicast.emulator;
import android.annotation.TargetApi;
import android.app.NativeActivity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@ -37,7 +36,6 @@ import java.util.HashMap;
import tv.ouya.console.api.OuyaController;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class GL2JNINative extends NativeActivity {
public GL2JNIView mView;
OnScreenMenu menu;
@ -57,7 +55,6 @@ public class GL2JNINative extends NativeActivity {
native int RegisterNative(boolean touchpad);
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate(Bundle icicle) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -68,12 +65,11 @@ public class GL2JNINative extends NativeActivity {
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
getWindow().takeSurface(null);
pad.isXperiaPlay = pad.IsXperiaPlay();
pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNINative.this);
// isNvidiaShield = Gamepad.IsNvidiaShield();
RegisterNative(pad.isXperiaPlay);
RegisterNative(false);
Emulator app = (Emulator)getApplicationContext();
app.getConfigurationPrefs(prefs);
@ -124,92 +120,62 @@ public class GL2JNINative extends NativeActivity {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
int joys[] = InputDevice.getDeviceIds();
for (int joy : joys) {
String descriptor = 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);
}
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
int joys[] = InputDevice.getDeviceIds();
for (int joy : joys) {
String descriptor = null;
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());
if (pad.isXperiaPlay) {
if (InputDevice.getDevice(joy).getName()
.contains(Gamepad.controllers_play_gp)) {
pad.keypadZeus[0] = joy;
}
if (InputDevice.getDevice(joy).getName()
.contains(Gamepad.controllers_play_tp)) {
pad.keypadZeus[1] = joy;
}
}
Log.d("reicast", "InputDevice Descriptor: " + descriptor);
pad.deviceId_deviceDescriptor.put(joy, descriptor);
}
for (int joy : joys) {
Integer playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(joy));
for (int joy : joys) {
Integer playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(joy));
if (playerNum != null) {
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 (playerNum != null) {
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]) {
// setCustomMapping(id, playerNum);
// } else {
// pad.map[playerNum] = pad.getConsoleController();
// }
new Handler().post(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), R.string.controller_unavailable,
Toast.LENGTH_SHORT).show();
finish();
}
});
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()
.contains(Gamepad.controllers_play) ) {
for (int keys : pad.keypadZeus) {
pad.playerNumX.put(keys, playerNum);
}
if (pad.custom[playerNum]) {
pad.setCustomMapping(id, playerNum, prefs);
} else {
pad.map[playerNum] = pad.getXPlayController();
}
} 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 (!pad.isActiveMoga[playerNum]) { // Ouya controller
pad.map[playerNum] = pad.getOUYAController();
}
} else{
pad.getCompatibilityMap(playerNum, id, prefs);
.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 (!pad.isActiveMoga[playerNum]) { // Ouya controller
pad.map[playerNum] = pad.getOUYAController();
}
pad.initJoyStickLayout(playerNum);
pad.playerNumX.put(joy, playerNum);
} else {
pad.runCompatibilityMode(joy, prefs);
} else{
pad.getCompatibilityMap(playerNum, id, prefs);
}
pad.initJoyStickLayout(playerNum);
pad.playerNumX.put(joy, playerNum);
} else {
pad.runCompatibilityMode(joy, prefs);
}
}
@ -322,70 +288,62 @@ public class GL2JNINative extends NativeActivity {
}
public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if (playerNum == null || playerNum == -1)
return false;
if (!pad.compat[playerNum]) {
// do other things with joystick
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y);
float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X);
float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y);
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
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);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) {
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;
}
} else {
if (RS_Y > 0.25) {
GL2JNIView.rt[playerNum] = (int) (RS_Y * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
} else if (RS_Y < 0.25) {
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
}
}
}
mView.pushInput();
if (!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))
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
return false;
else
return true;
} else {
if (playerNum == null || playerNum == -1)
return false;
if (!pad.compat[playerNum]) {
// do other things with joystick
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y);
float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X);
float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y);
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
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);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) {
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;
}
} else {
if (RS_Y > 0.25) {
GL2JNIView.rt[playerNum] = (int) (RS_Y * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
} else if (RS_Y < 0.25) {
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
}
}
}
mView.pushInput();
// Only handle Left Stick on an Xbox 360 controller if there was
// some actual motion on the stick,
// so otherwise the event can be handled as a DPAD event
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));
}
@Override
@ -393,11 +351,10 @@ public class GL2JNINative extends NativeActivity {
// Log.w("INPUT", event.toString() + " " + event.getSource());
// Get all the axis for the KeyEvent
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
&& event.getSource() != Gamepad.Xperia_Touchpad) {
if (event.getSource() != Gamepad.Xperia_Touchpad) {
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
if (playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
} else {
@ -495,34 +452,26 @@ public class GL2JNINative extends NativeActivity {
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
return super.onKeyUp(keyCode, event);
}
return true;
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 (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
&& ViewConfiguration.get(this).hasPermanentMenuKey())) {
}
if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
return showMenu();
}
}
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (pad.isXperiaPlay) {
return true;
} else {
return showMenu();
}
return showMenu();
}
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
return super.onKeyDown(keyCode, event);
}
return true;
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) {

View File

@ -138,14 +138,6 @@ public class MainActivity extends AppCompatActivity implements
// Check that the activity is using the layout version with
// the fragment_container FrameLayout
if (findViewById(R.id.fragment_container) != null) {
// However, if we're being restored from a previous state,
// then we don't need to do anything and should return or else
// we could end up with overlapping fragments.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
if (savedInstanceState != null) {
return;
}
}
onMainBrowseSelected(true, null, false, null);
}
@ -411,9 +403,7 @@ public class MainActivity extends AppCompatActivity implements
CloudFragment cloudfragment = (CloudFragment) getSupportFragmentManager()
.findFragmentByTag("CLOUD_FRAG");
if (cloudfragment != null && cloudfragment.isVisible()) {
if (cloudfragment != null) {
cloudfragment.onResume();
}
cloudfragment.onResume();
}
}

View File

@ -207,7 +207,7 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
game_details = mContext.getString(R.string.info_unavailable);
final String nameLower = game.getName().toLowerCase(
Locale.getDefault());
if (Build.VERSION.SDK_INT < 21) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
game_icon = mContext.getResources().getDrawable(
game.isDirectory() ? R.drawable.open_folder : nameLower
.endsWith(".gdi") ? R.drawable.gdi : nameLower
@ -336,12 +336,12 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
fOut.flush();
fOut.close();
} catch (Exception ex) {
ex.printStackTrace();
}
return bitmap;
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

View File

@ -1,6 +1,5 @@
package com.reicast.emulator.config;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
@ -27,7 +26,6 @@ import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.emu.OnScreenMenu;
import com.reicast.emulator.periph.VJoy;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class EditVJoyActivity extends Activity {
GL2JNIView mView;
PopupWindow popUp;

View File

@ -75,20 +75,18 @@ public class InputFragment extends Fragment {
Config.vibrationDuration = sharedPreferences.getInt(Config.pref_vibrationDuration, 20);
vib = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ImageView icon_a = (ImageView) getView().findViewById(
R.id.controller_icon_a);
icon_a.setAlpha(0.8f);
ImageView icon_b = (ImageView) getView().findViewById(
R.id.controller_icon_b);
icon_b.setAlpha(0.8f);
ImageView icon_c = (ImageView) getView().findViewById(
R.id.controller_icon_c);
icon_c.setAlpha(0.8f);
ImageView icon_d = (ImageView) getView().findViewById(
R.id.controller_icon_d);
icon_d.setAlpha(0.8f);
}
ImageView icon_a = (ImageView) getView().findViewById(
R.id.controller_icon_a);
icon_a.setAlpha(0.8f);
ImageView icon_b = (ImageView) getView().findViewById(
R.id.controller_icon_b);
icon_b.setAlpha(0.8f);
ImageView icon_c = (ImageView) getView().findViewById(
R.id.controller_icon_c);
icon_c.setAlpha(0.8f);
ImageView icon_d = (ImageView) getView().findViewById(
R.id.controller_icon_d);
icon_d.setAlpha(0.8f);
Button buttonLaunchEditor = (Button) getView().findViewById(
R.id.buttonLaunchEditor);
@ -186,86 +184,76 @@ public class InputFragment extends Fragment {
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Button buttonSelectControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer1);
buttonSelectControllerPlayer1
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(1);
}
});
Button buttonSelectControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer2);
buttonSelectControllerPlayer2
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(2);
}
});
Button buttonSelectControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer3);
buttonSelectControllerPlayer3
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(3);
}
});
Button buttonSelectControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer4);
buttonSelectControllerPlayer4
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(4);
}
});
Button buttonSelectControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer1);
buttonSelectControllerPlayer1
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(1);
}
});
Button buttonSelectControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer2);
buttonSelectControllerPlayer2
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(2);
}
});
Button buttonSelectControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer3);
buttonSelectControllerPlayer3
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(3);
}
});
Button buttonSelectControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer4);
buttonSelectControllerPlayer4
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
selectController(4);
}
});
Button buttonRemoveControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer1);
buttonRemoveControllerPlayer1
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(1);
}
});
Button buttonRemoveControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer1);
buttonRemoveControllerPlayer1
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(1);
}
});
Button buttonRemoveControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer2);
buttonRemoveControllerPlayer2
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(2);
}
});
Button buttonRemoveControllerPlayer2 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer2);
buttonRemoveControllerPlayer2
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(2);
}
});
Button buttonRemoveControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer3);
buttonRemoveControllerPlayer3
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(3);
}
});
Button buttonRemoveControllerPlayer3 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer3);
buttonRemoveControllerPlayer3
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(3);
}
});
Button buttonRemoveControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer4);
buttonRemoveControllerPlayer4
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(4);
}
});
Button buttonRemoveControllerPlayer4 = (Button) getView()
.findViewById(R.id.buttonRemoveControllerPlayer4);
buttonRemoveControllerPlayer4
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
removeController(4);
}
});
updateControllers();
} else {
TableLayout input_devices = (TableLayout) getActivity()
.findViewById(R.id.input_devices);
input_devices.setVisibility(View.GONE);
}
updateControllers();
updateVibration();
}
@ -290,12 +278,7 @@ public class InputFragment extends Fragment {
for (int devideId : InputDevice.getDeviceIds()) {
InputDevice dev = InputDevice.getDevice(devideId);
String descriptor = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
descriptor = dev.getDescriptor();
} else {
descriptor = dev.getName();
}
String descriptor = dev.getDescriptor();
if (descriptor != null) {
if (descriptor.equals(deviceDescriptorPlayer1))
@ -436,21 +419,16 @@ public class InputFragment extends Fragment {
|| keyCode == KeyEvent.KEYCODE_VOLUME_UP
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
return false;
if (!pad.IsXperiaPlay() && keyCode == KeyEvent.KEYCODE_BACK)
if (keyCode == KeyEvent.KEYCODE_BACK)
return false;
String descriptor = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (pad.isActiveMoga[listenForButton]) {
MogaListener config = new MogaListener(listenForButton);
moga.mController.setListener(config, new Handler());
descriptor = config.getController();
}
descriptor = InputDevice.getDevice(event.getDeviceId())
.getDescriptor();
} else {
descriptor = InputDevice.getDevice(event.getDeviceId()).getName();
if (pad.isActiveMoga[listenForButton]) {
MogaListener config = new MogaListener(listenForButton);
moga.mController.setListener(config, new Handler());
descriptor = config.getController();
}
descriptor = InputDevice.getDevice(event.getDeviceId()).getDescriptor();
if (descriptor == null)
return false;
@ -490,7 +468,7 @@ public class InputFragment extends Fragment {
break;
}
Log.d("New controller for port " + listenForButton + ":", descriptor);
Log.d("New port " + listenForButton + " controller:", descriptor);
listenForButton = 0;
alertDialogSelectController.cancel();

View File

@ -81,11 +81,6 @@ public class InputModFragment extends Fragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Runtime.getRuntime().freeMemory();
System.gc();
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
final String[] controllers = getResources().getStringArray(R.array.controllers);
@ -390,10 +385,6 @@ public class InputModFragment extends Fragment {
*/
private Drawable getButtonImage(int x, int y) {
Bitmap image = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Runtime.getRuntime().freeMemory();
System.gc();
}
try {
File buttons = null;
InputStream bitmap = null;
@ -411,10 +402,6 @@ public class InputModFragment extends Fragment {
image = BitmapFactory.decodeStream(bitmap, null, options);
bitmap.close();
bitmap = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Runtime.getRuntime().freeMemory();
System.gc();
}
Matrix matrix = new Matrix();
matrix.postScale(32, 32);
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64 / sS,
@ -436,10 +423,6 @@ public class InputModFragment extends Fragment {
return getButtonImage(x, y);
} else {
E.printStackTrace();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Runtime.getRuntime().freeMemory();
System.gc();
}
}
}
return getResources().getDrawable(R.drawable.input);
@ -535,7 +518,6 @@ public class InputModFragment extends Fragment {
return keyCode;
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public boolean dispatchTouchEvent(MotionEvent ev) {
if (isMapping) {
if ((ev.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {

View File

@ -246,15 +246,10 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
@Override
protected void onPostExecute(final String response) {
if (response != null && !response.equals(null)) {
if (response != null) {
showToastMessage(mContext.getString(R.string.log_saved), Snackbar.LENGTH_LONG);
UploadLogs mUploadLogs = new UploadLogs(mContext, currentTime);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mUploadLogs.executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, response);
} else {
mUploadLogs.execute(response);
}
mUploadLogs.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, response);
}
}

View File

@ -135,9 +135,7 @@ public class GL2JNIView extends GLSurfaceView
});
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setPreserveEGLContextOnPause(true);
}
setPreserveEGLContextOnPause(true);
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
@ -159,21 +157,7 @@ public class GL2JNIView extends GLSurfaceView
touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true);
vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20);
int renderType = prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
this.setLayerType(renderType, null);
} else {
try {
Method setLayerType = this.getClass().getMethod(
"setLayerType", new Class[] { int.class, Paint.class });
if (setLayerType != null)
setLayerType.invoke(this, new Object[] { renderType, null });
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
}
this.setLayerType(prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE), null);
vjoy_d_custom = VJoy.readCustomVjoyValues(context);

View File

@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.KeyEvent;
import java.util.HashMap;
@ -46,9 +47,6 @@ public class Gamepad {
public static final String controllers_sony = "Sony PLAYSTATION(R)3 Controller";
public static final String controllers_xbox = "Microsoft X-Box 360 pad";
public static final String controllers_shield = "NVIDIA Corporation NVIDIA Controller";
public static final String controllers_play = "keypad-zeus";
public static final String controllers_play_gp = "keypad-game-zeus";
public static final String controllers_play_tp = "synaptics_touchpad";
public static final String controllers_gamekey = "gamekeyboard";
public String[] portId = { "_A", "_B", "_C", "_D" };
@ -61,16 +59,14 @@ public class Gamepad {
public boolean[] wasKeyStick = { false, false, false, false };
public int map[][] = new int[4][];
public SparseArray<String> deviceId_deviceDescriptor = new SparseArray<String>();
public HashMap<String, Integer> deviceDescriptor_PlayerNum = new HashMap<String, Integer>();
public SparseArray<String> deviceId_deviceDescriptor = new SparseArray<>();
public HashMap<String, Integer> deviceDescriptor_PlayerNum = new HashMap<>();
public boolean isActiveMoga[] = { false, false, false, false };
public boolean isMogaPro[] = { false, false, false, false };
public SparseArray<Integer> playerNumX = new SparseArray<Integer>();
public int[] keypadZeus = new int[2];
public SparseIntArray playerNumX = new SparseIntArray();
public boolean isXperiaPlay;
public boolean isOuyaOrTV;
// public boolean isNvidiaShield;
@ -104,24 +100,6 @@ public class Gamepad {
};
}
public int[] getXPlayController() {
return new int[] {
KeyEvent.KEYCODE_DPAD_CENTER, key_CONT_A,
KeyEvent.KEYCODE_BACK, key_CONT_B,
OuyaController.BUTTON_U, key_CONT_X,
OuyaController.BUTTON_Y, key_CONT_Y,
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN,
OuyaController.BUTTON_DPAD_LEFT, key_CONT_DPAD_LEFT,
OuyaController.BUTTON_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
getStartButtonCode(), key_CONT_START,
getSelectButtonCode(), getSelectButtonCode()
// Redundant, but verifies it is mapped properly
};
}
public int[] getOUYAController() {
return new int[] {
OuyaController.BUTTON_O, key_CONT_A,
@ -173,46 +151,23 @@ public class Gamepad {
};
}
public boolean IsXperiaPlay() {
return android.os.Build.MODEL.equals("R800a")
|| android.os.Build.MODEL.equals("R800i")
|| android.os.Build.MODEL.equals("R800x")
|| android.os.Build.MODEL.equals("R800at")
|| android.os.Build.MODEL.equals("SO-01D")
|| android.os.Build.MODEL.equals("zeus");
}
public boolean IsOuyaOrTV(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
UiModeManager uiModeManager = (UiModeManager)
context.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
return true;
}
UiModeManager uiModeManager = (UiModeManager)
context.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
return true;
}
PackageManager pMan = context.getPackageManager();
if (pMan.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
return true;
} else if (OuyaFacade.getInstance().isRunningOnOUYAHardware()) {
return true;
}
return false;
return pMan.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
|| OuyaFacade.getInstance().isRunningOnOUYAHardware();
}
public int getStartButtonCode() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
return 108;
} else {
return KeyEvent.KEYCODE_BUTTON_START;
}
return KeyEvent.KEYCODE_BUTTON_START;
}
public int getSelectButtonCode() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
return 109;
} else {
return KeyEvent.KEYCODE_BUTTON_SELECT;
}
return KeyEvent.KEYCODE_BUTTON_SELECT;
}
public boolean IsNvidiaShield() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB