Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'android-new-input-ui'
  • Loading branch information
lioncash committed Aug 26, 2013
2 parents 0e8f9d8 + 0815338 commit e051935
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 468 deletions.
4 changes: 4 additions & 0 deletions Source/Android/res/values-ja/strings.xml
Expand Up @@ -31,6 +31,9 @@
<string name="file_clicked">クリックされたファイル: </string>

<!-- Input Config Fragment -->
<string name="input_settings">入力設定</string>
<string name="input_binding">入力バインディング</string>
<string name="input_binding_descrip">このコントロールにバインドするための入力を移動または押してください。</string>
<string name="button_a">Aボタン</string>
<string name="button_b">Bボタン</string>
<string name="button_start">スタートボタン</string>
Expand Down Expand Up @@ -115,6 +118,7 @@
<!-- Miscellaneous -->
<string name="yes">はい</string>
<string name="no">いいえ</string>
<string name="cancel">キャンセル</string>
<string name="disabled">無効</string>
<string name="other">その他</string>

Expand Down
4 changes: 4 additions & 0 deletions Source/Android/res/values/strings.xml
Expand Up @@ -31,6 +31,9 @@
<string name="file_clicked">File clicked: </string>

<!-- Input Config Fragment -->
<string name="input_settings">Input</string>
<string name="input_binding">Input Binding</string>
<string name="input_binding_descrip">Press or move an input to bind it to this control.</string>
<string name="button_a">Button A</string>
<string name="button_b">Button B</string>
<string name="button_start">Button Start</string>
Expand Down Expand Up @@ -115,6 +118,7 @@
<!-- Miscellaneous -->
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="cancel">Cancel</string>
<string name="disabled">Disabled</string>
<string name="other">Other</string>

Expand Down
83 changes: 83 additions & 0 deletions Source/Android/res/xml/input_prefs.xml
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<Preference
android:key="InputA"
android:title="@string/button_a" />

<Preference
android:key="InputB"
android:title="@string/button_b" />

<Preference
android:key="InputX"
android:title="@string/button_x" />

<Preference
android:key="InputY"
android:title="@string/button_y" />

<Preference
android:key="InputZ"
android:title="@string/button_z" />

<Preference
android:key="InputStart"
android:title="@string/button_start" />

<Preference
android:key="DPadUp"
android:title="@string/dpad_up" />

<Preference
android:key="DPadDown"
android:title="@string/dpad_down" />

<Preference
android:key="DPadLeft"
android:title="@string/dpad_left" />

<Preference
android:key="DPadRight"
android:title="@string/dpad_right" />

<Preference
android:key="MainUp"
android:title="@string/main_stick_up" />

<Preference
android:key="MainDown"
android:title="@string/main_stick_down" />

<Preference
android:key="MainLeft"
android:title="@string/main_stick_left" />

<Preference
android:key="MainRight"
android:title="@string/main_stick_right" />

<Preference
android:key="CStickUp"
android:title="@string/c_stick_up" />

<Preference
android:key="CStickDown"
android:title="@string/c_stick_down" />

<Preference
android:key="CStickLeft"
android:title="@string/c_stick_left" />

<Preference
android:key="CStickRight"
android:title="@string/c_stick_right" />

<Preference
android:key="InputL"
android:title="@string/trigger_left" />

<Preference
android:key="InputR"
android:title="@string/trigger_right" />
</PreferenceScreen>
Expand Up @@ -22,7 +22,7 @@
import java.util.List;

import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import org.dolphinemu.dolphinemu.settings.InputConfigFragment;
import org.dolphinemu.dolphinemu.settings.UserPreferences;

