summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2013-10-25 16:52:46 -0400
committerLioncash <mathew1800@gmail.com>2013-10-25 16:52:46 -0400
commit9f36081a8f84cbef302a210a4c779250133ec5ba (patch)
treed3ec882a7516e34c42333e44f11e51829228820c /Source/Android
parent1267877e80d08a818983cc7b0c01a6f3e5061330 (diff)
[Android] Implement a very basic version of the input overlay configuration screen.
Still a bit of a mess, but this will get cleaned up during finalizations.
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/AndroidManifest.xml2
-rw-r--r--Source/Android/res/drawable/button_a.pngbin0 -> 5178 bytes
-rw-r--r--Source/Android/res/drawable/button_b.pngbin0 -> 4971 bytes
-rw-r--r--Source/Android/res/drawable/button_start.pngbin0 -> 1511 bytes
-rw-r--r--Source/Android/res/layout/emulation_view.xml8
-rw-r--r--Source/Android/res/layout/input_overlay_config_layout.xml32
-rw-r--r--Source/Android/res/xml/input_prefs.xml166
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java2
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java4
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java64
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayItem.java107
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/PrefsActivity.java3
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/cpu/CPUSettingsFragment.java (renamed from Source/Android/src/org/dolphinemu/dolphinemu/settings/CPUSettingsFragment.java)2
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java (renamed from Source/Android/src/org/dolphinemu/dolphinemu/settings/InputConfigFragment.java)13
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigActivity.java27
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigButton.java52
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java (renamed from Source/Android/src/org/dolphinemu/dolphinemu/settings/VideoSettingsFragment.java)2
17 files changed, 396 insertions, 88 deletions
diff --git a/Source/Android/AndroidManifest.xml b/Source/Android/AndroidManifest.xml
index 2e3964c65f..5b2a3cfee9 100644
--- a/Source/Android/AndroidManifest.xml
+++ b/Source/Android/AndroidManifest.xml
@@ -38,6 +38,8 @@
<activity android:name="org.dolphinemu.dolphinemu.emulation.EmulationActivity"
android:screenOrientation="landscape" />
+ <activity android:name="org.dolphinemu.dolphinemu.settings.input.InputOverlayConfigActivity"/>
+
<activity
android:name="org.dolphinemu.dolphinemu.settings.PrefsActivity"
android:label="@string/settings" />
diff --git a/Source/Android/res/drawable/button_a.png b/Source/Android/res/drawable/button_a.png
new file mode 100644
index 0000000000..7e685324ae
--- /dev/null
+++ b/Source/Android/res/drawable/button_a.png
Binary files differ
diff --git a/Source/Android/res/drawable/button_b.png b/Source/Android/res/drawable/button_b.png
new file mode 100644
index 0000000000..21da4c20f1
--- /dev/null
+++ b/Source/Android/res/drawable/button_b.png
Binary files differ
diff --git a/Source/Android/res/drawable/button_start.png b/Source/Android/res/drawable/button_start.png
new file mode 100644
index 0000000000..e79a9269ee
--- /dev/null
+++ b/Source/Android/res/drawable/button_start.png
Binary files differ
diff --git a/Source/Android/res/layout/emulation_view.xml b/Source/Android/res/layout/emulation_view.xml
index 62cbbe703e..c4648b577b 100644
--- a/Source/Android/res/layout/emulation_view.xml
+++ b/Source/Android/res/layout/emulation_view.xml
@@ -11,4 +11,12 @@
android:focusable="false"
android:focusableInTouchMode="false"/>
+ <!-- This is the onscreen input overlay -->
+ <org.dolphinemu.dolphinemu.emulation.overlay.InputOverlay
+ android:id="@+id/emulationControlOverlay"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"/>
+
</merge> \ No newline at end of file
diff --git a/Source/Android/res/layout/input_overlay_config_layout.xml b/Source/Android/res/layout/input_overlay_config_layout.xml
new file mode 100644
index 0000000000..868f0b3166
--- /dev/null
+++ b/Source/Android/res/layout/input_overlay_config_layout.xml
@@ -0,0 +1,32 @@
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/inputLayout"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <org.dolphinemu.dolphinemu.settings.input.InputOverlayConfigButton
+ android:id="@+id/buttonA"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:background="@drawable/button_a" />
+
+ <org.dolphinemu.dolphinemu.settings.input.InputOverlayConfigButton
+ android:id="@+id/buttonStart"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/buttonB"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:background="@drawable/button_start" />
+
+ <org.dolphinemu.dolphinemu.settings.input.InputOverlayConfigButton
+ android:id="@+id/buttonB"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_toLeftOf="@+id/buttonStart"
+ android:background="@drawable/button_b" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/Source/Android/res/xml/input_prefs.xml b/Source/Android/res/xml/input_prefs.xml
index 899e559480..5dc15ac75e 100644
--- a/Source/Android/res/xml/input_prefs.xml
+++ b/Source/Android/res/xml/input_prefs.xml
@@ -2,86 +2,90 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/input_settings">
+
+ <Preference
+ android:key="inputOverlayConfigPref"
+ android:title="Butts"/>
- <PreferenceScreen android:title="@string/gamecube_bindings">
- <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>
+ <PreferenceScreen android:title="@string/gamecube_bindings">
+ <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>
</PreferenceScreen> \ No newline at end of file
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
index 8b29e607d7..3695bfa40b 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
@@ -20,7 +20,7 @@ import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
-import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment;
+import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
/**
* Represents the about screen.
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java
index 912fc021c5..8b8f4e0551 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java
@@ -21,8 +21,8 @@ import android.view.WindowManager.LayoutParams;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
-import org.dolphinemu.dolphinemu.settings.InputConfigFragment;
-import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment;
+import org.dolphinemu.dolphinemu.settings.input.InputConfigFragment;
+import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
import java.util.List;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java
new file mode 100644
index 0000000000..c2272fdc5f
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java
@@ -0,0 +1,64 @@
+package org.dolphinemu.dolphinemu.emulation.overlay;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.View.OnTouchListener;
+
+/**
+ * Draws the interactive input overlay on top of the
+ * {@link NativeGLSurfaceView} that is rendering emulation.
+ */
+public final class InputOverlay extends SurfaceView implements OnTouchListener
+{
+ private final Set<InputOverlayItem> overlayItems = new HashSet<InputOverlayItem>();
+
+ /**
+ * Constructor
+ *
+ * @param context The current {@link Context}.
+ * @param attrs {@link AttributeSet} for parsing XML attributes.
+ */
+ public InputOverlay(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+
+ // Force draw
+ setWillNotDraw(false);
+
+ // Request focus for the overlay so it has priority on presses.
+ requestFocus();
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event)
+ {
+ switch (event.getAction())
+ {
+ case MotionEvent.ACTION_DOWN:
+ {
+ // TODO: Handle down presses.
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas)
+ {
+ super.onDraw(canvas);
+
+ for (InputOverlayItem item : overlayItems)
+ {
+ item.draw(canvas);
+ }
+ }
+}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayItem.java
new file mode 100644
index 0000000000..a45578b263
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlayItem.java
@@ -0,0 +1,107 @@
+package org.dolphinemu.dolphinemu.emulation.overlay;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+
+/**
+ * Represents a drawable image for the {@link InputOverlay}
+ */
+public final class InputOverlayItem
+{
+ // The image as a BitmapDrawable
+ private BitmapDrawable drawable;
+
+ // Width and height of the underlying image.
+ private int width;
+ private int height;
+
+ // X and Y coordinates to display this item at.
+ private int x;
+ private int y;
+
+ // Image scale factor.
+ private float scaleFactor = 1.0f;
+
+ // Rectangle that we draw this item to.
+ private Rect drawRect;
+
+ /**
+ * Constructor.
+ *
+ * @param res Reference to the app resources for fetching display metrics.
+ * @param resId Resource ID of the {@link BitmapDrawable} to encapsulate.
+ */
+ public InputOverlayItem(Resources res, int resId)
+ {
+ // Idiot-proof the constructor.
+ if (res == null)
+ throw new IllegalArgumentException("res cannot be null");
+
+ // Everything is valid, decode the filename as a bitmap.
+ drawable = (BitmapDrawable) res.getDrawable(resId);
+ Bitmap image = drawable.getBitmap();
+
+ // Set width/height
+ width = image.getWidth();
+ height = image.getHeight();
+
+ // Initialize rectangle to zero width, height, x, and y.
+ drawRect = new Rect();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param res Reference to the app resources for fetching display metrics.
+ * @param resId Resource ID of the {@link BitmapDrawable} to encapsulate.
+ * @param x X coordinate on the screen to place the control.
+ * @param y Y coordinate on the screen to place the control.
+ */
+ public InputOverlayItem(Resources res, int resId, int x, int y)
+ {
+ this(res, resId);
+
+ setPosition(x, y);
+ }
+
+ /**
+ * Sets the position of this item on the screen.
+ *
+ * @param x New x-coordinate for this image.
+ * @param y New y-coordinate for this image.
+ */
+ public void setPosition(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+
+ drawRect.set(x, y, x + (int)(width * scaleFactor), y + (int)(height * scaleFactor));
+ drawable.setBounds(drawRect);
+ }
+
+ /**
+ * Sets a new scaling factor for the current image.
+ *
+ * @param scaleFactor The new scaling factor. Note that 1.0 is normal size.
+ */
+ public void setScaleFactor(float scaleFactor)
+ {
+ this.scaleFactor = scaleFactor;
+
+ // Adjust for the new scale factor.
+ setPosition(x, y);
+ }
+
+ /**
+ * Draws this item to a given canvas.
+ *
+ * @param canvas The canvas to draw this item to.
+ */
+ public void draw(Canvas canvas)
+ {
+ drawable.draw(canvas);
+ }
+}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/PrefsActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/PrefsActivity.java
index 51153866e1..5368475319 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/PrefsActivity.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/PrefsActivity.java
@@ -7,6 +7,9 @@
package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.settings.cpu.CPUSettingsFragment;
+import org.dolphinemu.dolphinemu.settings.input.InputConfigFragment;
+import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/CPUSettingsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/cpu/CPUSettingsFragment.java
index 47f0cb7d35..77caec2b83 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/CPUSettingsFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/cpu/CPUSettingsFragment.java
@@ -4,7 +4,7 @@
* Refer to the license.txt file included.
*/
-package org.dolphinemu.dolphinemu.settings;
+package org.dolphinemu.dolphinemu.settings.cpu;
import org.dolphinemu.dolphinemu.R;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java
index a23f1b4a3f..2ada44ccff 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/InputConfigFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java
@@ -4,12 +4,13 @@
* Refer to the license.txt file included.
*/
-package org.dolphinemu.dolphinemu.settings;
+package org.dolphinemu.dolphinemu.settings.input;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
@@ -115,9 +116,17 @@ public final class InputConfigFragment extends PreferenceFragment
// Everything is set, show the dialog.
dialog.show();
+ return true;
+ }
+
+ if (pref.getKey().equals("inputOverlayConfigPref"))
+ {
+ Intent inputOverlayConfig = new Intent(getActivity(), InputOverlayConfigActivity.class);
+ startActivity(inputOverlayConfig);
+ return true;
}
- return true;
+ return false;
}
/**
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigActivity.java
new file mode 100644
index 0000000000..3084c181d1
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigActivity.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2013 Dolphin Emulator Project
+ * Licensed under GPLv2
+ * Refer to the license.txt file included.
+ */
+
+package org.dolphinemu.dolphinemu.settings.input;
+
+import org.dolphinemu.dolphinemu.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * {@link Activity} used for configuring the input overlay.
+ */
+public final class InputOverlayConfigActivity extends Activity
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ // Set the initial layout.
+ setContentView(R.layout.input_overlay_config_layout);
+ }
+}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigButton.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigButton.java
new file mode 100644
index 0000000000..cca596e85c
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputOverlayConfigButton.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2013 Dolphin Emulator Project
+ * Licensed under GPLv2
+ * Refer to the license.txt file included.
+ */
+
+package org.dolphinemu.dolphinemu.settings.input;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.widget.Button;
+
+/**
+ * A movable {@link Button} for use within the
+ * input overlay configuration screen.
+ */
+public final class InputOverlayConfigButton extends Button implements OnTouchListener
+{
+ /**
+ * Constructor
+ *
+ * @param context The current {@link Context}.
+ * @param attribs {@link AttributeSet} for parsing XML attributes.
+ */
+ public InputOverlayConfigButton(Context context, AttributeSet attribs)
+ {
+ super(context, attribs);
+
+ // Set the button as its own OnTouchListener.
+ setOnTouchListener(this);
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event)
+ {
+ switch(event.getAction())
+ {
+ // Only change the X/Y coordinates when we move the button.
+ case MotionEvent.ACTION_MOVE:
+ {
+ setX(getX() + event.getX());
+ setY(getY() + event.getY());
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/VideoSettingsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java
index fffea888a7..47f9ef475f 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/VideoSettingsFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/video/VideoSettingsFragment.java
@@ -4,7 +4,7 @@
* Refer to the license.txt file included.
*/
-package org.dolphinemu.dolphinemu.settings;
+package org.dolphinemu.dolphinemu.settings.video;
import android.app.Activity;
import android.content.SharedPreferences;