From 0142efbb2a4479d2e772d6c715057273638c7557 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 07:17:45 -0400 Subject: [PATCH 01/20] [Android] Add 'final' to all of the class declarations. This prevents inheritance of the classes (will throw a compiler error if you try and extend any of the classes). This is mainly syntactical sugar and form. Nothing major. --- Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java | 2 +- Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java | 2 +- .../src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/GameListActivity.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/GameListFragment.java | 2 +- Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java | 2 +- .../src/org/dolphinemu/dolphinemu/InputConfigAdapter.java | 2 +- .../src/org/dolphinemu/dolphinemu/InputConfigFragment.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java | 2 +- .../src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java | 2 +- Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java | 2 +- Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java | 2 +- .../Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java | 2 +- Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java index 4905027ae1..1e2ff17061 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -16,7 +16,7 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class AboutFragment extends Fragment { +public final class AboutFragment extends Fragment { private static Activity m_activity; private ListView mMainList; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java index d4177de5a4..ff4e989d28 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -17,7 +17,7 @@ import android.view.WindowManager; import java.io.*; import java.util.List; -public class DolphinEmulator extends Activity +public final class DolphinEmulator extends Activity { static private NativeGLSurfaceView GLview = null; static private boolean Running = false; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java index aa44ad83ca..f180a5b198 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java @@ -14,7 +14,7 @@ import android.widget.Toast; import java.io.File; import java.util.*; -public class FolderBrowser extends Fragment { +public final class FolderBrowser extends Fragment { private Activity m_activity; private FolderBrowserAdapter adapter; private ListView mDrawerList; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java index 0c38aa7b2f..ea326ecca4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java @@ -11,7 +11,7 @@ import android.widget.TextView; import java.util.List; -public class FolderBrowserAdapter extends ArrayAdapter{ +public final class FolderBrowserAdapter extends ArrayAdapter{ private Context c; private int id; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java index 845bf72bdd..564de80df4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java @@ -22,7 +22,7 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class GameListActivity extends Activity +public final class GameListActivity extends Activity implements GameListFragment.OnGameListZeroListener{ private int mCurFragmentNum = 0; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java index 986f33555b..e31072d2b7 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java @@ -10,7 +10,7 @@ import android.widget.TextView; import java.util.List; -public class GameListAdapter extends ArrayAdapter{ +public final class GameListAdapter extends ArrayAdapter{ private Context c; private int id; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java index 8e4d2cb244..a513530a28 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java @@ -24,7 +24,7 @@ import java.util.Set; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class GameListFragment extends Fragment +public final class GameListFragment extends Fragment { private ListView mMainList; private GameListAdapter mGameAdapter; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java index 427cd132f8..58cc291326 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java @@ -8,7 +8,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -public class GameListItem implements Comparable{ +public final class GameListItem implements Comparable{ private String name; private String data; private String path; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java index b0984dd08a..c7e23f3cfa 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java @@ -14,7 +14,7 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class InputConfigAdapter extends ArrayAdapter { +public final class InputConfigAdapter extends ArrayAdapter { private Context c; private int id; private List items; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java index b11dc4a34b..50e49a2383 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java @@ -18,7 +18,7 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class InputConfigFragment extends Fragment +public final class InputConfigFragment extends Fragment implements GameListActivity.OnGameConfigListener{ private Activity m_activity; private ListView mDrawerList; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java index 0a6f69a1d0..13bf8b9f3c 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java @@ -9,7 +9,7 @@ package org.dolphinemu.dolphinemu; /** * Represents a controller input item (button, stick, etc). */ -public class InputConfigItem implements Comparable{ +public final class InputConfigItem implements Comparable{ private String m_name; private String m_Config; private String m_bind; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java index 030c7ed823..edeb3eeac4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java @@ -4,7 +4,7 @@ import android.content.Context; import android.view.SurfaceHolder; import android.view.SurfaceView; -public class NativeGLSurfaceView extends SurfaceView { +public final class NativeGLSurfaceView extends SurfaceView { static private Thread myRun; static private boolean Running = false; static private boolean Created = false; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java index da58274c5f..5d6aa1ac23 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -13,7 +13,7 @@ import android.view.Surface; * Class which contains methods that interact * with the native side of the Dolphin code. */ -public class NativeLibrary { +public final class NativeLibrary { public static native void onTouchEvent(int Action, float X, float Y); public static native void onGamePadEvent(String Device, int Button, int Action); public static native void onGamePadMoveEvent(String Device, int Axis, float Value); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java index 4f088a58b4..5dd2afa969 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -17,7 +17,7 @@ import javax.microedition.khronos.opengles.GL10; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class PrefsFragment extends PreferenceFragment { +public final class PrefsFragment extends PreferenceFragment { private Activity m_activity; static public class VersionCheck { diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java index eb2143becb..d47cbc96ba 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java @@ -9,7 +9,7 @@ import android.widget.TextView; import java.util.List; -public class SideMenuAdapter extends ArrayAdapter{ +public final class SideMenuAdapter extends ArrayAdapter{ private Context c; private int id; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java index 6d204d0d69..25869b77e7 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java @@ -10,7 +10,7 @@ package org.dolphinemu.dolphinemu; /** * Represents an item that goes in the sidemenu of the app. */ -public class SideMenuItem implements Comparable +public final class SideMenuItem implements Comparable { private String m_name; private int m_id; From 39eeb370321d4da0f995b71814e95451b81a5152 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 07:33:17 -0400 Subject: [PATCH 02/20] [Android] Correct the accessibility scope of a method and variable in InputConfigFragment.java. Also, join a variable's declaration and assignment in the onMotionEvent() function. If no explicit accessibility term (private, protected, public, etc) is given, then the permission level is set to something called 'package-private' which means it is set to the scope of the whole package. So technically any class could have access to this method and variable, which is likely not what we want. --- .../org/dolphinemu/dolphinemu/InputConfigFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java index 50e49a2383..5be1416944 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java @@ -111,9 +111,9 @@ public final class InputConfigFragment extends Fragment } }; - static ArrayList m_values = new ArrayList(); + private static ArrayList m_values = new ArrayList(); - void AssignBind(String bind) + private void AssignBind(String bind) { InputConfigItem o = adapter.getItem(configPosition); adapter.remove(o); @@ -149,8 +149,8 @@ public final class InputConfigFragment extends Fragment { for (int a = 0; a < motions.size(); ++a) { - InputDevice.MotionRange range; - range = motions.get(a); + InputDevice.MotionRange range = motions.get(a); + if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f)) { AssignBind("Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-"); From 0cd94b5bc769286ce803d3a4045ce817334826cf Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Wed, 14 Aug 2013 11:47:23 +0000 Subject: [PATCH 03/20] VertexShaderGen: Cleanup. --- .../Core/VideoCommon/Src/VertexShaderGen.cpp | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index e44e01a13b..ad090fb839 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -92,8 +92,6 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ _assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens); _assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans); - bool is_d3d = (api_type & API_D3D9 || api_type == API_D3D11); - // uniforms if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) out.Write("layout(std140) uniform VSBlock {\n"); @@ -177,19 +175,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ if (components & VB_HAS_NRM0) out.Write(" float3 rawnorm0 : NORMAL0,\n"); if (components & VB_HAS_NRM1) - { - if (is_d3d) - out.Write(" float3 rawnorm1 : NORMAL1,\n"); - else - out.Write(" float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB); - } + out.Write(" float3 rawnorm1 : NORMAL1,\n"); if (components & VB_HAS_NRM2) - { - if (is_d3d) - out.Write(" float3 rawnorm2 : NORMAL2,\n"); - else - out.Write(" float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB); - } + out.Write(" float3 rawnorm2 : NORMAL2,\n"); if (components & VB_HAS_COL0) out.Write(" float4 color0 : COLOR0,\n"); if (components & VB_HAS_COL1) @@ -201,12 +189,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ out.Write(" float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i); } if (components & VB_HAS_POSMTXIDX) - { - if (is_d3d) - out.Write(" float4 blend_indices : BLENDINDICES,\n"); - else - out.Write(" float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB); - } + out.Write(" float4 blend_indices : BLENDINDICES,\n"); out.Write(" float4 rawpos : POSITION) {\n"); } out.Write("VS_OUTPUT o;\n"); @@ -471,7 +454,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ //write the true depth value, if the game uses depth textures pixel shaders will override with the correct values //if not early z culling will improve speed - if (is_d3d) + if (api_type & API_D3D9 || api_type == API_D3D11) { out.Write("o.pos.z = " I_DEPTHPARAMS".x * o.pos.w + o.pos.z * " I_DEPTHPARAMS".y;\n"); } From 6f1612d99cb7acd79434eac24916a9d0b0c52ff5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 14:33:47 -0400 Subject: [PATCH 04/20] [Android] Fix the gamepad settings view inflation. In some cases, it would fail to inflate correctly in the sense that it would only show the binding status and not the name of the actual control that was being binded. --- .../src/org/dolphinemu/dolphinemu/InputConfigAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java index c7e23f3cfa..ad3a5211c8 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java @@ -36,7 +36,7 @@ public final class InputConfigAdapter extends ArrayAdapter { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); + v = vi.inflate(id, parent, false); } final InputConfigItem o = items.get(position); if (o != null) { From 94397a44cc556198caf79da20f649a928758cbcc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 15:03:07 -0400 Subject: [PATCH 05/20] [Android] General formatting clean-up. Made some class variables final, since they should convey that they cannot be changed after the first assignment. Made the formatting consistent between files. --- .../dolphinemu/dolphinemu/AboutFragment.java | 21 ++++--- .../dolphinemu/DolphinEmulator.java | 36 ++++++++---- .../dolphinemu/dolphinemu/FolderBrowser.java | 17 ++++-- .../dolphinemu/FolderBrowserAdapter.java | 14 ++--- .../dolphinemu/GameListActivity.java | 56 +++++++++++++++---- .../dolphinemu/GameListAdapter.java | 45 ++++++++------- .../dolphinemu/GameListFragment.java | 26 ++++++--- .../dolphinemu/dolphinemu/GameListItem.java | 40 ++++++++----- .../dolphinemu/InputConfigAdapter.java | 43 +++++++------- .../dolphinemu/InputConfigFragment.java | 30 +++++++--- .../dolphinemu/InputConfigItem.java | 3 +- .../dolphinemu/NativeGLSurfaceView.java | 20 ++++--- .../dolphinemu/dolphinemu/NativeLibrary.java | 3 +- .../dolphinemu/dolphinemu/PrefsFragment.java | 30 +++++++--- .../dolphinemu/SideMenuAdapter.java | 24 ++++---- .../dolphinemu/dolphinemu/SideMenuItem.java | 4 +- 16 files changed, 267 insertions(+), 145 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java index 1e2ff17061..e05d1c7db2 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -16,7 +16,8 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public final class AboutFragment extends Fragment { +public final class AboutFragment extends Fragment +{ private static Activity m_activity; private ListView mMainList; @@ -25,13 +26,14 @@ public final class AboutFragment extends Fragment { boolean Configuring = false; boolean firstEvent = true; - public AboutFragment() { + public AboutFragment() + { // Empty constructor required for fragment subclasses } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) + { View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); mMainList = (ListView) rootView.findViewById(R.id.gamelist); @@ -47,15 +49,20 @@ public final class AboutFragment extends Fragment { return mMainList; } + @Override - public void onAttach(Activity activity) { + public void onAttach(Activity activity) + { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception - try { + try + { m_activity = activity; - } catch (ClassCastException e) { + } + catch (ClassCastException e) + { throw new ClassCastException(activity.toString() + " must implement OnGameListZeroListener"); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java index ff4e989d28..d1e23d1e53 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -25,24 +25,32 @@ public final class DolphinEmulator extends Activity private float screenWidth; private float screenHeight; - private void CopyAsset(String asset, String output) { + private void CopyAsset(String asset, String output) + { InputStream in = null; OutputStream out = null; - try { + + try + { in = getAssets().open(asset); out = new FileOutputStream(output); copyFile(in, out); in.close(); out.close(); - } catch(IOException e) { + } + catch(IOException e) + { Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e); } } - private void copyFile(InputStream in, OutputStream out) throws IOException { + private void copyFile(InputStream in, OutputStream out) throws IOException + { byte[] buffer = new byte[1024]; int read; - while((read = in.read(buffer)) != -1){ + + while((read = in.read(buffer)) != -1) + { out.write(buffer, 0, read); } } @@ -54,6 +62,7 @@ public final class DolphinEmulator extends Activity if (Running) NativeLibrary.StopEmulation(); } + @Override public void onPause() { @@ -61,6 +70,7 @@ public final class DolphinEmulator extends Activity if (Running) NativeLibrary.PauseEmulation(); } + @Override public void onResume() { @@ -71,7 +81,8 @@ public final class DolphinEmulator extends Activity /** Called when the activity is first created. */ @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) + { super.onCreate(savedInstanceState); if (savedInstanceState == null) { @@ -158,7 +169,8 @@ public final class DolphinEmulator extends Activity // Gets button presses @Override - public boolean dispatchKeyEvent(KeyEvent event) { + public boolean dispatchKeyEvent(KeyEvent event) + { int action = 0; // Special catch for the back key @@ -180,7 +192,8 @@ public final class DolphinEmulator extends Activity if (Running) { - switch (event.getAction()) { + switch (event.getAction()) + { case KeyEvent.ACTION_DOWN: action = 0; break; @@ -198,8 +211,10 @@ public final class DolphinEmulator extends Activity } @Override - public boolean dispatchGenericMotionEvent(MotionEvent event) { - if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running) { + public boolean dispatchGenericMotionEvent(MotionEvent event) + { + if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running) + { return super.dispatchGenericMotionEvent(event); } @@ -213,5 +228,4 @@ public final class DolphinEmulator extends Activity return true; } - } \ No newline at end of file diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java index f180a5b198..e60378c2cd 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java @@ -14,7 +14,8 @@ import android.widget.Toast; import java.io.File; import java.util.*; -public final class FolderBrowser extends Fragment { +public final class FolderBrowser extends Fragment +{ private Activity m_activity; private FolderBrowserAdapter adapter; private ListView mDrawerList; @@ -77,9 +78,9 @@ public final class FolderBrowser extends Fragment { mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(mMenuItemClickListener); } + @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if(currentDir == null) currentDir = new File(Environment.getExternalStorageDirectory().getPath()); @@ -111,14 +112,18 @@ public final class FolderBrowser extends Fragment { }; @Override - public void onAttach(Activity activity) { + public void onAttach(Activity activity) + { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception - try { + try + { m_activity = activity; - } catch (ClassCastException e) { + } + catch (ClassCastException e) + { throw new ClassCastException(activity.toString() + " must implement OnGameListZeroListener"); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java index ea326ecca4..dea96ce9d6 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java @@ -1,7 +1,6 @@ package org.dolphinemu.dolphinemu; import android.content.Context; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,13 +10,14 @@ import android.widget.TextView; import java.util.List; -public final class FolderBrowserAdapter extends ArrayAdapter{ +public final class FolderBrowserAdapter extends ArrayAdapter +{ + private final Context c; + private final int id; + private final List items; - private Context c; - private int id; - private List items; - - public FolderBrowserAdapter(Context context, int textViewResourceId, List objects) { + public FolderBrowserAdapter(Context context, int textViewResourceId, List objects) + { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java index 564de80df4..2bd61cb0f2 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java @@ -23,7 +23,8 @@ import java.util.List; * Refer to the license.txt file included. */ public final class GameListActivity extends Activity - implements GameListFragment.OnGameListZeroListener{ + implements GameListFragment.OnGameListZeroListener +{ private int mCurFragmentNum = 0; private Fragment mCurFragment; @@ -43,7 +44,8 @@ public final class GameListActivity extends Activity } @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) + { super.onCreate(savedInstanceState); setContentView(R.layout.gamelist_activity); mMe = this; @@ -94,16 +96,19 @@ public final class GameListActivity extends Activity FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } + public void SwitchPage(int toPage) { if (mCurFragmentNum == toPage) return; + switch (mCurFragmentNum) { // Folder browser case 1: recreateFragment(); - break; + break; + // Settings case 2: { @@ -147,6 +152,7 @@ public final class GameListActivity extends Activity } } break; + case 3: // Gamepad settings { InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter(); @@ -162,11 +168,13 @@ public final class GameListActivity extends Activity } } break; + case 0: // Game List case 4: // About /* Do Nothing */ break; } + switch(toPage) { case 0: @@ -177,6 +185,7 @@ public final class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 1: { Toast.makeText(mMe, getString(R.string.loading_browser), Toast.LENGTH_SHORT).show(); @@ -186,6 +195,7 @@ public final class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 2: { Toast.makeText(mMe, getString(R.string.loading_settings), Toast.LENGTH_SHORT).show(); @@ -195,6 +205,7 @@ public final class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 3: { Toast.makeText(mMe, getString(R.string.loading_gamepad), Toast.LENGTH_SHORT).show(); @@ -204,6 +215,7 @@ public final class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 4: { Toast.makeText(mMe, getString(R.string.about), Toast.LENGTH_SHORT).show(); @@ -213,10 +225,12 @@ public final class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + default: break; } } + private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) @@ -232,57 +246,75 @@ public final class GameListActivity extends Activity */ @Override - protected void onPostCreate(Bundle savedInstanceState) { + protected void onPostCreate(Bundle savedInstanceState) + { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(Configuration newConfig) + { super.onConfigurationChanged(newConfig); - // Pass any configuration change to the drawer toggls + // Pass any configuration change to the drawer toggle mDrawerToggle.onConfigurationChanged(newConfig); } /* Called whenever we call invalidateOptionsMenu() */ @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(Menu menu) + { return super.onPrepareOptionsMenu(menu); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) + { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. - if (mDrawerToggle.onOptionsItemSelected(item)) { + if (mDrawerToggle.onOptionsItemSelected(item)) + { return true; } + return super.onOptionsItemSelected(item); } + public void onBackPressed() { SwitchPage(0); } - public interface OnGameConfigListener { + public interface OnGameConfigListener + { public boolean onMotionEvent(MotionEvent event); public boolean onKeyEvent(KeyEvent event); } + // Gets move(triggers, joystick) events @Override - public boolean dispatchGenericMotionEvent(MotionEvent event) { + 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) { + public boolean dispatchKeyEvent(KeyEvent event) + { if (mCurFragmentNum == 3) + { if (((OnGameConfigListener)mCurFragment).onKeyEvent(event)) return true; + } + return super.dispatchKeyEvent(event); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java index e31072d2b7..d7170bb474 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java @@ -10,13 +10,14 @@ import android.widget.TextView; import java.util.List; -public final class GameListAdapter extends ArrayAdapter{ +public final class GameListAdapter extends ArrayAdapter +{ + private final Context c; + private final int id; + private final Listitems; - private Context c; - private int id; - private Listitems; - - public GameListAdapter(Context context, int textViewResourceId, List objects) { + public GameListAdapter(Context context, int textViewResourceId, List objects) + { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; @@ -29,26 +30,30 @@ public final class GameListAdapter extends ArrayAdapter{ } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { View v = convertView; - if (v == null) { + if (v == null) + { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } - final GameListItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.GameItemTitle); - TextView t2 = (TextView) v.findViewById(R.id.GameItemSubText); - ImageView v1 = (ImageView) v.findViewById(R.id.GameItemIcon); + final GameListItem item = items.get(position); + if (item != null) + { + TextView title = (TextView) v.findViewById(R.id.GameItemTitle); + TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText); + ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon); - if(t1!=null) - t1.setText(o.getName()); - if(t2!=null) - t2.setText(o.getData()); - if(v1!=null) - v1.setImageBitmap(o.getImage()); - } + if(title != null) + title.setText(item.getName()); + if(subtitle != null) + subtitle.setText(item.getData()); + if(icon != null) + icon.setImageBitmap(item.getImage()); + } + return v; } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java index a513530a28..13f66c1c83 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java @@ -31,13 +31,16 @@ public final class GameListFragment extends Fragment private static GameListActivity mMe; OnGameListZeroListener mCallback; - public interface OnGameListZeroListener { + public interface OnGameListZeroListener + { public void onZeroFiles(); } - public GameListFragment() { + public GameListFragment() + { // Empty constructor required for fragment subclasses } + private void Fill() { List fls = new ArrayList(); @@ -51,7 +54,7 @@ public final class GameListFragment extends Fragment { String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + a, ""); File currentDir = new File(BrowseDir); - File[]dirs = currentDir.listFiles(); + File[] dirs = currentDir.listFiles(); try { for(File entry : dirs) @@ -81,8 +84,8 @@ public final class GameListFragment extends Fragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) + { View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); mMainList = (ListView) rootView.findViewById(R.id.gamelist); mMainList.setOnItemClickListener(mGameItemClickListener); @@ -91,6 +94,7 @@ public final class GameListFragment extends Fragment return mMainList; } + private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) @@ -102,6 +106,7 @@ public final class GameListFragment extends Fragment } } }; + private void onFileClick(String o) { Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show(); @@ -111,16 +116,21 @@ public final class GameListFragment extends Fragment mMe.setResult(Activity.RESULT_OK, intent); mMe.finish(); } + @Override - public void onAttach(Activity activity) { + public void onAttach(Activity activity) + { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception - try { + try + { mCallback = (OnGameListZeroListener) activity; mMe = (GameListActivity) activity; - } catch (ClassCastException e) { + } + catch (ClassCastException e) + { throw new ClassCastException(activity.toString() + " must implement OnGameListZeroListener"); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java index 58cc291326..a9ef41c6d4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java @@ -8,36 +8,44 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -public final class GameListItem implements Comparable{ - private String name; - private String data; - private String path; +public final class GameListItem implements Comparable +{ + private final String name; + private final String data; + private final String path; + private final boolean isValid; private Bitmap image; - private boolean m_valid; - public GameListItem(Context ctx, String n,String d,String p, boolean valid) + public GameListItem(Context ctx, String name, String data, String path, boolean isValid) { - name = n; - data = d; - path = p; - m_valid = valid; + this.name = name; + this.data = data; + this.path = path; + this.isValid = isValid; + File file = new File(path); if (!file.isDirectory() && !path.equals("")) { int[] Banner = NativeLibrary.GetBanner(path); if (Banner[0] == 0) { - try { - InputStream path = ctx.getAssets().open("NoBanner.png"); - image = BitmapFactory.decodeStream(path); - } catch (IOException e) { + try + { + InputStream noBannerPath = ctx.getAssets().open("NoBanner.png"); + image = BitmapFactory.decodeStream(noBannerPath); + } + catch (IOException e) + { // TODO Auto-generated catch block e.printStackTrace(); } } else + { image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888); + } + name = NativeLibrary.GetTitle(path); } } @@ -56,13 +64,15 @@ public final class GameListItem implements Comparable{ { return path; } + public Bitmap getImage() { return image; } + public boolean isValid() { - return m_valid; + return isValid; } public int compareTo(GameListItem o) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java index ad3a5211c8..12541b8b37 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java @@ -14,13 +14,14 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public final class InputConfigAdapter extends ArrayAdapter { - private Context c; - private int id; - private List items; +public final class InputConfigAdapter extends ArrayAdapter +{ + private final Context c; + private final int id; + private final List items; - public InputConfigAdapter(Context context, int textViewResourceId, - List objects) { + public InputConfigAdapter(Context context, int textViewResourceId, List objects) + { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; @@ -31,26 +32,30 @@ public final class InputConfigAdapter extends ArrayAdapter { { return items.get(i); } + @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { View v = convertView; - if (v == null) { + if (v == null) + { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, parent, false); } - final InputConfigItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.FolderTitle); - TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle); + + final InputConfigItem item = items.get(position); + if (item != null) + { + TextView title = (TextView) v.findViewById(R.id.FolderTitle); + TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle); - if(t1!=null) - t1.setText(o.getName()); - if(t2!=null) - t2.setText(o.getBind()); + if(title != null) + title.setText(item.getName()); + + if(subtitle != null) + subtitle.setText(item.getBind()); } + return v; } - - - } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java index 5be1416944..530f8b1d3b 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java @@ -19,7 +19,8 @@ import java.util.List; * Refer to the license.txt file included. */ public final class InputConfigFragment extends Fragment - implements GameListActivity.OnGameConfigListener{ + implements GameListActivity.OnGameConfigListener +{ private Activity m_activity; private ListView mDrawerList; private InputConfigAdapter adapter; @@ -31,20 +32,24 @@ public final class InputConfigFragment extends Fragment { if (input == null) return "null"; // Happens when the inputdevice is from an unknown source + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) + { return input.getDescriptor(); + } else { List motions = input.getMotionRanges(); String fakeid = ""; + for (InputDevice.MotionRange range : motions) fakeid += range.getAxis(); + return fakeid; } } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { List Input = new ArrayList(); Input.add(new InputConfigItem(getString(R.string.draw_onscreen_controls), "Android-ScreenControls", "True")); @@ -77,6 +82,7 @@ public final class InputConfigFragment extends Fragment mDrawerList.setOnItemClickListener(mMenuItemClickListener); return mDrawerList; } + private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) @@ -100,6 +106,7 @@ public final class InputConfigFragment extends Fragment o.setBind(newBind); adapter.insert(o, position); break; + default: // gamepad controls Toast.makeText(m_activity, getString(R.string.press_button_to_config, o.getName()), Toast.LENGTH_SHORT).show(); @@ -120,10 +127,12 @@ public final class InputConfigFragment extends Fragment o.setBind(bind); adapter.insert(o, configPosition); } + public InputConfigAdapter getAdapter() { return adapter; } + // Called from GameListActivity public boolean onMotionEvent(MotionEvent event) { @@ -166,10 +175,12 @@ public final class InputConfigFragment extends Fragment } return true; } + public boolean onKeyEvent(KeyEvent event) { Log.w("InputConfigFragment", "Got Event " + event.getAction()); - switch (event.getAction()) { + switch (event.getAction()) + { case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_UP: if (Configuring) @@ -179,6 +190,7 @@ public final class InputConfigFragment extends Fragment Configuring = false; return true; } + default: break; } @@ -187,14 +199,18 @@ public final class InputConfigFragment extends Fragment } @Override - public void onAttach(Activity activity) { + public void onAttach(Activity activity) + { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception - try { + try + { m_activity = activity; - } catch (ClassCastException e) { + } + catch (ClassCastException e) + { throw new ClassCastException(activity.toString() + " must implement OnGameListZeroListener"); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java index 13bf8b9f3c..70e68261ec 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java @@ -9,7 +9,8 @@ package org.dolphinemu.dolphinemu; /** * Represents a controller input item (button, stick, etc). */ -public final class InputConfigItem implements Comparable{ +public final class InputConfigItem implements Comparable +{ private String m_name; private String m_Config; private String m_bind; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java index edeb3eeac4..ffe89714be 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java @@ -4,12 +4,14 @@ import android.content.Context; import android.view.SurfaceHolder; import android.view.SurfaceView; -public final class NativeGLSurfaceView extends SurfaceView { +public final class NativeGLSurfaceView extends SurfaceView +{ static private Thread myRun; static private boolean Running = false; static private boolean Created = false; - public NativeGLSurfaceView(Context context) { + public NativeGLSurfaceView(Context context) + { super(context); if (!Created) { @@ -20,8 +22,10 @@ public final class NativeGLSurfaceView extends SurfaceView { NativeLibrary.Run(getHolder().getSurface()); } }; + getHolder().addCallback(new SurfaceHolder.Callback() { - public void surfaceCreated(SurfaceHolder holder) { + public void surfaceCreated(SurfaceHolder holder) + { // TODO Auto-generated method stub if (!Running) { @@ -30,17 +34,17 @@ public final class NativeGLSurfaceView extends SurfaceView { } } - public void surfaceChanged(SurfaceHolder arg0, int arg1, - int arg2, int arg3) { + public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) + { // TODO Auto-generated method stub - } - public void surfaceDestroyed(SurfaceHolder arg0) { + public void surfaceDestroyed(SurfaceHolder arg0) + { // TODO Auto-generated method stub - } }); + Created = true; } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java index 5d6aa1ac23..14f7527c1d 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -13,7 +13,8 @@ import android.view.Surface; * Class which contains methods that interact * with the native side of the Dolphin code. */ -public final class NativeLibrary { +public final class NativeLibrary +{ public static native void onTouchEvent(int Action, float X, float Y); public static native void onGamePadEvent(String Device, int Button, int Action); public static native void onGamePadMoveEvent(String Device, int Axis, float Value); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java index 5dd2afa969..ad69a89a9d 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -17,10 +17,12 @@ import javax.microedition.khronos.opengles.GL10; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public final class PrefsFragment extends PreferenceFragment { +public final class PrefsFragment extends PreferenceFragment +{ private Activity m_activity; - static public class VersionCheck { + static public class VersionCheck + { EGL10 mEGL; EGLDisplay mEGLDisplay; EGLConfig[] mEGLConfigs; @@ -31,8 +33,8 @@ public final class PrefsFragment extends PreferenceFragment { String mThreadOwner; - public VersionCheck() { - + public VersionCheck() + { int[] version = new int[2]; int[] attribList = new int[] { EGL10.EGL_WIDTH, 1, @@ -69,11 +71,14 @@ public final class PrefsFragment extends PreferenceFragment { { return mGL.glGetString(GL10.GL_VENDOR); } + public String getRenderer() { return mGL.glGetString(GL10.GL_RENDERER); } - private EGLConfig chooseConfig() { + + private EGLConfig chooseConfig() + { int[] attribList = new int[] { EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, @@ -95,6 +100,7 @@ public final class PrefsFragment extends PreferenceFragment { return mEGLConfigs[0]; // Best match is probably the first configuration } } + static public boolean SupportsGLES3() { VersionCheck mbuffer = new VersionCheck(); @@ -134,8 +140,10 @@ public final class PrefsFragment extends PreferenceFragment { } return mSupportsGLES3; } + @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) + { super.onCreate(savedInstanceState); // Load the preferences from an XML resource @@ -197,14 +205,18 @@ public final class PrefsFragment extends PreferenceFragment { } @Override - public void onAttach(Activity activity) { + public void onAttach(Activity activity) + { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception - try { + try + { m_activity = activity; - } catch (ClassCastException e) { + } + catch (ClassCastException e) + { throw new ClassCastException(activity.toString() + " must implement OnGameListZeroListener"); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java index d47cbc96ba..11c071b026 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java @@ -9,14 +9,13 @@ import android.widget.TextView; import java.util.List; -public final class SideMenuAdapter extends ArrayAdapter{ - - private Context c; - private int id; - private Listitems; +public final class SideMenuAdapter extends ArrayAdapter +{ + private final Context c; + private final int id; + private final Listitems; - public SideMenuAdapter(Context context, int textViewResourceId, - List objects) + public SideMenuAdapter(Context context, int textViewResourceId, List objects) { super(context, textViewResourceId, objects); c = context; @@ -28,6 +27,7 @@ public final class SideMenuAdapter extends ArrayAdapter{ { return items.get(i); } + @Override public View getView(int position, View convertView, ViewGroup parent) { @@ -38,13 +38,13 @@ public final class SideMenuAdapter extends ArrayAdapter{ v = vi.inflate(id, null); } - final SideMenuItem o = items.get(position); - if (o != null) + final SideMenuItem item = items.get(position); + if (item != null) { - TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle); + TextView title = (TextView) v.findViewById(R.id.SideMenuTitle); - if(t1!=null) - t1.setText(o.getName()); + if(title != null) + title.setText(item.getName()); } return v; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java index 25869b77e7..51ebc93c19 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java @@ -12,8 +12,8 @@ package org.dolphinemu.dolphinemu; */ public final class SideMenuItem implements Comparable { - private String m_name; - private int m_id; + private final String m_name; + private final int m_id; /** * Constructor From ffdd79df3634a379cb94789e036434b80f16f22a Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 11 Aug 2013 16:30:19 +0200 Subject: [PATCH 06/20] Move VideoBackendBase from Common to VideoCommon --- Source/Core/Common/CMakeLists.txt | 1 - Source/Core/Common/Common.vcxproj | 4 +--- Source/Core/Common/Common.vcxproj.filters | 4 +--- Source/Core/VideoCommon/CMakeLists.txt | 1 + Source/Core/{Common => VideoCommon}/Src/VideoBackendBase.cpp | 2 ++ Source/Core/{Common => VideoCommon}/Src/VideoBackendBase.h | 0 Source/Core/VideoCommon/VideoCommon.vcxproj | 2 ++ Source/Core/VideoCommon/VideoCommon.vcxproj.filters | 2 ++ 8 files changed, 9 insertions(+), 7 deletions(-) rename Source/Core/{Common => VideoCommon}/Src/VideoBackendBase.cpp (99%) rename Source/Core/{Common => VideoCommon}/Src/VideoBackendBase.h (100%) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 480a08a0fc..0a1a26e530 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -20,7 +20,6 @@ set(SRCS Src/BreakPoints.cpp Src/Thread.cpp Src/Timer.cpp Src/Version.cpp - Src/VideoBackendBase.cpp Src/x64ABI.cpp Src/x64Analyzer.cpp Src/x64Emitter.cpp diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 822fafe74b..2982a5c720 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -195,7 +195,6 @@ - @@ -250,7 +249,6 @@ - @@ -261,4 +259,4 @@ - \ No newline at end of file + diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index d427b70cdd..ae434219fd 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -23,7 +23,6 @@ - @@ -92,7 +91,6 @@ - @@ -134,4 +132,4 @@ {f078f36e-a0ff-4cd0-95f8-476100d68e68} - \ No newline at end of file + diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index a4dad8293b..8503377779 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRCS Src/BPFunctions.cpp Src/VertexManagerBase.cpp Src/VertexShaderGen.cpp Src/VertexShaderManager.cpp + Src/VideoBackendBase.cpp Src/VideoConfig.cpp Src/VideoState.cpp Src/XFMemory.cpp diff --git a/Source/Core/Common/Src/VideoBackendBase.cpp b/Source/Core/VideoCommon/Src/VideoBackendBase.cpp similarity index 99% rename from Source/Core/Common/Src/VideoBackendBase.cpp rename to Source/Core/VideoCommon/Src/VideoBackendBase.cpp index 99bce01156..4769ede3a0 100644 --- a/Source/Core/Common/Src/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/Src/VideoBackendBase.cpp @@ -19,6 +19,8 @@ VideoBackend* g_video_backend = NULL; static VideoBackend* s_default_backend = NULL; #ifdef _WIN32 +#include + // http://msdn.microsoft.com/en-us/library/ms725491.aspx static bool IsGteVista() { diff --git a/Source/Core/Common/Src/VideoBackendBase.h b/Source/Core/VideoCommon/Src/VideoBackendBase.h similarity index 100% rename from Source/Core/Common/Src/VideoBackendBase.h rename to Source/Core/VideoCommon/Src/VideoBackendBase.h diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 1e7a56f578..c5896af1a6 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -213,6 +213,7 @@ + @@ -266,6 +267,7 @@ + diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters index 785e55877f..3f864b0e7e 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters @@ -4,6 +4,7 @@ + Vertex Loading @@ -128,6 +129,7 @@ + Vertex Loading From 26f58e1ba5e88959f73813d1fcc0dd586a0bd236 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 11 Aug 2013 17:08:12 +0200 Subject: [PATCH 07/20] Add an option to enable performance queries in gameini files, disable it by default --- Source/Core/VideoCommon/Src/PerfQueryBase.cpp | 6 ++++++ Source/Core/VideoCommon/Src/PerfQueryBase.h | 5 ++++- Source/Core/VideoCommon/Src/VideoConfig.cpp | 1 + Source/Core/VideoCommon/Src/VideoConfig.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/Src/PerfQueryBase.cpp b/Source/Core/VideoCommon/Src/PerfQueryBase.cpp index c537d176f6..af8bfa72e5 100644 --- a/Source/Core/VideoCommon/Src/PerfQueryBase.cpp +++ b/Source/Core/VideoCommon/Src/PerfQueryBase.cpp @@ -1,3 +1,9 @@ #include "PerfQueryBase.h" +#include "VideoConfig.h" PerfQueryBase* g_perf_query = 0; + +bool PerfQueryBase::ShouldEmulate() const +{ + return g_ActiveConfig.bPerfQueriesEnable; +} diff --git a/Source/Core/VideoCommon/Src/PerfQueryBase.h b/Source/Core/VideoCommon/Src/PerfQueryBase.h index b979449edb..bf5474b4db 100644 --- a/Source/Core/VideoCommon/Src/PerfQueryBase.h +++ b/Source/Core/VideoCommon/Src/PerfQueryBase.h @@ -25,9 +25,12 @@ enum PerfQueryGroup class PerfQueryBase { public: - PerfQueryBase() {}; + PerfQueryBase() {} virtual ~PerfQueryBase() {} + // Checks if performance queries are enabled in the gameini configuration. + bool ShouldEmulate() const; + // Begin querying the specified value for the following host GPU commands virtual void EnableQuery(PerfQueryGroup type) {} diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index d422c3d01d..b3e9a8815f 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -181,6 +181,7 @@ void VideoConfig::GameIniLoad(const char *ini_file) iniFile.GetIfExists("Video", "PH_ZFar", &sPhackvalue[1]); iniFile.GetIfExists("Video", "ZTPSpeedupHack", &bZTPSpeedHack); iniFile.GetIfExists("Video", "UseBBox", &bUseBBox); + iniFile.GetIfExists("Video", "PerfQueriesEnable", &bPerfQueriesEnable); } void VideoConfig::VerifyValidity() diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index a0a5cabacf..b856683595 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -108,6 +108,7 @@ struct VideoConfig // Hacks bool bEFBAccessEnable; bool bDlistCachingEnable; + bool bPerfQueriesEnable; bool bEFBCopyEnable; bool bEFBCopyCacheEnable; From c322bedf0ea7de19580a6ca500534e68bdd4d4f1 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 11 Aug 2013 17:09:20 +0200 Subject: [PATCH 08/20] Enable performance queries for Super Mario Sunshine --- Data/User/GameConfig/GMSE01.ini | 1 + Data/User/GameConfig/GMSP01.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/Data/User/GameConfig/GMSE01.ini b/Data/User/GameConfig/GMSE01.ini index 6c4191405b..e37c4ec387 100644 --- a/Data/User/GameConfig/GMSE01.ini +++ b/Data/User/GameConfig/GMSE01.ini @@ -152,6 +152,7 @@ PH_SZFar = 0 PH_ExtraParam = 0 PH_ZNear = PH_ZFar = +PerformanceQueriesEnable = True [Video_Settings] wideScreenHack = False diff --git a/Data/User/GameConfig/GMSP01.ini b/Data/User/GameConfig/GMSP01.ini index 4903413a33..fdac93eb91 100644 --- a/Data/User/GameConfig/GMSP01.ini +++ b/Data/User/GameConfig/GMSP01.ini @@ -74,6 +74,7 @@ PH_SZFar = 0 PH_ExtraParam = 0 PH_ZNear = PH_ZFar = +PerformanceQueriesEnable = True [Video_Settings] wideScreenHack = False From e60e50a198aec5b718ea5b1ac38685632247dffa Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 11 Aug 2013 17:13:29 +0200 Subject: [PATCH 09/20] Respect ShouldEmulate() in PerfQuery implementations for DX11 and OGL (ugly implem, but the current state of VideoCommon does not allow much better) --- .../Plugin_VideoDX11/Src/PerfQuery.cpp | 21 +++++++++++++++++++ .../Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PerfQuery.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PerfQuery.cpp index c634593361..3ba5e098ef 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PerfQuery.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PerfQuery.cpp @@ -28,6 +28,9 @@ PerfQuery::~PerfQuery() void PerfQuery::EnableQuery(PerfQueryGroup type) { + if (!ShouldEmulate()) + return; + // Is this sane? if (m_query_count > ARRAYSIZE(m_query_buffer) / 2) WeakFlush(); @@ -53,6 +56,9 @@ void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type) { + if (!ShouldEmulate()) + return; + // stop query if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) { @@ -69,6 +75,9 @@ void PerfQuery::ResetQuery() u32 PerfQuery::GetQueryResult(PerfQueryType type) { + if (!ShouldEmulate()) + return 0; + u32 result = 0; if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) @@ -93,6 +102,9 @@ u32 PerfQuery::GetQueryResult(PerfQueryType type) void PerfQuery::FlushOne() { + if (!ShouldEmulate()) + return; + auto& entry = m_query_buffer[m_query_read_pos]; UINT64 result = 0; @@ -113,12 +125,18 @@ void PerfQuery::FlushOne() // TODO: could selectively flush things, but I don't think that will do much void PerfQuery::FlushResults() { + if (!ShouldEmulate()) + return; + while (!IsFlushed()) FlushOne(); } void PerfQuery::WeakFlush() { + if (!ShouldEmulate()) + return; + while (!IsFlushed()) { auto& entry = m_query_buffer[m_query_read_pos]; @@ -143,6 +161,9 @@ void PerfQuery::WeakFlush() bool PerfQuery::IsFlushed() const { + if (!ShouldEmulate()) + return true; + return 0 == m_query_count; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp index 31d2af6107..a1582c0c62 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp @@ -23,6 +23,9 @@ PerfQuery::~PerfQuery() void PerfQuery::EnableQuery(PerfQueryGroup type) { + if (!ShouldEmulate()) + return; + // Is this sane? if (m_query_count > ARRAYSIZE(m_query_buffer) / 2) WeakFlush(); @@ -47,6 +50,9 @@ void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type) { + if (!ShouldEmulate()) + return; + // stop query if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) { @@ -56,11 +62,17 @@ void PerfQuery::DisableQuery(PerfQueryGroup type) bool PerfQuery::IsFlushed() const { + if (!ShouldEmulate()) + return true; + return 0 == m_query_count; } void PerfQuery::FlushOne() { + if (!ShouldEmulate()) + return; + auto& entry = m_query_buffer[m_query_read_pos]; GLuint result = 0; @@ -76,12 +88,18 @@ void PerfQuery::FlushOne() // TODO: could selectively flush things, but I don't think that will do much void PerfQuery::FlushResults() { + if (!ShouldEmulate()) + return; + while (!IsFlushed()) FlushOne(); } void PerfQuery::WeakFlush() { + if (!ShouldEmulate()) + return; + while (!IsFlushed()) { auto& entry = m_query_buffer[m_query_read_pos]; @@ -108,6 +126,9 @@ void PerfQuery::ResetQuery() u32 PerfQuery::GetQueryResult(PerfQueryType type) { + if (!ShouldEmulate()) + return 0; + u32 result = 0; if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) From 0e6b5bc5c8abc1fafcefeaf20eb64e81aa15765a Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 18:04:22 -0400 Subject: [PATCH 10/20] D3DBase: Don't pass the DEBUG flag when creating a device In order for this flag to not fail, you either need a Windows 8 machine or upgrade to the paid version of Visual Studio 2012. Not gonna happen. --- Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index c786c16e17..8ea7e88e3e 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -333,11 +333,7 @@ HRESULT Create(HWND wnd) swap_chain_desc.BufferDesc.Width = xres; swap_chain_desc.BufferDesc.Height = yres; -#if defined(_DEBUG) || defined(DEBUGFAST) - D3D11_CREATE_DEVICE_FLAG device_flags = (D3D11_CREATE_DEVICE_FLAG)(D3D11_CREATE_DEVICE_DEBUG|D3D11_CREATE_DEVICE_SINGLETHREADED); -#else D3D11_CREATE_DEVICE_FLAG device_flags = D3D11_CREATE_DEVICE_SINGLETHREADED; -#endif hr = PD3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, device_flags, supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS, D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device, From 92f8d795749e4284de2ce4219e5f6a729a12bdfa Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 17:05:11 -0400 Subject: [PATCH 11/20] NetPlay: Set the pad buffer size on server creation If we don't do this, then when the game starts we'll send out the buffer size to clients being a super large value of junk, and they'll hang forever trying to accumulate an input buffer a size that they'll never ever reach in a million years. This never manifested in release builds for some reason. --- Source/Core/DolphinWX/Src/NetWindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index e4bc377f37..064e852028 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -17,6 +17,7 @@ #include #define NETPLAY_TITLEBAR "Dolphin NetPlay" +#define INITIAL_PAD_BUFFER_SIZE 20 BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread) @@ -246,6 +247,7 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&) m_host_port_text->GetValue().ToULong(&port); netplay_server = new NetPlayServer(u16(port)); netplay_server->ChangeGame(game); + netplay_server->AdjustPadBufferSize(INITIAL_PAD_BUFFER_SIZE); if (netplay_server->is_connected) { #ifdef USE_UPNP @@ -346,7 +348,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game bottom_szr->Add(stop_btn); bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 ); wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20") - , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, 20); + , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE); padbuf_spin->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &NetPlayDiag::OnAdjustBuffer, this); bottom_szr->Add(padbuf_spin, 0, wxCENTER); } From 5241deaebe2d4b83cb9e00a86d847b5645b6ff0d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 17:50:21 -0400 Subject: [PATCH 12/20] NetPlay: Allow hosts to stop the game by closing the game window --- Source/Core/DolphinWX/Src/FrameTools.cpp | 1 + Source/Core/DolphinWX/Src/NetWindow.cpp | 10 +++++++++- Source/Core/DolphinWX/Src/NetWindow.h | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 30d5cd7bb3..8a7e3bf1e3 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1049,6 +1049,7 @@ void CFrame::DoStop() DoRecordingSave(); if(Movie::IsPlayingInput() || Movie::IsRecordingInput()) Movie::EndPlayInput(false); + NetPlay::StopGame(); wxBeginBusyCursor(); BootManager::Stop(); diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 064e852028..2a545df611 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -432,7 +432,7 @@ void NetPlayDiag::OnStart(wxCommandEvent&) void NetPlayDiag::OnStop(wxCommandEvent&) { - netplay_server->StopGame(); + NetPlay::StopGame(); } void NetPlayDiag::BootGame(const std::string& filename) @@ -661,3 +661,11 @@ void PadMapDiag::OnAdjust(wxCommandEvent& event) for (unsigned int i=0; i<4; ++i) m_mapping[i] = m_map_cbox[i]->GetSelection() - 1; } + +void NetPlay::StopGame() +{ + if (netplay_server != NULL) + netplay_server->StopGame(); + + // TODO: allow non-hosting clients to close the window +} diff --git a/Source/Core/DolphinWX/Src/NetWindow.h b/Source/Core/DolphinWX/Src/NetWindow.h index e798033eab..350cde7faf 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.h +++ b/Source/Core/DolphinWX/Src/NetWindow.h @@ -133,5 +133,10 @@ private: int* const m_mapping; }; +namespace NetPlay +{ + void StopGame(); +} + #endif // _NETWINDOW_H_ From 1c74e412e2385631f501a97d770a009a68e7ed6f Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 18:03:05 -0400 Subject: [PATCH 13/20] NetPlay: Remove the "Stop" button Now that the host can simply close the window, there's no need for this extra control. --- Source/Core/DolphinWX/Src/NetWindow.cpp | 8 -------- Source/Core/DolphinWX/Src/NetWindow.h | 1 - 2 files changed, 9 deletions(-) diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 2a545df611..4ba99dc184 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -343,9 +343,6 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game wxButton* const start_btn = new wxButton(panel, wxID_ANY, _("Start")); start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this); bottom_szr->Add(start_btn); - wxButton* const stop_btn = new wxButton(panel, wxID_ANY, _("Stop")); - stop_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStop, this); - bottom_szr->Add(stop_btn); bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 ); wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20") , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE); @@ -430,11 +427,6 @@ void NetPlayDiag::OnStart(wxCommandEvent&) netplay_server->StartGame(FindGame()); } -void NetPlayDiag::OnStop(wxCommandEvent&) -{ - NetPlay::StopGame(); -} - void NetPlayDiag::BootGame(const std::string& filename) { main_frame->BootGame(filename); diff --git a/Source/Core/DolphinWX/Src/NetWindow.h b/Source/Core/DolphinWX/Src/NetWindow.h index 350cde7faf..b63ba4d38e 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.h +++ b/Source/Core/DolphinWX/Src/NetWindow.h @@ -67,7 +67,6 @@ public: Common::FifoQueue chat_msgs; void OnStart(wxCommandEvent& event); - void OnStop(wxCommandEvent& event); // implementation of NetPlayUI methods void BootGame(const std::string& filename); From 998194246ce99dae73c372d4b821c8180ffad5a8 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 18:14:29 -0400 Subject: [PATCH 14/20] NetPlay: Disable the "Start" button while the game is running --- Source/Core/DolphinWX/Src/NetWindow.cpp | 12 +++++++++--- Source/Core/DolphinWX/Src/NetWindow.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 4ba99dc184..ac315025ba 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -283,6 +283,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game : wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize) , m_selected_game(game) , m_game_list(game_list) + , m_start_btn(NULL) { wxPanel* const panel = new wxPanel(this); @@ -340,9 +341,10 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL); if (is_hosting) { - wxButton* const start_btn = new wxButton(panel, wxID_ANY, _("Start")); - start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this); - bottom_szr->Add(start_btn); + m_start_btn = new wxButton(panel, wxID_ANY, _("Start")); + m_start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this); + bottom_szr->Add(m_start_btn); + bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 ); wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20") , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE); @@ -463,12 +465,16 @@ void NetPlayDiag::OnMsgStartGame() { wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); GetEventHandler()->AddPendingEvent(evt); + if (m_start_btn) + m_start_btn->Disable(); } void NetPlayDiag::OnMsgStopGame() { wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); GetEventHandler()->AddPendingEvent(evt); + if (m_start_btn) + m_start_btn->Enable(); } void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Src/NetWindow.h b/Source/Core/DolphinWX/Src/NetWindow.h index b63ba4d38e..75f9964e9d 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.h +++ b/Source/Core/DolphinWX/Src/NetWindow.h @@ -100,6 +100,7 @@ private: std::string m_selected_game; wxButton* m_game_btn; + wxButton* m_start_btn; std::vector m_playerids; From 7622d5b35411dee948a22e97a9f56337fc4695c9 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Thu, 15 Aug 2013 00:25:25 +0200 Subject: [PATCH 15/20] Only call SetGenerationMode from BPWritten if the cull mode changed. Should decrease CPU usage on the GPU thread by a bit in the OGL backend. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index ce0346b523..00cecf0082 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -153,7 +153,10 @@ void BPWritten(const BPCmd& bp) bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.multisampling, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.numindstages, bpmem.genMode.zfreeze); - SetGenerationMode(); + + // Only call SetGenerationMode when cull mode changes. + if (bp.changes & 0xC000) + SetGenerationMode(); break; } case BPMEM_IND_MTXA: // Index Matrix Changed From 1826fce9468d5ee7a55e7d121f4b30eef9916761 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 14 Aug 2013 18:35:52 -0400 Subject: [PATCH 16/20] NetPlay: Make sure the server knows it's stopped when it's stopped This is embarassing. --- Source/Core/Core/Src/NetPlayServer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Core/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp index 505e6a8f76..eaf02ea2c8 100644 --- a/Source/Core/Core/Src/NetPlayServer.cpp +++ b/Source/Core/Core/Src/NetPlayServer.cpp @@ -581,6 +581,8 @@ bool NetPlayServer::StopGame() std::lock_guard lks(m_crit.send); SendToClients(spac); + m_is_running = false; + return true; } From 9c27fedd6ddc9ead11bd83d119b0a7efb4c3f482 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 19:49:39 -0400 Subject: [PATCH 17/20] [Android] Remove the subtitles on all folders in the folder browser. No need to have the subtitle "Folder" when it's visibly indicated by the icon of a folder next to it. Now it looks like this: http://i.imgur.com/CbUSqgg.png --- Source/Android/res/layout/folderbrowser.xml | 2 +- .../dolphinemu/dolphinemu/FolderBrowser.java | 2 +- .../dolphinemu/FolderBrowserAdapter.java | 11 ++++++++++- .../dolphinemu/FolderBrowserItem.java | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Source/Android/res/layout/folderbrowser.xml b/Source/Android/res/layout/folderbrowser.xml index adfd72ed35..3f7be27552 100644 --- a/Source/Android/res/layout/folderbrowser.xml +++ b/Source/Android/res/layout/folderbrowser.xml @@ -39,5 +39,5 @@ android:gravity="center_vertical" android:text="Title" - android:textStyle="bold" />/> + android:textStyle="bold" /> diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java index e60378c2cd..3e2c93a3eb 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java @@ -45,7 +45,7 @@ public final class FolderBrowser extends Fragment { if(entry.isDirectory()) { - dir.add(new FolderBrowserItem(m_activity, entryName, getString(R.string.folder), entry.getAbsolutePath(), true)); + dir.add(new FolderBrowserItem(m_activity, entryName, entry.getAbsolutePath(), true)); } else { diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java index dea96ce9d6..979ad35865 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java @@ -1,6 +1,7 @@ package org.dolphinemu.dolphinemu; import android.content.Context; +import android.content.res.Resources; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -58,7 +59,15 @@ public final class FolderBrowserAdapter extends ArrayAdapter if(subtitleText != null) { - subtitleText.setText(item.getSubtitle()); + // Remove the subtitle for all folders, except for the parent directory folder. + if (item.isDirectory() && !item.getSubtitle().equals(c.getResources().getString(R.string.parent_directory))) + { + subtitleText.setVisibility(View.GONE); + } + else + { + subtitleText.setText(item.getSubtitle()); + } } if (iconView != null) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java index d2f8773e24..a895da8c43 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java @@ -37,6 +37,24 @@ public final class FolderBrowserItem implements Comparable this.underlyingFile = new File(path); } + /** + * Constructor. Initializes a FolderBrowserItem with an empty subtitle. + * + * @param ctx Context this FolderBrowserItem is being used in. + * @param name The name of the file/folder represented by this item. + * @param path The path of the file/folder represented by this item. + * @param isValid Whether or not this item represents a file type that can be handled. + */ + public FolderBrowserItem(Context ctx, String name, String path, boolean isValid) + { + this.ctx = ctx; + this.name = name; + this.subtitle = ""; + this.path = path; + this.isValid = isValid; + this.underlyingFile = new File(path); + } + /** * Gets the name of the file/folder represented by this FolderBrowserItem. * From 3380e47ca7e267c89a8e76ca273539c2c159985b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 13 Aug 2013 10:27:47 -0400 Subject: [PATCH 18/20] MemArena: Free memory for 64-bit machines Make the logic here a lot simpler. Patch contributed by Google Code user plbl4ster. --- Source/Core/Common/Src/MemArena.cpp | 44 ++++++++++------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/Source/Core/Common/Src/MemArena.cpp b/Source/Core/Common/Src/MemArena.cpp index 487788dc45..7be7c98c89 100644 --- a/Source/Core/Common/Src/MemArena.cpp +++ b/Source/Core/Common/Src/MemArena.cpp @@ -20,6 +20,7 @@ #include #endif #endif +#include #if defined(__APPLE__) static const char* ram_temp_file = "/tmp/gc_mem.tmp"; @@ -214,27 +215,7 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 bail: // Argh! ERROR! Free what we grabbed so far so we can try again. - for (int j = 0; j <= i; j++) - { - SKIP(flags, views[i].flags); - if (views[j].out_ptr_low && *views[j].out_ptr_low) - { - arena->ReleaseView(*views[j].out_ptr_low, views[j].size); - *views[j].out_ptr_low = NULL; - } - if (*views[j].out_ptr) - { -#ifdef _M_X64 - arena->ReleaseView(*views[j].out_ptr, views[j].size); -#else - if (!(views[j].flags & MV_MIRROR_PREVIOUS)) - { - arena->ReleaseView(*views[j].out_ptr, views[j].size); - } -#endif - *views[j].out_ptr = NULL; - } - } + MemoryMap_Shutdown(views, i+1, flags, arena); return false; } @@ -300,15 +281,20 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemArena *arena) { + std::set freeset; for (int i = 0; i < num_views; i++) { - SKIP(flags, views[i].flags); - if (views[i].out_ptr_low && *views[i].out_ptr_low) - arena->ReleaseView(*views[i].out_ptr_low, views[i].size); - if (*views[i].out_ptr && (views[i].out_ptr_low && *views[i].out_ptr != *views[i].out_ptr_low)) - arena->ReleaseView(*views[i].out_ptr, views[i].size); - *views[i].out_ptr = NULL; - if (views[i].out_ptr_low) - *views[i].out_ptr_low = NULL; + const MemoryView* view = &views[i]; + u8** outptrs[2] = {view->out_ptr_low, view->out_ptr}; + for (int j = 0; j < 2; j++) + { + u8** outptr = outptrs[j]; + if (outptr && *outptr && !freeset.count(*outptr)) + { + arena->ReleaseView(*outptr, view->size); + freeset.insert(*outptr); + *outptr = NULL; + } + } } } From 3e6f9d22db84fdaf904f72509596cac55d243c1e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 20:43:29 -0400 Subject: [PATCH 19/20] [Android] Add a faint divider line between each folder browser item. See here for how it looks: http://i.imgur.com/CGX9NTt.png --- Source/Android/res/layout/folderbrowser.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Android/res/layout/folderbrowser.xml b/Source/Android/res/layout/folderbrowser.xml index 3f7be27552..d3ee4538fa 100644 --- a/Source/Android/res/layout/folderbrowser.xml +++ b/Source/Android/res/layout/folderbrowser.xml @@ -40,4 +40,14 @@ android:gravity="center_vertical" android:text="Title" android:textStyle="bold" /> + + From 072fac4a740fad70a23c63c13503400d69fb9074 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Aug 2013 20:49:26 -0400 Subject: [PATCH 20/20] [Android] Remove a redundant LinearLayout in one of the layout files. --- Source/Android/res/layout/sidemenu.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/Android/res/layout/sidemenu.xml b/Source/Android/res/layout/sidemenu.xml index 76bc937489..6f4b8d3e5d 100644 --- a/Source/Android/res/layout/sidemenu.xml +++ b/Source/Android/res/layout/sidemenu.xml @@ -5,10 +5,6 @@ android:gravity="left" android:orientation="vertical" > - - -