This should get the menus back to working properly again

This commit is contained in:
TwistedUmbrella 2014-03-08 14:55:30 -05:00
parent 2b9926d397
commit 27ee791d71
3 changed files with 20 additions and 23 deletions

View File

@ -18,8 +18,6 @@ public class AboutFragment extends Fragment {
String buildId = "";
private Activity parentActivity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -29,7 +27,6 @@ public class AboutFragment extends Fragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
parentActivity = getActivity();
try {
InputStream file = getResources().getAssets().open("build");
@ -44,10 +41,10 @@ public class AboutFragment extends Fragment {
}
try {
String versionName = parentActivity.getPackageManager()
.getPackageInfo(parentActivity.getPackageName(), 0).versionName;
int versionCode = parentActivity.getPackageManager()
.getPackageInfo(parentActivity.getPackageName(), 0).versionCode;
String versionName = getActivity().getPackageManager()
.getPackageInfo(getActivity().getPackageName(), 0).versionName;
int versionCode = getActivity().getPackageManager()
.getPackageInfo(getActivity().getPackageName(), 0).versionCode;
TextView version = (TextView) getView().findViewById(
R.id.revision_text);
String revision = getString(R.string.revision_text,

View File

@ -249,7 +249,7 @@ public class GL2JNIActivity extends Activity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
int playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
@ -257,7 +257,7 @@ public class GL2JNIActivity extends Activity {
playerNum = -1;
}
if (playerNum == -1)
if (playerNum == null || playerNum == -1)
return false;
if (!pad.compat[playerNum]) {
@ -333,8 +333,8 @@ public class GL2JNIActivity extends Activity {
return true;
}
public boolean handle_key(int playerNum, int kc, boolean down) {
if (playerNum == -1)
public boolean handle_key(Integer playerNum, int kc, boolean down) {
if (playerNum == null || playerNum == -1)
return false;
if (kc == pad.getSelectButtonCode()) {
return false;
@ -416,7 +416,7 @@ public class GL2JNIActivity extends Activity {
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
int playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
@ -424,7 +424,7 @@ public class GL2JNIActivity extends Activity {
playerNum = -1;
}
if (playerNum != -1) {
if (playerNum != null && playerNum != -1) {
if (pad.compat[playerNum] || pad.custom[playerNum]) {
String id = pad.portId[playerNum];
if (keyCode == prefs.getInt(Gamepad.pref_button_l + id,
@ -441,7 +441,7 @@ public class GL2JNIActivity extends Activity {
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
int playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
@ -449,7 +449,7 @@ public class GL2JNIActivity extends Activity {
playerNum = -1;
}
if (playerNum != -1) {
if (playerNum != null && playerNum != -1) {
if (pad.compat[playerNum] || pad.custom[playerNum]) {
String id = pad.portId[playerNum];
if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1)) {

View File

@ -343,14 +343,14 @@ public class GL2JNINative extends NativeActivity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
&& event.getSource() != Gamepad.Xperia_Touchpad) {
int playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
playerNum = pad.deviceDescriptor_PlayerNum
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
} else {
playerNum = -1;
}
if (playerNum == -1) {
if (playerNum == null || playerNum == -1) {
return false;
}
if (!pad.compat[playerNum]) {
@ -416,8 +416,8 @@ public class GL2JNINative extends NativeActivity {
}
boolean handle_key(int playerNum, int kc, boolean down) {
if (playerNum == -1)
boolean handle_key(Integer playerNum, int kc, boolean down) {
if (playerNum == null || playerNum == -1)
return false;
if (kc == pad.getSelectButtonCode()) {
return false;
@ -473,8 +473,8 @@ public class GL2JNINative extends NativeActivity {
}
public boolean OnNativeKeyPress(int device, int keyCode, int action, int metaState) {
int playerNum = pad.playerNumX.get(device);
if (playerNum != -1) {
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != null && 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)) {
@ -504,8 +504,8 @@ public class GL2JNINative extends NativeActivity {
public boolean OnNativeMotion(int device, int source, int action, int x, int y, boolean newEvent) {
if (newEvent && source == Gamepad.Xperia_Touchpad) {
// Source is Xperia Play touchpad
int playerNum = pad.playerNumX.get(device);
if (playerNum != -1) {
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != null && playerNum != -1) {
Log.d("reidc", playerNum + " - " + device + ": " + source);
if (action == MotionEvent.ACTION_UP) {
x = 0;