Merge pull request #134 from NoblesseOblige/master
Feature request : key mapping / Rate reicast menu
This commit is contained in:
commit
960153d547
|
@ -252,6 +252,17 @@
|
|||
android:text="@string/remove" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonKeycodeEditor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/menu_edit_keycodes" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -0,0 +1,361 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="*" >
|
||||
|
||||
<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/modified_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/switchModifiedLayoutEnabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/a_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="A button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/a_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/b_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="B button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/b_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/x_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="X button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/x_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/y_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="Y button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/y_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/l_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="L button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/l_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/r_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="R button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/r_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/joystick_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="Joystick" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/joystick_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_left_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="DPad Left" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/dpad_left_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_right_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="DPad Right" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/dpad_right_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_up_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="DPad Up" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/dpad_up_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dpad_down_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="DPad Down" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/dpad_down_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<TableRow android:gravity="center_vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_button_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:text="Start Button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/start_button_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="8"
|
||||
android:text="@string/launch_editor" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -70,6 +70,16 @@
|
|||
android:layout_marginTop="2dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/question" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rate"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/profiler" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
|
|
|
@ -42,9 +42,17 @@
|
|||
<string name="select_controller_title">Select Controller</string>
|
||||
<string name="select_controller_message">Press any button on the controller to assign to port</string>
|
||||
<string name="controller_already_in_use">This controller is already in use!</string>
|
||||
<string name="modified_layout">Enable Custom Key Layout</string>
|
||||
|
||||
<string name="menu_edit_keycodes">Edit Key Bindings</string>
|
||||
<string name="map_keycode_title">Modify Controller</string>
|
||||
<string name="map_keycode_message">Press the new controller button for %1$s</string>
|
||||
|
||||
<string name="moga_pro_connect">MOGA Pro Connected!</string>
|
||||
<string name="moga_connect">MOGA Connected!</string>
|
||||
|
||||
<string name="about_title">About reicast</string>
|
||||
<string name="about_text">reicast is a dreamcast emulator\n\nVersion: %1$s\n\nWe work hard for you\nShare the love back and rate the app!</string>
|
||||
<string name="about_text">reicast is a dreamcast emulator\n\nVersion: %1$s\n\n</string>
|
||||
|
||||
<string-array name="images">
|
||||
<item>cdi</item>
|
||||
|
@ -69,6 +77,7 @@
|
|||
<item>Paths</item>
|
||||
<item>Input</item>
|
||||
<item>About</item>
|
||||
<item>Rate Me</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Nav Drawer List Item Icons -->
|
||||
|
@ -79,6 +88,7 @@
|
|||
<item>@drawable/open_folder</item>
|
||||
<item>@drawable/input</item>
|
||||
<item>@drawable/question</item>
|
||||
<item>@drawable/profiler</item>
|
||||
</array>
|
||||
|
||||
<!-- Content Description -->
|
||||
|
|
|
@ -39,8 +39,11 @@ public class GL2JNIActivity extends Activity {
|
|||
PopupWindow popUp;
|
||||
LayoutParams params;
|
||||
MOGAInput moga = new MOGAInput();
|
||||
static boolean[] 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];
|
||||
private SharedPreferences prefs;
|
||||
static boolean[] 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];
|
||||
|
||||
public static HashMap<Integer, String> deviceId_deviceDescriptor = new HashMap<Integer, String>();
|
||||
public static HashMap<String, Integer> deviceDescriptor_PlayerNum = new HashMap<String, Integer>();
|
||||
|
@ -81,7 +84,8 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent inte = new Intent(GL2JNIActivity.this, MainActivity.class);
|
||||
Intent inte = new Intent(GL2JNIActivity.this,
|
||||
MainActivity.class);
|
||||
startActivity(inte);
|
||||
GL2JNIActivity.this.finish();
|
||||
}
|
||||
|
@ -130,7 +134,7 @@ public class GL2JNIActivity extends Activity {
|
|||
protected void onCreate(Bundle icicle) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
moga.onCreate(this);
|
||||
|
||||
|
||||
createPopup();
|
||||
/*
|
||||
* try { //int rID =
|
||||
|
@ -151,146 +155,147 @@ public class GL2JNIActivity extends Activity {
|
|||
map = new int[4][];
|
||||
|
||||
// Populate device descriptor-to-player-map from preferences
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_1", null), 0);
|
||||
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_2", null), 1);
|
||||
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_3", null), 2);
|
||||
deviceDescriptor_PlayerNum.put(prefs.getString("device_descriptor_player_4", null), 3);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
deviceDescriptor_PlayerNum.put(
|
||||
prefs.getString("device_descriptor_player_1", null), 0);
|
||||
deviceDescriptor_PlayerNum.put(
|
||||
prefs.getString("device_descriptor_player_2", null), 1);
|
||||
deviceDescriptor_PlayerNum.put(
|
||||
prefs.getString("device_descriptor_player_3", null), 2);
|
||||
deviceDescriptor_PlayerNum.put(
|
||||
prefs.getString("device_descriptor_player_4", null), 3);
|
||||
|
||||
boolean controllerTwoConnected = false;
|
||||
boolean controllerThreeConnected = false;
|
||||
boolean controllerFourConnected = false;
|
||||
|
||||
for (HashMap.Entry<String, Integer> e : deviceDescriptor_PlayerNum.entrySet()) {
|
||||
for (HashMap.Entry<String, Integer> e : deviceDescriptor_PlayerNum
|
||||
.entrySet()) {
|
||||
String descriptor = e.getKey();
|
||||
Integer playerNum = e.getValue();
|
||||
|
||||
switch (playerNum) {
|
||||
case 1:
|
||||
if (descriptor != null)
|
||||
controllerTwoConnected = true;
|
||||
break;
|
||||
case 2:
|
||||
if (descriptor != null)
|
||||
controllerThreeConnected = true;
|
||||
break;
|
||||
case 3:
|
||||
if (descriptor != null)
|
||||
controllerFourConnected = true;
|
||||
break;
|
||||
case 1:
|
||||
if (descriptor != null)
|
||||
controllerTwoConnected = true;
|
||||
break;
|
||||
case 2:
|
||||
if (descriptor != null)
|
||||
controllerThreeConnected = true;
|
||||
break;
|
||||
case 3:
|
||||
if (descriptor != null)
|
||||
controllerFourConnected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
|
||||
JNIdc.initControllers(new boolean[] {controllerTwoConnected, controllerThreeConnected, controllerFourConnected});
|
||||
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
|
||||
controllerThreeConnected, controllerFourConnected });
|
||||
|
||||
int joys[] = InputDevice.getDeviceIds();
|
||||
for (int i = 0; i < joys.length; i++) {
|
||||
String descriptor = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
descriptor = InputDevice.getDevice(joys[i]).getDescriptor();
|
||||
} else {
|
||||
descriptor = InputDevice.getDevice(joys[i]).getName();
|
||||
}
|
||||
Log.d("reidc", "InputDevice ID: " + joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "
|
||||
+ InputDevice.getDevice(joys[i]).getName());
|
||||
Log.d("reidc", "InputDevice Descriptor: " + descriptor);
|
||||
deviceId_deviceDescriptor.put(joys[i], descriptor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < joys.length; i++) {
|
||||
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(joys[i]));
|
||||
|
||||
if (playerNum != null) {
|
||||
|
||||
if (InputDevice.getDevice(joys[i]).getName()
|
||||
.equals("Sony PLAYSTATION(R)3 Controller")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START
|
||||
|
||||
};
|
||||
} else if (InputDevice.getDevice(joys[i]).getName()
|
||||
.equals("Microsoft X-Box 360 pad")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START };
|
||||
|
||||
xbox[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()
|
||||
.contains("NVIDIA Corporation NVIDIA Controller")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START };
|
||||
nVidia[playerNum] = true;
|
||||
|
||||
globalLS_X[playerNum] = previousLS_X[playerNum] = 0.0f;
|
||||
globalLS_Y[playerNum] = previousLS_Y[playerNum] = 0.0f;
|
||||
} else if (!moga.isActive) { // Ouya controller
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START };
|
||||
int joys[] = InputDevice.getDeviceIds();
|
||||
for (int i = 0; i < joys.length; i++) {
|
||||
String descriptor = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
descriptor = InputDevice.getDevice(joys[i]).getDescriptor();
|
||||
} else {
|
||||
descriptor = InputDevice.getDevice(joys[i]).getName();
|
||||
}
|
||||
Log.d("reidc", "InputDevice ID: " + joys[i]);
|
||||
Log.d("reidc",
|
||||
"InputDevice Name: "
|
||||
+ InputDevice.getDevice(joys[i]).getName());
|
||||
Log.d("reidc", "InputDevice Descriptor: " + descriptor);
|
||||
deviceId_deviceDescriptor.put(joys[i], descriptor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < joys.length; i++) {
|
||||
Integer playerNum = deviceDescriptor_PlayerNum
|
||||
.get(deviceId_deviceDescriptor.get(joys[i]));
|
||||
|
||||
if (playerNum != null) {
|
||||
|
||||
if (prefs.getBoolean("modified_key_layout", false)) {
|
||||
map[playerNum] = setModifiedKeys();
|
||||
} else if (InputDevice.getDevice(joys[i]).getName()
|
||||
.equals("Sony PLAYSTATION(R)3 Controller")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START
|
||||
|
||||
};
|
||||
} else if (InputDevice.getDevice(joys[i]).getName()
|
||||
.equals("Microsoft X-Box 360 pad")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START
|
||||
};
|
||||
|
||||
xbox[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()
|
||||
.contains("NVIDIA Corporation NVIDIA Controller")) {
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START
|
||||
};
|
||||
nVidia[playerNum] = true;
|
||||
|
||||
globalLS_X[playerNum] = previousLS_X[playerNum] = 0.0f;
|
||||
globalLS_Y[playerNum] = previousLS_Y[playerNum] = 0.0f;
|
||||
} else if (!moga.isActive[playerNum]) { // Ouya controller
|
||||
map[playerNum] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
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,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_R1, key_CONT_START
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -306,55 +311,73 @@ public class GL2JNIActivity extends Activity {
|
|||
Toast.makeText(getApplicationContext(),
|
||||
"Press the back button for a menu", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private int[] setModifiedKeys() {
|
||||
return new int[] {
|
||||
prefs.getInt("a_button", OuyaController.BUTTON_O), key_CONT_A,
|
||||
prefs.getInt("b_button", OuyaController.BUTTON_A), key_CONT_B,
|
||||
prefs.getInt("y_button", OuyaController.BUTTON_Y), key_CONT_Y,
|
||||
prefs.getInt("x_button", OuyaController.BUTTON_U), key_CONT_X,
|
||||
|
||||
prefs.getInt("dpad_up", OuyaController.BUTTON_DPAD_UP), key_CONT_DPAD_UP,
|
||||
prefs.getInt("dpad_down", OuyaController.BUTTON_DPAD_DOWN), key_CONT_DPAD_DOWN,
|
||||
prefs.getInt("dpad_left", OuyaController.BUTTON_DPAD_LEFT), key_CONT_DPAD_LEFT,
|
||||
prefs.getInt("dpad_right", OuyaController.BUTTON_DPAD_RIGHT), key_CONT_DPAD_RIGHT,
|
||||
|
||||
prefs.getInt("start_button", OuyaController.BUTTON_MENU), key_CONT_START,
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
// Log.w("INPUT", event.toString() + " " + event.getSource());
|
||||
// Get all the axis for the KeyEvent
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
|
||||
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
Integer playerNum = deviceDescriptor_PlayerNum
|
||||
.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
|
||||
if (playerNum == null)
|
||||
return false;
|
||||
if (playerNum == null)
|
||||
return false;
|
||||
|
||||
if (!moga.isActive) {
|
||||
if (!moga.isActive[playerNum]) {
|
||||
|
||||
// Joystick
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
// 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);
|
||||
// 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 (xbox[playerNum] || nVidia[playerNum]) {
|
||||
previousLS_X[playerNum] = globalLS_X[playerNum];
|
||||
previousLS_Y[playerNum] = globalLS_Y[playerNum];
|
||||
globalLS_X[playerNum] = LS_X;
|
||||
globalLS_Y[playerNum] = LS_Y;
|
||||
}
|
||||
|
||||
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
|
||||
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
|
||||
|
||||
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
|
||||
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
|
||||
}
|
||||
|
||||
if (xbox[playerNum] || nVidia[playerNum]) {
|
||||
previousLS_X[playerNum] = globalLS_X[playerNum];
|
||||
previousLS_Y[playerNum] = globalLS_Y[playerNum];
|
||||
globalLS_X[playerNum] = LS_X;
|
||||
globalLS_Y[playerNum] = LS_Y;
|
||||
}
|
||||
|
||||
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
|
||||
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
|
||||
|
||||
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
|
||||
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((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,
|
||||
// so otherwise the event can be handled as a DPAD event
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
if ((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,
|
||||
// so otherwise the event can be handled as a DPAD event
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
@ -362,15 +385,15 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
}
|
||||
|
||||
private static final int key_CONT_B = 0x0002;
|
||||
private static final int key_CONT_A = 0x0004;
|
||||
private static final int key_CONT_START = 0x0008;
|
||||
private static final int key_CONT_DPAD_UP = 0x0010;
|
||||
private static final int key_CONT_DPAD_DOWN = 0x0020;
|
||||
private static final int key_CONT_DPAD_LEFT = 0x0040;
|
||||
private static final int key_CONT_DPAD_RIGHT = 0x0080;
|
||||
private static final int key_CONT_Y = 0x0200;
|
||||
private static final int key_CONT_X = 0x0400;
|
||||
private static final int key_CONT_B = 0x0002;
|
||||
private static final int key_CONT_A = 0x0004;
|
||||
private static final int key_CONT_START = 0x0008;
|
||||
private static final int key_CONT_DPAD_UP = 0x0010;
|
||||
private static final int key_CONT_DPAD_DOWN = 0x0020;
|
||||
private static final int key_CONT_DPAD_LEFT = 0x0040;
|
||||
private static final int key_CONT_DPAD_RIGHT = 0x0080;
|
||||
private static final int key_CONT_Y = 0x0200;
|
||||
private static final int key_CONT_X = 0x0400;
|
||||
|
||||
// TODO: Controller mapping in options. Trunk has Ouya layout. This is a DS3
|
||||
// layout.
|
||||
|
@ -407,42 +430,45 @@ public class GL2JNIActivity extends Activity {
|
|||
*/
|
||||
|
||||
boolean handle_key(Integer playerNum, int kc, boolean down) {
|
||||
if (playerNum == null)
|
||||
return false;
|
||||
if (playerNum == null)
|
||||
return false;
|
||||
|
||||
if (!moga.isActive) {
|
||||
if (!moga.isActive[playerNum]) {
|
||||
|
||||
boolean rav = false;
|
||||
for (int i = 0; i < map[playerNum].length; i += 2) {
|
||||
if (map[playerNum][i + 0] == kc) {
|
||||
if (down)
|
||||
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
|
||||
else
|
||||
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
|
||||
boolean rav = false;
|
||||
for (int i = 0; i < map[playerNum].length; i += 2) {
|
||||
if (map[playerNum][i + 0] == kc) {
|
||||
if (down)
|
||||
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
|
||||
else
|
||||
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
|
||||
|
||||
rav = true;
|
||||
break;
|
||||
rav = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rav;
|
||||
return rav;
|
||||
|
||||
} else {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
Integer playerNum = deviceDescriptor_PlayerNum
|
||||
.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
|
||||
return handle_key(playerNum, keyCode, false) || super.onKeyUp(keyCode, event);
|
||||
return handle_key(playerNum, keyCode, false)
|
||||
|| super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
Integer playerNum = deviceDescriptor_PlayerNum
|
||||
.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
|
||||
if (handle_key(playerNum, keyCode, true)) {
|
||||
if(playerNum == 0)
|
||||
if (playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -153,6 +153,22 @@ public class InputFragment extends Fragment {
|
|||
}
|
||||
|
||||
updateVibration();
|
||||
|
||||
Button buttonKeycodeEditor = (Button) getView().findViewById(
|
||||
R.id.buttonKeycodeEditor);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
buttonKeycodeEditor.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
InputModFragment inputModFrag = new InputModFragment();
|
||||
getActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, inputModFrag,
|
||||
"INPUT_MOD_FRAG").addToBackStack(null).commit();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
buttonKeycodeEditor.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVibration() {
|
||||
|
@ -172,7 +188,7 @@ public class InputFragment extends Fragment {
|
|||
InputDevice dev = InputDevice.getDevice(devideId);
|
||||
String descriptor = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
descriptor = dev.getDescriptor();
|
||||
descriptor = dev.getDescriptor();
|
||||
} else {
|
||||
descriptor = dev.getName();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,265 @@
|
|||
package com.reicast.emulator;
|
||||
|
||||
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.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
public class InputModFragment extends Fragment {
|
||||
|
||||
private Activity parentActivity;
|
||||
private SharedPreferences mPrefs;
|
||||
private Switch switchModifiedLayoutEnabled;
|
||||
|
||||
// Container Activity must implement this interface
|
||||
public interface OnClickListener {
|
||||
public void onMainBrowseSelected(String path_entry, boolean games);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.input_mod_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
parentActivity = getActivity();
|
||||
|
||||
mPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(parentActivity);
|
||||
|
||||
OnCheckedChangeListener modified_layout = new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
mPrefs.edit()
|
||||
.putBoolean("modified_key_layout", isChecked)
|
||||
.commit();
|
||||
}
|
||||
};
|
||||
switchModifiedLayoutEnabled = (Switch) getView().findViewById(
|
||||
R.id.switchModifiedLayoutEnabled);
|
||||
boolean layout = mPrefs.getBoolean(
|
||||
"modified_key_layout", false);
|
||||
if (layout) {
|
||||
switchModifiedLayoutEnabled.setChecked(true);
|
||||
} else {
|
||||
switchModifiedLayoutEnabled.setChecked(false);
|
||||
}
|
||||
switchModifiedLayoutEnabled.setOnCheckedChangeListener(modified_layout);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
|
||||
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() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("a_button", a_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView b_button_text = (TextView) getView()
|
||||
.findViewById(R.id.b_button_key);
|
||||
getKeyCode("b_button", b_button_text);
|
||||
Button b_button = (Button) getView()
|
||||
.findViewById(R.id.b_button_edit);
|
||||
b_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("b_button", b_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView x_button_text = (TextView) getView()
|
||||
.findViewById(R.id.x_button_key);
|
||||
getKeyCode("x_button", x_button_text);
|
||||
Button x_button = (Button) getView()
|
||||
.findViewById(R.id.x_button_edit);
|
||||
x_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("x_button", x_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView y_button_text = (TextView) getView()
|
||||
.findViewById(R.id.y_button_key);
|
||||
getKeyCode("y_button", y_button_text);
|
||||
Button y_button = (Button) getView()
|
||||
.findViewById(R.id.y_button_edit);
|
||||
y_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("y_button", y_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView l_button_text = (TextView) getView()
|
||||
.findViewById(R.id.l_button_key);
|
||||
getKeyCode("l_button", l_button_text);
|
||||
Button l_button = (Button) getView()
|
||||
.findViewById(R.id.l_button_edit);
|
||||
l_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("l_button", l_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView r_button_text = (TextView) getView()
|
||||
.findViewById(R.id.r_button_key);
|
||||
getKeyCode("r_button", r_button_text);
|
||||
Button r_button = (Button) getView()
|
||||
.findViewById(R.id.r_button_edit);
|
||||
r_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("r_button", r_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView joystick_text = (TextView) getView()
|
||||
.findViewById(R.id.joystick_key);
|
||||
getKeyCode("joystick", joystick_text);
|
||||
Button joystick = (Button) getView()
|
||||
.findViewById(R.id.joystick_edit);
|
||||
joystick.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("joystick", joystick_text);
|
||||
}
|
||||
});
|
||||
joystick.setEnabled(false);
|
||||
mPrefs.edit().remove("joystick").commit();
|
||||
// Still needs better support for identifying the entire stick
|
||||
|
||||
final TextView dpad_left_text = (TextView) getView()
|
||||
.findViewById(R.id.dpad_left_key);
|
||||
getKeyCode("dpad_left", dpad_left_text);
|
||||
Button dpad_left = (Button) getView()
|
||||
.findViewById(R.id.dpad_left_edit);
|
||||
dpad_left.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("dpad_left", dpad_left_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView dpad_right_text = (TextView) getView()
|
||||
.findViewById(R.id.dpad_right_key);
|
||||
getKeyCode("dpad_right", dpad_right_text);
|
||||
Button dpad_right = (Button) getView()
|
||||
.findViewById(R.id.dpad_right_edit);
|
||||
dpad_right.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("dpad_right", dpad_right_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView dpad_up_text = (TextView) getView()
|
||||
.findViewById(R.id.dpad_up_key);
|
||||
getKeyCode("dpad_up", dpad_up_text);
|
||||
Button dpad_up = (Button) getView()
|
||||
.findViewById(R.id.dpad_up_edit);
|
||||
dpad_up.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("dpad_up", dpad_up_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView dpad_down_text = (TextView) getView()
|
||||
.findViewById(R.id.dpad_down_key);
|
||||
getKeyCode("dpad_down", dpad_down_text);
|
||||
Button dpad_down = (Button) getView()
|
||||
.findViewById(R.id.dpad_down_edit);
|
||||
dpad_down.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("dpad_down", dpad_down_text);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView start_button_text = (TextView) getView()
|
||||
.findViewById(R.id.start_button_key);
|
||||
getKeyCode("start_button", start_button_text);
|
||||
Button start_button = (Button) getView()
|
||||
.findViewById(R.id.start_button_edit);
|
||||
start_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mapKeyCode("start_button", start_button_text);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
switchModifiedLayoutEnabled.setEnabled(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void getKeyCode(final String button, final TextView output) {
|
||||
int keyCode = mPrefs.getInt(button, -1);
|
||||
if (keyCode != -1) {
|
||||
String label = output.getText().toString();
|
||||
if (label.contains(":")) {
|
||||
label = label.substring(0, label.indexOf(":"));
|
||||
}
|
||||
output.setText(label + ": " + String.valueOf(keyCode));
|
||||
}
|
||||
}
|
||||
|
||||
private void mapKeyCode(final String button, final TextView output) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setTitle(getString(R.string.map_keycode_title));
|
||||
builder.setMessage(getString(R.string.map_keycode_message, button.replace("_", " ")));
|
||||
builder.setNegativeButton("Cancel",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setOnKeyListener(new Dialog.OnKeyListener() {
|
||||
public boolean onKey(DialogInterface dialog, int keyCode,
|
||||
KeyEvent event) {
|
||||
int value = mapButton(keyCode, event, button);
|
||||
dialog.dismiss();
|
||||
if (value != -1) {
|
||||
String label = output.getText().toString();
|
||||
if (label.contains(":")) {
|
||||
label = label.substring(0, label.indexOf(":"));
|
||||
}
|
||||
output.setText(label + ": " + String.valueOf(value));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
builder.create();
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private int mapButton(int keyCode, KeyEvent event, String button) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU
|
||||
|| keyCode == KeyEvent.KEYCODE_BACK
|
||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||
return -1;
|
||||
|
||||
mPrefs.edit().putInt(button, keyCode).commit();
|
||||
|
||||
return keyCode;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,9 @@ package com.reicast.emulator;
|
|||
/******************************************************************************/
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bda.controller.Controller;
|
||||
|
@ -20,6 +22,8 @@ import com.bda.controller.StateEvent;
|
|||
*/
|
||||
public class MOGAInput
|
||||
{
|
||||
private SharedPreferences prefs;
|
||||
|
||||
static final int DELAY = 1000 / 50; // 50 Hz
|
||||
|
||||
static final int ACTION_CONNECTED = Controller.ACTION_CONNECTED;
|
||||
|
@ -29,7 +33,8 @@ public class MOGAInput
|
|||
|
||||
Controller mController = null;
|
||||
|
||||
public boolean isActive = false;
|
||||
public boolean isActive[] = { false, false, false, false };
|
||||
public boolean isMogaPro[] = { false, false, false, false };
|
||||
|
||||
private static final int key_CONT_B = 0x0002;
|
||||
private static final int key_CONT_A = 0x0004;
|
||||
|
@ -42,18 +47,18 @@ public class MOGAInput
|
|||
private static final int key_CONT_X = 0x0400;
|
||||
|
||||
int[] map = new int[] {
|
||||
KeyEvent.KEYCODE_BUTTON_B, key_CONT_B,
|
||||
KeyEvent.KEYCODE_BUTTON_A, key_CONT_A,
|
||||
KeyEvent.KEYCODE_BUTTON_X, key_CONT_X,
|
||||
KeyEvent.KEYCODE_BUTTON_Y, key_CONT_Y,
|
||||
KeyEvent.KEYCODE_BUTTON_B, key_CONT_B,
|
||||
KeyEvent.KEYCODE_BUTTON_A, key_CONT_A,
|
||||
KeyEvent.KEYCODE_BUTTON_X, key_CONT_X,
|
||||
KeyEvent.KEYCODE_BUTTON_Y, key_CONT_Y,
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_UP, key_CONT_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT, key_CONT_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_DPAD_UP, key_CONT_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT, key_CONT_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
|
||||
|
||||
KeyEvent.KEYCODE_BUTTON_START, key_CONT_START,
|
||||
};
|
||||
KeyEvent.KEYCODE_BUTTON_START, key_CONT_START,
|
||||
};
|
||||
|
||||
Activity act;
|
||||
public MOGAInput()
|
||||
|
@ -93,6 +98,7 @@ public class MOGAInput
|
|||
protected void onCreate(Activity act)
|
||||
{
|
||||
this.act = act;
|
||||
setModifiedKeys();
|
||||
|
||||
mController = Controller.getInstance(act);
|
||||
mController.init();
|
||||
|
@ -136,6 +142,26 @@ public class MOGAInput
|
|||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void setModifiedKeys() {
|
||||
prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(act.getApplicationContext());
|
||||
if (prefs.getBoolean("modified_key_layout", false)) {
|
||||
map = new int[] {
|
||||
prefs.getInt("b_button", KeyEvent.KEYCODE_BUTTON_B), key_CONT_B,
|
||||
prefs.getInt("a_button", KeyEvent.KEYCODE_BUTTON_A), key_CONT_A,
|
||||
prefs.getInt("x_button", KeyEvent.KEYCODE_BUTTON_X), key_CONT_X,
|
||||
prefs.getInt("l_button", KeyEvent.KEYCODE_BUTTON_Y), key_CONT_Y,
|
||||
|
||||
prefs.getInt("dpad_up", KeyEvent.KEYCODE_DPAD_UP), key_CONT_DPAD_UP,
|
||||
prefs.getInt("dpad_down", KeyEvent.KEYCODE_DPAD_DOWN), key_CONT_DPAD_DOWN,
|
||||
prefs.getInt("dpad_left", KeyEvent.KEYCODE_DPAD_LEFT), key_CONT_DPAD_LEFT,
|
||||
prefs.getInt("dpad_right", KeyEvent.KEYCODE_DPAD_RIGHT), key_CONT_DPAD_RIGHT,
|
||||
|
||||
prefs.getInt("start_button", KeyEvent.KEYCODE_BUTTON_START), key_CONT_START,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ExampleControllerListener implements ControllerListener
|
||||
{
|
||||
|
@ -202,8 +228,20 @@ public class MOGAInput
|
|||
JNIdc.hide_osd();
|
||||
|
||||
if (event.getState() == StateEvent.STATE_CONNECTION && event.getAction() == ACTION_CONNECTED) {
|
||||
Toast.makeText(act.getApplicationContext(), "MOGA Connected!", Toast.LENGTH_SHORT).show();
|
||||
isActive = true;
|
||||
int mControllerVersion = mController.getState(Controller.STATE_CURRENT_PRODUCT_VERSION);
|
||||
String notify = null;
|
||||
if (mControllerVersion == Controller.ACTION_VERSION_MOGAPRO) {
|
||||
isActive[playerNum] = true;
|
||||
isMogaPro[playerNum] = true;
|
||||
notify = act.getApplicationContext().getString(R.string.moga_pro_connect);
|
||||
} else if (mControllerVersion == Controller.ACTION_VERSION_MOGA) {
|
||||
isActive[playerNum] = true;
|
||||
isMogaPro[playerNum] = false;
|
||||
notify = act.getApplicationContext().getString(R.string.moga_connect);
|
||||
}
|
||||
if (notify != null && !notify.equals(null)) {
|
||||
Toast.makeText(act.getApplicationContext(), notify, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,9 @@ public class MainActivity extends FragmentActivity implements
|
|||
// About
|
||||
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons
|
||||
.getResourceId(4, 0)));
|
||||
// Rate
|
||||
navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons
|
||||
.getResourceId(5, 0)));
|
||||
|
||||
// Recycle the typed array
|
||||
navMenuIcons.recycle();
|
||||
|
@ -236,23 +239,27 @@ public class MainActivity extends FragmentActivity implements
|
|||
MainActivity.this);
|
||||
|
||||
// set title
|
||||
alertDialogBuilder.setTitle("About reicast");
|
||||
alertDialogBuilder.setTitle(getString(R.string.about_title));
|
||||
|
||||
String versionName = "";
|
||||
try {
|
||||
PackageInfo pInfo = getPackageManager().getPackageInfo(
|
||||
getPackageName(), 0);
|
||||
versionName = pInfo.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// set dialog message
|
||||
alertDialogBuilder
|
||||
.setMessage("reicast is a dreamcast emulator")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Dismiss",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(
|
||||
DialogInterface dialog,
|
||||
int id) {
|
||||
// if this button is clicked,
|
||||
// close
|
||||
// current activity
|
||||
// FileBrowser.this.finish();
|
||||
}
|
||||
});
|
||||
.setMessage(getString(R.string.about_text, versionName))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Dismiss",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
// create alert dialog
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
@ -264,6 +271,17 @@ public class MainActivity extends FragmentActivity implements
|
|||
return false;
|
||||
}
|
||||
});
|
||||
findViewById(R.id.rate).setOnTouchListener(new OnTouchListener() {
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
// vib.vibrate(50);
|
||||
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=" + getPackageName())));
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -483,21 +501,11 @@ public class MainActivity extends FragmentActivity implements
|
|||
alertDialogBuilder
|
||||
.setMessage(getString(R.string.about_text, versionName))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Rate It",
|
||||
.setPositiveButton("Dismiss",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
startActivity(new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id="
|
||||
+ getPackageName())));
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Dismiss",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -508,6 +516,9 @@ public class MainActivity extends FragmentActivity implements
|
|||
alertDialog.show();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=" + getPackageName())));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue