Patch up the dpad issues, Add the wow factor to customize
This commit is contained in:
parent
1a46c4b252
commit
a0260c0d97
|
@ -55,15 +55,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/a_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="A button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/a_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/a_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="A button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -90,15 +106,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/b_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="B button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/b_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/b_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="B button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -125,15 +157,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/x_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="X button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/x_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/x_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="X button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -160,15 +208,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/y_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="Y button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/y_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/y_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="Y button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -195,15 +259,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/l_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="L button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/l_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/l_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="L button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -230,15 +310,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/r_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="R button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/r_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/r_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="R button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -265,7 +361,9 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/joystick_key"
|
||||
|
@ -300,7 +398,9 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_up_key"
|
||||
|
@ -335,7 +435,9 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_down_key"
|
||||
|
@ -370,7 +472,9 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_left_key"
|
||||
|
@ -405,7 +509,9 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_right_key"
|
||||
|
@ -440,15 +546,31 @@
|
|||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
<TableRow
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_button_key"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="Start Button" />
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/start_button_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/input" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:ems="10"
|
||||
android:text="Start Button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -38,8 +38,8 @@ public class GL2JNIActivity extends Activity {
|
|||
LayoutParams params;
|
||||
MOGAInput moga = new MOGAInput();
|
||||
private SharedPreferences prefs;
|
||||
static boolean[] xbox = { false, false, false, false }, nVidia = { false,
|
||||
false, false, false };
|
||||
static boolean[] custom = { false, false, false, false }, xbox = { false,
|
||||
false, false, false }, nVidia = { false, false, false, false };
|
||||
float[] globalLS_X = new float[4], globalLS_Y = new float[4],
|
||||
previousLS_X = new float[4], previousLS_Y = new float[4];
|
||||
|
||||
|
@ -217,6 +217,11 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
if (prefs.getBoolean("modified_key_layout", false)) {
|
||||
map[playerNum] = setModifiedKeys(playerNum);
|
||||
|
||||
custom[playerNum] = true;
|
||||
|
||||
globalLS_X[playerNum] = previousLS_X[playerNum] = 0.0f;
|
||||
globalLS_Y[playerNum] = previousLS_Y[playerNum] = 0.0f;
|
||||
} else if (InputDevice.getDevice(joys[i]).getName()
|
||||
.equals("Sony PLAYSTATION(R)3 Controller")) {
|
||||
map[playerNum] = new int[] {
|
||||
|
@ -356,7 +361,7 @@ public class GL2JNIActivity extends Activity {
|
|||
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
|
||||
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
|
||||
|
||||
if (xbox[playerNum] || nVidia[playerNum]) {
|
||||
if (custom[playerNum] || xbox[playerNum] || nVidia[playerNum]) {
|
||||
previousLS_X[playerNum] = globalLS_X[playerNum];
|
||||
previousLS_Y[playerNum] = globalLS_Y[playerNum];
|
||||
globalLS_X[playerNum] = LS_X;
|
||||
|
@ -372,7 +377,7 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
}
|
||||
|
||||
if ((xbox[playerNum] || nVidia[playerNum])
|
||||
if ((custom[playerNum] || xbox[playerNum] || nVidia[playerNum])
|
||||
&& ((globalLS_X[playerNum] == previousLS_X[playerNum] && globalLS_Y[playerNum] == previousLS_Y[playerNum]) || (previousLS_X[playerNum] == 0.0f && previousLS_Y[playerNum] == 0.0f)))
|
||||
// Only handle Left Stick on an Xbox 360 controller if there was
|
||||
// some actual motion on the stick,
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package com.reicast.emulator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import de.ankri.views.Switch;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -18,6 +26,7 @@ import android.widget.AdapterView;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
@ -94,9 +103,11 @@ public class InputModFragment extends Fragment {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
|
||||
ImageView a_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.a_button_icon);
|
||||
a_button_icon.setImageDrawable(getButtonImage(448, 0));
|
||||
final TextView a_button_text = (TextView) getView()
|
||||
.findViewById(R.id.a_button_key);
|
||||
getKeyCode("a_button", a_button_text);
|
||||
Button a_button = (Button) getView()
|
||||
.findViewById(R.id.a_button_edit);
|
||||
a_button.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -112,6 +123,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView b_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.b_button_icon);
|
||||
b_button_icon.setImageDrawable(getButtonImage(384, 0));
|
||||
final TextView b_button_text = (TextView) getView()
|
||||
.findViewById(R.id.b_button_key);
|
||||
getKeyCode("b_button", b_button_text);
|
||||
|
@ -130,6 +144,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView x_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.x_button_icon);
|
||||
x_button_icon.setImageDrawable(getButtonImage(256, 0));
|
||||
final TextView x_button_text = (TextView) getView()
|
||||
.findViewById(R.id.x_button_key);
|
||||
getKeyCode("x_button", x_button_text);
|
||||
|
@ -148,6 +165,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView y_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.y_button_icon);
|
||||
y_button_icon.setImageDrawable(getButtonImage(320, 0));
|
||||
final TextView y_button_text = (TextView) getView()
|
||||
.findViewById(R.id.y_button_key);
|
||||
getKeyCode("y_button", y_button_text);
|
||||
|
@ -166,6 +186,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView l_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.l_button_icon);
|
||||
l_button_icon.setImageDrawable(getButtonImage(78, 64));
|
||||
final TextView l_button_text = (TextView) getView()
|
||||
.findViewById(R.id.l_button_key);
|
||||
getKeyCode("l_button", l_button_text);
|
||||
|
@ -184,6 +207,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView r_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.r_button_icon);
|
||||
r_button_icon.setImageDrawable(getButtonImage(160, 64));
|
||||
final TextView r_button_text = (TextView) getView()
|
||||
.findViewById(R.id.r_button_key);
|
||||
getKeyCode("r_button", r_button_text);
|
||||
|
@ -295,6 +321,9 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageView start_button_icon = (ImageView) getView()
|
||||
.findViewById(R.id.start_button_icon);
|
||||
start_button_icon.setImageDrawable(getButtonImage(0, 64));
|
||||
final TextView start_button_text = (TextView) getView()
|
||||
.findViewById(R.id.start_button_key);
|
||||
getKeyCode("start_button", start_button_text);
|
||||
|
@ -319,6 +348,22 @@ public class InputModFragment extends Fragment {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable getButtonImage(int x, int y) {
|
||||
try {
|
||||
InputStream bitmap = parentActivity.getAssets().open("buttons.png");
|
||||
Bitmap image = BitmapFactory.decodeStream(bitmap);
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(32, 32);
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64, 64,
|
||||
matrix, true);
|
||||
BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
|
||||
return bmd;
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return parentActivity.getResources().getDrawable(R.drawable.input);
|
||||
}
|
||||
|
||||
private void getKeyCode(final String button, final TextView output) {
|
||||
int keyCode = mPrefs.getInt(button + player, -1);
|
||||
|
|
Loading…
Reference in New Issue