public final class DolphinEmulator<MainActivity> extends Activity
Expand Down
43 changes: 33 additions & 10 deletions Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java
Expand Up @@ -15,10 +15,33 @@
*/
public final class NativeLibrary
{
/**
* Handles touch events.
*
* @param Action Mask for the action being performed.
* @param X Location on the screen's X-axis that the touch event occurred.
* @param Y Location on the screen's Y-axis that the touch event occurred.
*/
public static native void onTouchEvent(int Action, float X, float Y);

/**
* Handles button press events for a gamepad.
*
* @param Device The input descriptor of the gamepad.
* @param Button Key code identifying which button was pressed.
* @param Action Mask identifying which action is happing (button pressed down, or button released).
*/
public static native void onGamePadEvent(String Device, int Button, int Action);

/**
* Handles gamepad movement events.
*
* @param Device The device ID of the gamepad.
* @param Axis The axis ID
* @param Value The value of the axis represented by the given ID.
*/
public static native void onGamePadMoveEvent(String Device, int Axis, float Value);

/**
* Gets a value from a key in the given ini-based config file.
*
Expand All @@ -30,7 +53,7 @@
* @return the value stored at the key, or a default value if it doesn't exist.
*/
public static native String GetConfig(String configFile, String Section, String Key, String Default);

/**
* Sets a value to a key in the given ini config file.
*
Expand All @@ -40,22 +63,22 @@
* @param Value The string to set the ini key to.
*/
public static native void SetConfig(String configFile, String Section, String Key, String Value);

/**
* Sets the filename to be run during emulation.
*
* @param filename The filename to be run during emulation.
*/
public static native void SetFilename(String filename);

/**
* Sets the dimensions of the rendering window.
*
* @param width The new width of the rendering window (in pixels).
* @param height The new height of the rendering window (in pixels).
*/
public static native void SetDimensions(int width, int height);

/**
* Gets the embedded banner within the given ISO/ROM.
*
Expand All @@ -64,7 +87,7 @@
* @return an integer array containing the color data for the banner.
*/
public static native int[] GetBanner(String filename);

/**
* Gets the embedded title of the given ISO/ROM.
*
Expand All @@ -73,7 +96,7 @@
* @return the embedded title of the ISO/ROM.
*/
public static native String GetTitle(String filename);

/**
* Gets the Dolphin version string.
*
Expand All @@ -87,13 +110,13 @@
* @param surf The surface to render to.
*/
public static native void Run(Surface surf);

/** Unpauses emulation from a paused state. */
public static native void UnPauseEmulation();

/** Pauses emulation. */
public static native void PauseEmulation();

/** Stops emulation. */
public static native void StopEmulation();

Expand Down
Expand Up @@ -27,9 +27,6 @@
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowser;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigAdapter;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigItem;
import org.dolphinemu.dolphinemu.settings.PrefsActivity;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuItem;
Expand All @@ -49,16 +46,7 @@ public final class GameListActivity extends Activity
private SideMenuAdapter mDrawerAdapter;
private ListView mDrawerList;

/**
* Interface defining methods which handle
* the binding of specific key presses within
* the input mapping settings.
*/
public interface OnGameConfigListener
{
boolean onMotionEvent(MotionEvent event);
boolean onKeyEvent(KeyEvent event);
}


/**
* Called from the {@link GameListFragment}.
Expand All @@ -84,8 +72,7 @@ protected void onCreate(Bundle savedInstanceState)
dir.add(new SideMenuItem(getString(R.string.game_list), 0));
dir.add(new SideMenuItem(getString(R.string.browse_folder), 1));
dir.add(new SideMenuItem(getString(R.string.settings), 2));
dir.add(new SideMenuItem(getString(R.string.gamepad_config), 3));
dir.add(new SideMenuItem(getString(R.string.about), 4));
dir.add(new SideMenuItem(getString(R.string.about), 3));

mDrawerAdapter = new SideMenuAdapter(this, R.layout.sidemenu, dir);
mDrawerList.setAdapter(mDrawerAdapter);
Expand Down Expand Up @@ -142,25 +129,9 @@ public void SwitchPage(int toPage)
recreateFragment();
break;

case 3: // Gamepad settings
{
InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter();
for (int a = 0; a < adapter.getCount(); ++a)
{
InputConfigItem o = adapter.getItem(a);
String config = o.getConfig();
String bind = o.getBind();
String ConfigValues[] = config.split("-");
String Key = ConfigValues[0];
String Value = ConfigValues[1];
NativeLibrary.SetConfig("Dolphin.ini", Key, Value, bind);
}
}
break;

case 0: // Game List
case 2: // Settings
case 4: // About
case 3: // About
/* Do Nothing */
break;
}
Expand Down Expand Up @@ -197,16 +168,6 @@ public void SwitchPage(int toPage)
case 3:
{
mCurFragmentNum = 3;
mCurFragment = new InputConfigFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
invalidateOptionsMenu();
}
break;

case 4:
{
mCurFragmentNum = 4;
mCurFragment = new AboutFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
Expand Down Expand Up @@ -322,30 +283,4 @@ public void onBackPressed()
{
SwitchPage(0);
}

// Gets move(triggers, joystick) events
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event)
{
if (mCurFragmentNum == 3)
{
if (((OnGameConfigListener)mCurFragment).onMotionEvent(event))
return true;
}

return super.dispatchGenericMotionEvent(event);
}

// Gets button presses
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if (mCurFragmentNum == 3)
{
if (((OnGameConfigListener)mCurFragment).onKeyEvent(event))
return true;
}

return super.dispatchKeyEvent(event);
}
}

0 comments on commit e051935

Please sign in to comment.