Refactor the Dpad Joystick toggle for purposely invalid input
This commit is contained in:
parent
1440b0ef6c
commit
839ddd0c40
|
@ -1,4 +1,5 @@
|
|||
APP_STL := stlport_static
|
||||
APP_ABI := armeabi-v7a
|
||||
#APP_ABI := armeabi-v7a x86
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_PLATFORM := android-18
|
||||
NDK_TOOLCHAIN_VERSION := 4.8
|
|
@ -29,6 +29,33 @@
|
|||
</Spinner>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
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/joystick_layout" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<de.ankri.views.Switch
|
||||
android:id="@+id/switchJoystickDpadEnabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<string name="select_controller_title">Select Controller</string>
|
||||
<string name="select_controller_message">Press any button on the controller %1$s to assign to port</string>
|
||||
<string name="controller_already_in_use">This controller is already in use!</string>
|
||||
<string name="joystick_layout">Use Joystick For Dpad Input</string>
|
||||
<string name="modified_layout">Enable Custom Key Layout</string>
|
||||
<string name="controller_compat">Enable Compatibility Mode</string>
|
||||
<string name="mic_in_port_2">Microphone plugged into port 2</string>
|
||||
|
|
|
@ -146,6 +146,7 @@ public class GL2JNIActivity extends Activity {
|
|||
String id = pad.portId[playerNum];
|
||||
pad.custom[playerNum] = prefs.getBoolean("modified_key_layout" + id, false);
|
||||
pad.compat[playerNum] = prefs.getBoolean("controller_compat" + id, false);
|
||||
pad.joystick[playerNum] = prefs.getBoolean("separate_joystick" + id, true);
|
||||
if (!pad.compat[playerNum]) {
|
||||
if (pad.custom[playerNum]) {
|
||||
pad.map[playerNum] = pad.setModifiedKeys(id, playerNum, prefs);
|
||||
|
@ -270,10 +271,12 @@ public class GL2JNIActivity extends Activity {
|
|||
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
|
||||
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
|
||||
|
||||
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;
|
||||
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);
|
||||
|
@ -306,7 +309,7 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
}
|
||||
mView.pushInput();
|
||||
if ((pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum] && pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum])
|
||||
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,
|
||||
|
|
|
@ -156,6 +156,7 @@ public class GL2JNINative extends NativeActivity {
|
|||
String id = pad.portId[playerNum];
|
||||
pad.custom[playerNum] = prefs.getBoolean("modified_key_layout" + id, false);
|
||||
pad.compat[playerNum] = prefs.getBoolean("controller_compat" + id, false);
|
||||
pad.joystick[playerNum] = prefs.getBoolean("separate_joystick" + id, false);
|
||||
if (InputDevice.getDevice(joy).getName()
|
||||
.contains("keypad-zeus")) {
|
||||
pad.playerNumX.put(joy, playerNum);
|
||||
|
@ -363,10 +364,12 @@ public class GL2JNINative extends NativeActivity {
|
|||
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
|
||||
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
|
||||
|
||||
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;
|
||||
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);
|
||||
|
@ -398,7 +401,7 @@ public class GL2JNINative extends NativeActivity {
|
|||
}
|
||||
}
|
||||
mView.pushInput();
|
||||
if ((pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum] && pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum])
|
||||
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,
|
||||
|
|
|
@ -45,6 +45,7 @@ public class InputModFragment extends Fragment {
|
|||
private Activity parentActivity;
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
private Switch switchJoystickDpadEnabled;
|
||||
private Switch switchModifiedLayoutEnabled;
|
||||
private Switch switchCompatibilityEnabled;
|
||||
|
||||
|
@ -99,6 +100,18 @@ public class InputModFragment extends Fragment {
|
|||
playerNum = b.getInt("portNumber", -1);
|
||||
}
|
||||
|
||||
OnCheckedChangeListener joystick_mode = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean("separate_joystick" + player, isChecked)
|
||||
.commit();
|
||||
}
|
||||
};
|
||||
switchJoystickDpadEnabled = (Switch) getView().findViewById(
|
||||
R.id.switchJoystickDpadEnabled);
|
||||
switchJoystickDpadEnabled.setOnCheckedChangeListener(joystick_mode);
|
||||
|
||||
OnCheckedChangeListener modified_layout = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
|
@ -559,6 +572,8 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void updateController(String player) {
|
||||
switchJoystickDpadEnabled.setChecked(mPrefs.getBoolean(
|
||||
"separate_joystick" + player, false));
|
||||
switchModifiedLayoutEnabled.setChecked(mPrefs.getBoolean(
|
||||
"modified_key_layout" + player, false));
|
||||
switchCompatibilityEnabled.setChecked(mPrefs.getBoolean(
|
||||
|
|
|
@ -18,6 +18,7 @@ public class Gamepad {
|
|||
public String[] portId = { "_A", "_B", "_C", "_D" };
|
||||
public boolean[] compat = { false, false, false, false };
|
||||
public boolean[] custom = { false, false, false, false };
|
||||
public boolean[] joystick = { false, false, false, false };
|
||||
public int[] name = { -1, -1, -1, -1 };
|
||||
public float[] globalLS_X = new float[4], globalLS_Y = new float[4],
|
||||
previousLS_X = new float[4], previousLS_Y = new float[4];
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
APP_ABI := armeabi-v7a
|
||||
#APP_ABI := armeabi-v7a x86
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_PLATFORM := android-9
|
||||
NDK_TOOLCHAIN_VERSION := 4.8
|
Loading…
Reference in New Issue