diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-11-18 14:48:08 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-11-18 14:48:08 -0600 |
| commit | ae11fba0692dcdbf0fe6e4edb799f1bd100ddcf8 (patch) | |
| tree | 5dcf94a8e21b5e0c8d3f0e0e5be8f9c59f6af8dc /Source/Android/src | |
| parent | 07765aa6f0f84992fbb61e16025bd343821cc378 (diff) | |
[Android] Make joysticks less dumb from a configuration standpoint.
Diffstat (limited to 'Source/Android/src')
4 files changed, 39 insertions, 37 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java index 07bea528ba..7745deadba 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -30,16 +30,18 @@ public final class NativeLibrary public static final int BUTTON_DOWN = 7; public static final int BUTTON_LEFT = 8; public static final int BUTTON_RIGHT = 9; - public static final int STICK_MAIN_UP = 10; - public static final int STICK_MAIN_DOWN = 11; - public static final int STICK_MAIN_LEFT = 12; - public static final int STICK_MAIN_RIGHT = 13; - public static final int STICK_C_UP = 14; - public static final int STICK_C_DOWN = 15; - public static final int STICK_C_LEFT = 16; - public static final int STICK_C_RIGHT = 17; - public static final int TRIGGER_L = 18; - public static final int TRIGGER_R = 19; + public static final int STICK_MAIN = 10; + public static final int STICK_MAIN_UP = 11; + public static final int STICK_MAIN_DOWN = 12; + public static final int STICK_MAIN_LEFT = 13; + public static final int STICK_MAIN_RIGHT = 14; + public static final int STICK_C = 15; + public static final int STICK_C_UP = 16; + public static final int STICK_C_DOWN = 17; + public static final int STICK_C_LEFT = 18; + public static final int STICK_C_RIGHT = 19; + public static final int TRIGGER_L = 20; + public static final int TRIGGER_R = 21; } /** diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index 359f25f17e..26f628ed46 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -50,8 +50,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener overlayButtons.add(initializeOverlayButton(context, R.drawable.button_start, ButtonType.BUTTON_START)); overlayJoysticks.add(initializeOverlayJoystick(context, R.drawable.joy_outer, R.drawable.joy_inner, - ButtonType.STICK_MAIN_UP, ButtonType.STICK_MAIN_DOWN, - ButtonType.STICK_MAIN_LEFT, ButtonType.STICK_MAIN_RIGHT)); + ButtonType.STICK_MAIN)); // Set the on touch listener. setOnTouchListener(this); @@ -200,14 +199,11 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener * @param context The current {@link Context} * @param resOuter Resource ID for the outer image of the joystick (the static image that shows the circular bounds). * @param resInner Resource ID for the inner image of the joystick (the one you actually move around). - * @param axisUp Identifier for this type of axis. - * @param axisDown Identifier for this type of axis. - * @param axisLeft Identifier for this type of axis. - * @param axisRight Identifier for this type of axis. + * @param joystick Identifier for which joystick this is. * * @return the initialized {@link InputOverlayDrawableJoystick}. */ - private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context, int resOuter, int resInner, int axisUp, int axisDown, int axisLeft, int axisRight) + private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context, int resOuter, int resInner, int joystick) { // Resources handle for fetching the initial Drawable resource. final Resources res = context.getResources(); @@ -219,22 +215,26 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener final Bitmap bitmapOuter = BitmapFactory.decodeResource(res, resOuter); final Bitmap bitmapInner = BitmapFactory.decodeResource(res, resInner); - // TODO: Load coordinates for the drawable from the SharedPreference keys - // made from the overlay configuration window in the settings. + // String ID of the Drawable. This is what is passed into SharedPreferences + // to check whether or not a value has been set. + final String drawableId = res.getResourceEntryName(resOuter); + + // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. + // These were set in the input overlay configuration menu. + int drawableX = (int) sPrefs.getFloat(drawableId+"-X", 0f); + int drawableY = (int) sPrefs.getFloat(drawableId+"-Y", 0f); // Now set the bounds for the InputOverlayDrawableJoystick. // This will dictate where on the screen (and the what the size) the InputOverlayDrawableJoystick will be. int outerSize = bitmapOuter.getWidth() + 256; - int X = 0; - int Y = 0; - Rect outerRect = new Rect(X, Y, X + outerSize, Y + outerSize); + Rect outerRect = new Rect(drawableX, drawableY, drawableX + outerSize, drawableY + outerSize); Rect innerRect = new Rect(0, 0, outerSize / 4, outerSize / 4); final InputOverlayDrawableJoystick overlayDrawable = new InputOverlayDrawableJoystick(res, bitmapOuter, bitmapInner, outerRect, innerRect, - axisUp, axisDown, axisLeft, axisRight); + joystick); return overlayDrawable; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayDrawableJoystick.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayDrawableJoystick.java index a115305fa2..9b5dd6b860 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayDrawableJoystick.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayDrawableJoystick.java @@ -29,15 +29,12 @@ public final class InputOverlayDrawableJoystick extends BitmapDrawable * * @param res {@link Resources} instance. * @param bitmapOuter {@link Bitmap} to use with this Drawable. - * @param axisUp Identifier for this type of axis. - * @param axisDown Identifier for this type of axis. - * @param axisLeft Identifier for this type of axis. - * @param axisRight Identifier for this type of axis. + * @param joystick Identifier for which joystick this is. */ public InputOverlayDrawableJoystick(Resources res, Bitmap bitmapOuter, Bitmap bitmapInner, Rect rectOuter, Rect rectInner, - int axisUp, int axisDown, int axisLeft, int axisRight) + int joystick) { super(res, bitmapOuter); this.setBounds(rectOuter); @@ -45,10 +42,10 @@ public final class InputOverlayDrawableJoystick extends BitmapDrawable this.ringInner = new BitmapDrawable(res, bitmapInner); this.ringInner.setBounds(rectInner); SetInnerBounds(); - this.axisIDs[0] = axisUp; - this.axisIDs[1] = axisDown; - this.axisIDs[2] = axisLeft; - this.axisIDs[3] = axisRight; + this.axisIDs[0] = joystick + 1; + this.axisIDs[1] = joystick + 2; + this.axisIDs[2] = joystick + 3; + this.axisIDs[3] = joystick + 4; } @Override @@ -142,5 +139,6 @@ public final class InputOverlayDrawableJoystick extends BitmapDrawable int height = this.ringInner.getBounds().height() / 2; this.ringInner.setBounds(X - width, Y - height, X + width, Y + height); + } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java index 96f1783310..c24d21a74b 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java @@ -16,13 +16,12 @@ import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; -import android.view.*; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; import android.widget.AdapterView; import android.widget.ListView; - -import java.util.ArrayList; -import java.util.List; - import org.dolphinemu.dolphinemu.AboutFragment; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; @@ -31,6 +30,9 @@ import org.dolphinemu.dolphinemu.settings.PrefsActivity; import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter; import org.dolphinemu.dolphinemu.sidemenu.SideMenuItem; +import java.util.ArrayList; +import java.util.List; + /** * The activity that implements all of the functions * for the game list. |
