[Android] Format all Java files to be consistent.

This commit is contained in:
Lioncash 2013-08-22 03:43:07 -04:00
parent f09cafb2be
commit 7c99b0650b
17 changed files with 948 additions and 944 deletions

View File

@ -21,40 +21,40 @@ import org.dolphinemu.dolphinemu.settings.UserPreferences;
public final class DolphinEmulator<MainActivity> extends Activity public final class DolphinEmulator<MainActivity> extends Activity
{ {
static private NativeGLSurfaceView GLview = null; private static NativeGLSurfaceView GLview = null;
static private boolean Running = false; private static boolean Running = false;
private float screenWidth; private float screenWidth;
private float screenHeight; private float screenHeight;
private void CopyAsset(String asset, String output) private void CopyAsset(String asset, String output)
{ {
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
try try
{ {
in = getAssets().open(asset); in = getAssets().open(asset);
out = new FileOutputStream(output); out = new FileOutputStream(output);
copyFile(in, out); copyFile(in, out);
in.close(); in.close();
out.close(); out.close();
} }
catch(IOException e) catch (IOException e)
{ {
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, 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]; byte[] buffer = new byte[1024];
int read; int read;
while((read = in.read(buffer)) != -1) while ((read = in.read(buffer)) != -1)
{ {
out.write(buffer, 0, read); out.write(buffer, 0, read);
} }
} }
@Override @Override
@ -81,7 +81,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
NativeLibrary.UnPauseEmulation(); NativeLibrary.UnPauseEmulation();
} }
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState)
{ {
@ -228,7 +228,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
for (InputDevice.MotionRange range : motions) for (InputDevice.MotionRange range : motions)
{ {
NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis())); NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis()));
} }
return true; return true;

View File

@ -6,9 +6,9 @@ import android.view.SurfaceView;
public final class NativeGLSurfaceView extends SurfaceView public final class NativeGLSurfaceView extends SurfaceView
{ {
static private Thread myRun; private static Thread myRun;
static private boolean Running = false; private static boolean Running = false;
static private boolean Created = false; private static boolean Created = false;
public NativeGLSurfaceView(Context context) public NativeGLSurfaceView(Context context)
{ {
@ -18,21 +18,22 @@ public final class NativeGLSurfaceView extends SurfaceView
myRun = new Thread() myRun = new Thread()
{ {
@Override @Override
public void run() { public void run() {
NativeLibrary.Run(getHolder().getSurface()); NativeLibrary.Run(getHolder().getSurface());
} }
}; };
getHolder().addCallback(new SurfaceHolder.Callback() { getHolder().addCallback(new SurfaceHolder.Callback()
public void surfaceCreated(SurfaceHolder holder) {
{ public void surfaceCreated(SurfaceHolder holder)
// TODO Auto-generated method stub {
if (!Running) // TODO Auto-generated method stub
{ if (!Running)
myRun.start(); {
Running = true; myRun.start();
} Running = true;
} }
}
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3)
{ {

View File

@ -44,7 +44,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
final FolderBrowserItem item = items.get(position); final FolderBrowserItem item = items.get(position);
if (item != null) if (item != null)
{ {
ImageView iconView = (ImageView) v.findViewById(R.id.ImageIcon); ImageView iconView = (ImageView) v.findViewById(R.id.ImageIcon);
TextView mainText = (TextView) v.findViewById(R.id.FolderTitle); TextView mainText = (TextView) v.findViewById(R.id.FolderTitle);
TextView subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle); TextView subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle);
@ -73,16 +73,15 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
if (iconView != null) if (iconView != null)
{ {
if (item.isDirectory()) if (item.isDirectory())
{ {
iconView.setImageResource(R.drawable.ic_menu_folder); iconView.setImageResource(R.drawable.ic_menu_folder);
} }
else else
{ {
iconView.setImageResource(R.drawable.ic_menu_file); iconView.setImageResource(R.drawable.ic_menu_file);
} }
} }
} }
return v; return v;
} }

View File

@ -7,117 +7,116 @@ import java.io.File;
*/ */
public final class FolderBrowserItem implements Comparable<FolderBrowserItem> public final class FolderBrowserItem implements Comparable<FolderBrowserItem>
{ {
private final String name; private final String name;
private final String subtitle; private final String subtitle;
private final String path; private final String path;
private final boolean isValid; private final boolean isValid;
private final File underlyingFile; private final File underlyingFile;
/** /**
* Constructor * Constructor
* *
* @param name The name of the file/folder represented by this item. * @param name The name of the file/folder represented by this item.
* @param subtitle The subtitle of this FolderBrowserItem to display. * @param subtitle The subtitle of this FolderBrowserItem to display.
* @param path The path 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. * @param isValid Whether or not this item represents a file type that can be handled.
*/ */
public FolderBrowserItem(String name, String subtitle, String path, boolean isValid) public FolderBrowserItem(String name, String subtitle, String path, boolean isValid)
{ {
this.name = name; this.name = name;
this.subtitle = subtitle; this.subtitle = subtitle;
this.path = path; this.path = path;
this.isValid = isValid; this.isValid = isValid;
this.underlyingFile = new File(path); this.underlyingFile = new File(path);
} }
/** /**
* Constructor. Initializes a FolderBrowserItem with an empty subtitle. * 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 name The name of the file/folder represented by this item. * @param path The path 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.
* @param isValid Whether or not this item represents a file type that can be handled. */
*/ public FolderBrowserItem(String name, String path, boolean isValid)
public FolderBrowserItem(String name, String path, boolean isValid) {
{ this.name = name;
this.name = name; this.subtitle = "";
this.subtitle = ""; this.path = path;
this.path = path; this.isValid = isValid;
this.isValid = isValid; this.underlyingFile = new File(path);
this.underlyingFile = new File(path); }
}
/** /**
* Gets the name of the file/folder represented by this FolderBrowserItem. * Gets the name of the file/folder represented by this FolderBrowserItem.
* *
* @return the name of the file/folder represented by this FolderBrowserItem. * @return the name of the file/folder represented by this FolderBrowserItem.
*/ */
public String getName() public String getName()
{ {
return name; return name;
} }
/** /**
* Gets the subtitle text of this FolderBrowserItem. * Gets the subtitle text of this FolderBrowserItem.
* *
* @return the subtitle text of this FolderBrowserItem. * @return the subtitle text of this FolderBrowserItem.
*/ */
public String getSubtitle() public String getSubtitle()
{ {
return subtitle; return subtitle;
} }
/** /**
* Gets the path of the file/folder represented by this FolderBrowserItem. * Gets the path of the file/folder represented by this FolderBrowserItem.
* *
* @return the path of the file/folder represented by this FolderBrowserItem. * @return the path of the file/folder represented by this FolderBrowserItem.
*/ */
public String getPath() public String getPath()
{ {
return path; return path;
} }
/** /**
* Gets whether or not the file represented * Gets whether or not the file represented
* by this FolderBrowserItem is supported * by this FolderBrowserItem is supported
* and can be handled correctly. * and can be handled correctly.
* *
* @return whether or not the file represented * @return whether or not the file represented
* by this FolderBrowserItem is supported * by this FolderBrowserItem is supported
* and can be handled correctly. * and can be handled correctly.
*/ */
public boolean isValid() public boolean isValid()
{ {
return isValid; return isValid;
} }
/** /**
* Gets the {@link File} representation of the underlying file/folder * Gets the {@link File} representation of the underlying file/folder
* represented by this FolderBrowserItem. * represented by this FolderBrowserItem.
* *
* @return the {@link File} representation of the underlying file/folder * @return the {@link File} representation of the underlying file/folder
* represented by this FolderBrowserItem. * represented by this FolderBrowserItem.
*/ */
public File getUnderlyingFile() public File getUnderlyingFile()
{ {
return underlyingFile; return underlyingFile;
} }
/** /**
* Gets whether or not this FolderBrowserItem represents a directory. * Gets whether or not this FolderBrowserItem represents a directory.
* *
* @return true if this FolderBrowserItem represents a directory, false otherwise. * @return true if this FolderBrowserItem represents a directory, false otherwise.
*/ */
public boolean isDirectory() public boolean isDirectory()
{ {
return underlyingFile.isDirectory(); return underlyingFile.isDirectory();
} }
public int compareTo(FolderBrowserItem other) public int compareTo(FolderBrowserItem other)
{ {
if(this.name != null) if(this.name != null)
return this.name.toLowerCase().compareTo(other.getName().toLowerCase()); return this.name.toLowerCase().compareTo(other.getName().toLowerCase());
else else
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }

View File

@ -131,7 +131,7 @@ public final class GameListActivity extends Activity
case 0: // Game List case 0: // Game List
case 2: // Settings case 2: // Settings
case 4: // About case 4: // About
/* Do Nothing */ /* Do Nothing */
break; break;
} }
@ -271,5 +271,4 @@ public final class GameListActivity extends Activity
return super.dispatchKeyEvent(event); return super.dispatchKeyEvent(event);
} }
} }

View File

@ -14,55 +14,55 @@ import org.dolphinemu.dolphinemu.R;
public final class GameListAdapter extends ArrayAdapter<GameListItem> public final class GameListAdapter extends ArrayAdapter<GameListItem>
{ {
private final Context c; private final Context c;
private final int id; private final int id;
private final List<GameListItem>items; private final List<GameListItem>items;
public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects) public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects)
{ {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
c = context; c = context;
id = textViewResourceId; id = textViewResourceId;
items = objects; items = objects;
} }
public GameListItem getItem(int i) public GameListItem getItem(int i)
{ {
return items.get(i); return items.get(i);
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent)
{ {
View v = convertView; View v = convertView;
if (v == null) if (v == null)
{ {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, parent, false); v = vi.inflate(id, parent, false);
} }
final GameListItem item = items.get(position); final GameListItem item = items.get(position);
if (item != null) if (item != null)
{ {
TextView title = (TextView) v.findViewById(R.id.GameItemTitle); TextView title = (TextView) v.findViewById(R.id.GameItemTitle);
TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText); TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText);
ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon); ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon);
if(title != null) if (title != null)
title.setText(item.getName()); title.setText(item.getName());
if(subtitle != null) if (subtitle != null)
subtitle.setText(item.getData()); subtitle.setText(item.getData());
if(icon != null) if (icon != null)
{ {
icon.setImageBitmap(item.getImage()); icon.setImageBitmap(item.getImage());
icon.getLayoutParams().width = (int) ((860 / c.getResources().getDisplayMetrics().density) + 0.5); icon.getLayoutParams().width = (int) ((860 / c.getResources().getDisplayMetrics().density) + 0.5);
icon.getLayoutParams().height = (int)((340 / c.getResources().getDisplayMetrics().density) + 0.5); icon.getLayoutParams().height = (int)((340 / c.getResources().getDisplayMetrics().density) + 0.5);
} }
} }
return v; return v;
} }
} }

View File

@ -60,13 +60,13 @@ public final class GameListFragment extends Fragment
File[] dirs = currentDir.listFiles(); File[] dirs = currentDir.listFiles();
try try
{ {
for(File entry : dirs) for (File entry : dirs)
{ {
String entryName = entry.getName(); String entryName = entry.getName();
if (entryName.charAt(0) != '.') if (entryName.charAt(0) != '.')
{ {
if(!entry.isDirectory()) if (!entry.isDirectory())
{ {
if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
fls.add(new GameListItem(mMe.getApplicationContext(), entryName, getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true)); fls.add(new GameListItem(mMe.getApplicationContext(), entryName, getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true));
@ -74,7 +74,7 @@ public final class GameListFragment extends Fragment
} }
} }
} }
catch(Exception ignored) catch (Exception ignored)
{ {
} }
} }
@ -87,12 +87,12 @@ public final class GameListFragment extends Fragment
// so there should be no worries about accidentally removing a valid game. // so there should be no worries about accidentally removing a valid game.
for (int i = 0; i < fls.size(); i++) for (int i = 0; i < fls.size(); i++)
{ {
int indexNext = i+1; int indexNext = i+1;
if (indexNext < fls.size() && fls.get(indexNext).getPath().contains(fls.get(i).getPath())) if (indexNext < fls.size() && fls.get(indexNext).getPath().contains(fls.get(i).getPath()))
{ {
fls.remove(indexNext); fls.remove(indexNext);
} }
} }
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls); mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
@ -118,7 +118,7 @@ public final class GameListFragment extends Fragment
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{ {
GameListItem o = mGameAdapter.getItem(position); GameListItem o = mGameAdapter.getItem(position);
if(!(o.getData().equalsIgnoreCase(getString(R.string.folder))||o.getData().equalsIgnoreCase(getString(R.string.parent_directory)))) if (!(o.getData().equalsIgnoreCase(getString(R.string.folder))||o.getData().equalsIgnoreCase(getString(R.string.parent_directory))))
{ {
onFileClick(o.getPath()); onFileClick(o.getPath());
} }

View File

@ -12,27 +12,27 @@ import org.dolphinemu.dolphinemu.NativeLibrary;
public final class GameListItem implements Comparable<GameListItem> public final class GameListItem implements Comparable<GameListItem>
{ {
private String name; private String name;
private final String data; private final String data;
private final String path; private final String path;
private final boolean isValid; private final boolean isValid;
private Bitmap image; private Bitmap image;
public GameListItem(Context ctx, String name, String data, String path, boolean isValid) public GameListItem(Context ctx, String name, String data, String path, boolean isValid)
{ {
this.name = name; this.name = name;
this.data = data; this.data = data;
this.path = path; this.path = path;
this.isValid = isValid; this.isValid = isValid;
File file = new File(path); File file = new File(path);
if (!file.isDirectory() && !path.equals("")) if (!file.isDirectory() && !path.equals(""))
{ {
int[] Banner = NativeLibrary.GetBanner(path); int[] Banner = NativeLibrary.GetBanner(path);
if (Banner[0] == 0) if (Banner[0] == 0)
{ {
try try
{ {
// Open the no banner icon. // Open the no banner icon.
InputStream noBannerPath = ctx.getAssets().open("NoBanner.png"); InputStream noBannerPath = ctx.getAssets().open("NoBanner.png");
@ -42,53 +42,52 @@ public final class GameListItem implements Comparable<GameListItem>
// Scale the bitmap to match other banners. // Scale the bitmap to match other banners.
image = Bitmap.createScaledBitmap(image, 96, 32, false); image = Bitmap.createScaledBitmap(image, 96, 32, false);
} }
catch (IOException e) catch (IOException e)
{ {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}
else
{
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
}
} this.name = NativeLibrary.GetTitle(path);
else }
{ }
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
}
this.name = NativeLibrary.GetTitle(path); public String getName()
} {
} return name;
}
public String getName() public String getData()
{ {
return name; return data;
} }
public String getData() public String getPath()
{ {
return data; return path;
} }
public String getPath() public Bitmap getImage()
{ {
return path; return image;
} }
public Bitmap getImage()
{
return image;
}
public boolean isValid() public boolean isValid()
{ {
return isValid; return isValid;
} }
public int compareTo(GameListItem o) public int compareTo(GameListItem o)
{ {
if(this.name != null) if (this.name != null)
return this.name.toLowerCase().compareTo(o.getName().toLowerCase()); return this.name.toLowerCase().compareTo(o.getName().toLowerCase());
else else
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }

View File

@ -51,11 +51,11 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
TextView title = (TextView) v.findViewById(R.id.FolderTitle); TextView title = (TextView) v.findViewById(R.id.FolderTitle);
TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle); TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle);
if(title != null) if (title != null)
title.setText(item.getName()); title.setText(item.getName());
if(subtitle != null) if (subtitle != null)
subtitle.setText(item.getBind()); subtitle.setText(item.getBind());
} }
return v; return v;

View File

@ -51,6 +51,7 @@ public final class InputConfigFragment extends Fragment
return fakeid; return fakeid;
} }
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
@ -116,7 +117,7 @@ public final class InputConfigFragment extends Fragment
// Called from GameListActivity // Called from GameListActivity
public boolean onMotionEvent(MotionEvent event) public boolean onMotionEvent(MotionEvent event)
{ {
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)) if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)
return false; return false;
InputDevice input = event.getDevice(); InputDevice input = event.getDevice();

View File

@ -41,7 +41,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
/** /**
* Constructor that creates an InputConfigItem * Constructor that creates an InputConfigItem
* that has a default binding of "None" * that has a default binding of "None".
* *
* @param name Name of the input config item. * @param name Name of the input config item.
* @param config Name of the key in the configuration file that this control modifies. * @param config Name of the key in the configuration file that this control modifies.
@ -72,7 +72,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
} }
/** /**
* Gets the currently set binding of this InputConfigItem * Gets the currently set binding of this InputConfigItem.
* *
* @return the currently set binding of this InputConfigItem * @return the currently set binding of this InputConfigItem
*/ */
@ -93,7 +93,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
public int compareTo(InputConfigItem o) public int compareTo(InputConfigItem o)
{ {
if(this.m_name != null) if (this.m_name != null)
return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase()); return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase());
else else
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View File

@ -19,62 +19,62 @@ import android.preference.PreferenceFragment;
*/ */
public final class CPUSettingsFragment extends PreferenceFragment public final class CPUSettingsFragment extends PreferenceFragment
{ {
private Activity m_activity; private Activity m_activity;
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState)
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Load the preferences from an XML resource // Load the preferences from an XML resource
addPreferencesFromResource(R.xml.cpu_prefs); addPreferencesFromResource(R.xml.cpu_prefs);
final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref"); final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref");
// //
// Set valid emulation cores depending on the CPU architecture // Set valid emulation cores depending on the CPU architecture
// that the Android device is running on. // that the Android device is running on.
// //
if (Build.CPU_ABI.contains("x86")) if (Build.CPU_ABI.contains("x86"))
{ {
cpuCores.setEntries(R.array.emuCoreEntriesX86); cpuCores.setEntries(R.array.emuCoreEntriesX86);
cpuCores.setEntryValues(R.array.emuCoreValuesX86); cpuCores.setEntryValues(R.array.emuCoreValuesX86);
} }
else if (Build.CPU_ABI.contains("arm")) else if (Build.CPU_ABI.contains("arm"))
{ {
cpuCores.setEntries(R.array.emuCoreEntriesARM); cpuCores.setEntries(R.array.emuCoreEntriesARM);
cpuCores.setEntryValues(R.array.emuCoreValuesARM); cpuCores.setEntryValues(R.array.emuCoreValuesARM);
} }
else else
{ {
cpuCores.setEntries(R.array.emuCoreEntriesOther); cpuCores.setEntries(R.array.emuCoreEntriesOther);
cpuCores.setEntryValues(R.array.emuCoreValuesOther); cpuCores.setEntryValues(R.array.emuCoreValuesOther);
} }
} }
@Override @Override
public void onAttach(Activity activity) public void onAttach(Activity activity)
{ {
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try try
{ {
m_activity = activity; m_activity = activity;
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new ClassCastException(activity.toString()); throw new ClassCastException(activity.toString());
} }
} }
@Override @Override
public void onDestroy() public void onDestroy()
{ {
super.onDestroy(); super.onDestroy();
// When this fragment is destroyed, force the settings to be saved to the ini file. // When this fragment is destroyed, force the settings to be saved to the ini file.
UserPreferences.SaveConfigToDolphinIni(m_activity); UserPreferences.SaveConfigToDolphinIni(m_activity);
} }
} }

View File

@ -7,6 +7,7 @@
package org.dolphinemu.dolphinemu.settings; package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.ActionBar.Tab; import android.app.ActionBar.Tab;
@ -24,123 +25,128 @@ import android.support.v4.view.ViewPager;
*/ */
public final class PrefsActivity extends Activity implements ActionBar.TabListener public final class PrefsActivity extends Activity implements ActionBar.TabListener
{ {
/** /**
* The {@link android.support.v4.view.PagerAdapter} that will provide org.dolphinemu.dolphinemu.settings for each of the * The {@link android.support.v4.view.PagerAdapter} that will provide org.dolphinemu.dolphinemu.settings for each of the
* sections. We use a {@link android.support.v4.app.FragmentPagerAdapter} derivative, which will * sections. We use a {@link android.support.v4.app.FragmentPagerAdapter} derivative, which will
* keep every loaded fragment in memory. If this becomes too memory intensive, it may be best to * keep every loaded fragment in memory. If this becomes too memory intensive, it may be best to
* switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}. * switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/ */
SectionsPagerAdapter mSectionsPagerAdapter; SectionsPagerAdapter mSectionsPagerAdapter;
/** /**
* The {@link ViewPager} that will host the section contents. * The {@link ViewPager} that will host the section contents.
*/ */
ViewPager mViewPager; ViewPager mViewPager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.prefs_viewpager); setContentView(R.layout.prefs_viewpager);
// Set up the action bar. // Set up the action bar.
final ActionBar actionBar = getActionBar(); final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three // Create the adapter that will return a fragment for each of the three
// primary sections of the app. // primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter. // Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding // When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have // tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab. // a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
{ {
@Override @Override
public void onPageSelected(int position) public void onPageSelected(int position)
{ {
actionBar.setSelectedNavigationItem(position); actionBar.setSelectedNavigationItem(position);
} }
} ); } );
// Create a tab with text corresponding to the page title defined by // Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements // the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when // the TabListener interface, as the callback (listener) for when
// this tab is selected. // this tab is selected.
actionBar.addTab(actionBar.newTab().setText(R.string.cpu_settings).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.cpu_settings).setTabListener(this));
actionBar.addTab(actionBar.newTab().setText(R.string.video_settings).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Input Settings").setTabListener(this));
actionBar.addTab(actionBar.newTab().setText(R.string.video_settings).setTabListener(this));
}
} public void onTabReselected(Tab arg0, FragmentTransaction arg1)
{
// Do nothing.
}
public void onTabReselected(Tab arg0, FragmentTransaction arg1) public void onTabSelected(Tab tab, FragmentTransaction ft)
{ {
// Do nothing. // When the given tab is selected, switch to the corresponding page in the ViewPager.
} mViewPager.setCurrentItem(tab.getPosition());
}
public void onTabSelected(Tab tab, FragmentTransaction ft) public void onTabUnselected(Tab tab, FragmentTransaction ft)
{ {
// When the given tab is selected, switch to the corresponding page in the ViewPager. // Do nothing.
mViewPager.setCurrentItem(tab.getPosition()); }
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) /**
{ * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the
// Do nothing. * sections/tabs/pages.
} */
public final class SectionsPagerAdapter extends FragmentPagerAdapter
{
public SectionsPagerAdapter(FragmentManager fm)
{
super(fm);
}
/** @Override
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the public Fragment getItem(int position)
* sections/tabs/pages. {
*/ switch(position)
public class SectionsPagerAdapter extends FragmentPagerAdapter {
{ case 0:
return new CPUSettingsFragment();
public SectionsPagerAdapter(FragmentManager fm) case 1:
{ return new InputConfigFragment();
super(fm);
}
@Override case 2:
public Fragment getItem(int position) return new VideoSettingsFragment();
{
switch(position)
{
case 0:
return new CPUSettingsFragment();
case 1: default: // Should never happen.
return new VideoSettingsFragment(); return null;
}
}
default: // Should never happen. @Override
return null; public int getCount()
} {
} // Show total pages.
return 3;
}
@Override @Override
public int getCount() public CharSequence getPageTitle(int position)
{ {
// Show total pages. switch(position)
return 2; {
} case 0:
return getString(R.string.cpu_settings).toUpperCase();
@Override case 1:
public CharSequence getPageTitle(int position) return "Input Settings";//getString(R.string)
{
switch(position)
{
case 0:
return getString(R.string.cpu_settings).toUpperCase();
case 1: case 2:
return getString(R.string.video_settings).toUpperCase(); return getString(R.string.video_settings).toUpperCase();
default: // Should never happen. default: // Should never happen.
return null; return null;
} }
} }
} }
} }

View File

@ -21,215 +21,215 @@ import android.preference.PreferenceManager;
*/ */
public final class UserPreferences public final class UserPreferences
{ {
/** /**
* Loads the set config items from the Dolphin config files to the shared preferences of this front-end * Loads the set config items from the Dolphin config files to the shared preferences of this front-end
* *
* @param ctx The context used to retrieve the SharedPreferences instance. * @param ctx The context used to retrieve the SharedPreferences instance.
*/ */
public static void LoadDolphinConfigToPrefs(Context ctx) public static void LoadDolphinConfigToPrefs(Context ctx)
{ {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
// Get an editor. // Get an editor.
SharedPreferences.Editor editor = prefs.edit(); SharedPreferences.Editor editor = prefs.edit();
// Add the settings. // Add the settings.
editor.putString("cpuCorePref", getConfig("Dolphin.ini", "Core", "CPUCore", "3")); editor.putString("cpuCorePref", getConfig("Dolphin.ini", "Core", "CPUCore", "3"));
editor.putBoolean("dualCorePref", getConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True")); editor.putBoolean("dualCorePref", getConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True"));
editor.putString("gpuPref", getConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer")); editor.putString("gpuPref", getConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer"));
editor.putBoolean("drawOnscreenControls", getConfig("Dolphin.ini", "Android", "ScreenControls", "True").equals("True")); editor.putBoolean("drawOnscreenControls", getConfig("Dolphin.ini", "Android", "ScreenControls", "True").equals("True"));
editor.putString("internalResolution", getConfig("gfx_opengl.ini", "Settings", "EFBScale", "2") ); editor.putString("internalResolution", getConfig("gfx_opengl.ini", "Settings", "EFBScale", "2") );
editor.putString("anisotropicFiltering", getConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", "0")); editor.putString("anisotropicFiltering", getConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", "0"));
editor.putBoolean("scaledEFBCopy", getConfig("gfx_opengl.ini", "Hacks", "EFBScaleCopy", "True").equals("True")); editor.putBoolean("scaledEFBCopy", getConfig("gfx_opengl.ini", "Hacks", "EFBScaleCopy", "True").equals("True"));
editor.putBoolean("perPixelLighting", getConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", "False").equals("True")); editor.putBoolean("perPixelLighting", getConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", "False").equals("True"));
editor.putBoolean("forceTextureFiltering", getConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", "False").equals("True")); editor.putBoolean("forceTextureFiltering", getConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", "False").equals("True"));
editor.putBoolean("disableFog", getConfig("gfx_opengl.ini", "Settings", "DisableFog", "False").equals("True")); editor.putBoolean("disableFog", getConfig("gfx_opengl.ini", "Settings", "DisableFog", "False").equals("True"));
editor.putBoolean("skipEFBAccess", getConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", "False").equals("True")); editor.putBoolean("skipEFBAccess", getConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", "False").equals("True"));
editor.putBoolean("ignoreFormatChanges", getConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", "False").equals("False")); editor.putBoolean("ignoreFormatChanges", getConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", "False").equals("False"));
String efbCopyOn = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False"); String efbCopyOn = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
String efbToTexture = getConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False"); String efbToTexture = getConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
String efbCopyCache = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False"); String efbCopyCache = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False");
if (efbCopyOn.equals("False")) if (efbCopyOn.equals("False"))
{ {
editor.putString("efbCopyMethod", "Off"); editor.putString("efbCopyMethod", "Off");
} }
else if (efbCopyOn.equals("True") && efbToTexture.equals("True")) else if (efbCopyOn.equals("True") && efbToTexture.equals("True"))
{ {
editor.putString("efbCopyMethod", "Texture"); editor.putString("efbCopyMethod", "Texture");
} }
else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("False")) else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("False"))
{ {
editor.putString("efbCopyMethod", "RAM (uncached)"); editor.putString("efbCopyMethod", "RAM (uncached)");
} }
else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("True")) else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("True"))
{ {
editor.putString("efbCopyMethod", "RAM (cached)"); editor.putString("efbCopyMethod", "RAM (cached)");
} }
editor.putString("textureCacheAccuracy", getConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", "128")); editor.putString("textureCacheAccuracy", getConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", "128"));
String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False"); String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False");
String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False"); String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
if (usingXFB.equals("False")) if (usingXFB.equals("False"))
{ {
editor.putString("externalFrameBuffer", "Disabled"); editor.putString("externalFrameBuffer", "Disabled");
} }
else if (usingXFB.equals("True") && usingRealXFB.equals("False")) else if (usingXFB.equals("True") && usingRealXFB.equals("False"))
{ {
editor.putString("externalFrameBuffer", "Virtual"); editor.putString("externalFrameBuffer", "Virtual");
} }
else if (usingXFB.equals("True") && usingRealXFB.equals("True")) else if (usingXFB.equals("True") && usingRealXFB.equals("True"))
{ {
editor.putString("externalFrameBuffer", "Real"); editor.putString("externalFrameBuffer", "Real");
} }
editor.putBoolean("cacheDisplayLists", getConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", "False").equals("True")); editor.putBoolean("cacheDisplayLists", getConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", "False").equals("True"));
editor.putBoolean("disableDestinationAlpha", getConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", "False").equals("True")); editor.putBoolean("disableDestinationAlpha", getConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", "False").equals("True"));
editor.putBoolean("fastDepthCalculation", getConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", "True").equals("True")); editor.putBoolean("fastDepthCalculation", getConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", "True").equals("True"));
// Apply the changes. // Apply the changes.
editor.commit(); editor.commit();
} }
// Small utility method that shortens calls to NativeLibrary.GetConfig. // Small utility method that shortens calls to NativeLibrary.GetConfig.
private static String getConfig(String ini, String section, String key, String defaultValue) private static String getConfig(String ini, String section, String key, String defaultValue)
{ {
return NativeLibrary.GetConfig(ini, section, key, defaultValue); return NativeLibrary.GetConfig(ini, section, key, defaultValue);
} }
/** /**
* Writes the config to the Dolphin ini file. * Writes the config to the Dolphin ini file.
* *
* @param ctx The context used to retrieve the user settings. * @param ctx The context used to retrieve the user settings.
* */ * */
public static void SaveConfigToDolphinIni(Context ctx) public static void SaveConfigToDolphinIni(Context ctx)
{ {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
// Whether or not the user is using dual core. // Whether or not the user is using dual core.
boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true); boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true);
// Current CPU core being used. Falls back to interpreter upon error. // Current CPU core being used. Falls back to interpreter upon error.
String currentEmuCore = prefs.getString("cpuCorePref", "0"); String currentEmuCore = prefs.getString("cpuCorePref", "0");
// Current video backend being used. Falls back to software rendering upon error. // Current video backend being used. Falls back to software rendering upon error.
String currentVideoBackend = prefs.getString("gpuPref", "Software Rendering"); String currentVideoBackend = prefs.getString("gpuPref", "Software Rendering");
// Whether or not to draw on-screen controls. // Whether or not to draw on-screen controls.
boolean drawingOnscreenControls = prefs.getBoolean("drawOnscreenControls", true); boolean drawingOnscreenControls = prefs.getBoolean("drawOnscreenControls", true);
// Whether or not to ignore all EFB access requests from the CPU. // Whether or not to ignore all EFB access requests from the CPU.
boolean skipEFBAccess = prefs.getBoolean("skipEFBAccess", false); boolean skipEFBAccess = prefs.getBoolean("skipEFBAccess", false);
// Whether or not to ignore changes to the EFB format. // Whether or not to ignore changes to the EFB format.
boolean ignoreFormatChanges = prefs.getBoolean("ignoreFormatChanges", false); boolean ignoreFormatChanges = prefs.getBoolean("ignoreFormatChanges", false);
// EFB copy method to use. // EFB copy method to use.
String efbCopyMethod = prefs.getString("efbCopyMethod", "Off"); String efbCopyMethod = prefs.getString("efbCopyMethod", "Off");
// Texture cache accuracy. Falls back to "Fast" up error. // Texture cache accuracy. Falls back to "Fast" up error.
String textureCacheAccuracy = prefs.getString("textureCacheAccuracy", "128"); String textureCacheAccuracy = prefs.getString("textureCacheAccuracy", "128");
// External frame buffer emulation. Falls back to disabled upon error. // External frame buffer emulation. Falls back to disabled upon error.
String externalFrameBuffer = prefs.getString("externalFrameBuffer", "Disabled"); String externalFrameBuffer = prefs.getString("externalFrameBuffer", "Disabled");
// Whether or not display list caching is enabled. // Whether or not display list caching is enabled.
boolean dlistCachingEnabled = prefs.getBoolean("cacheDisplayLists", false); boolean dlistCachingEnabled = prefs.getBoolean("cacheDisplayLists", false);
// Whether or not to disable destination alpha. // Whether or not to disable destination alpha.
boolean disableDstAlphaPass = prefs.getBoolean("disableDestinationAlpha", false); boolean disableDstAlphaPass = prefs.getBoolean("disableDestinationAlpha", false);
// Whether or not to use fast depth calculation. // Whether or not to use fast depth calculation.
boolean useFastDepthCalc = prefs.getBoolean("fastDepthCalculation", true); boolean useFastDepthCalc = prefs.getBoolean("fastDepthCalculation", true);
// Internal resolution. Falls back to 1x Native upon error. // Internal resolution. Falls back to 1x Native upon error.
String internalResolution = prefs.getString("internalResolution", "2"); String internalResolution = prefs.getString("internalResolution", "2");
// Anisotropic Filtering Level. Falls back to 1x upon error. // Anisotropic Filtering Level. Falls back to 1x upon error.
String anisotropicFiltLevel = prefs.getString("anisotropicFiltering", "0"); String anisotropicFiltLevel = prefs.getString("anisotropicFiltering", "0");
// Whether or not Scaled EFB copies are used. // Whether or not Scaled EFB copies are used.
boolean usingScaledEFBCopy = prefs.getBoolean("scaledEFBCopy", true); boolean usingScaledEFBCopy = prefs.getBoolean("scaledEFBCopy", true);
// Whether or not per-pixel lighting is used. // Whether or not per-pixel lighting is used.
boolean usingPerPixelLighting = prefs.getBoolean("perPixelLighting", false); boolean usingPerPixelLighting = prefs.getBoolean("perPixelLighting", false);
// Whether or not texture filtering is being forced. // Whether or not texture filtering is being forced.
boolean isForcingTextureFiltering = prefs.getBoolean("forceTextureFiltering", false); boolean isForcingTextureFiltering = prefs.getBoolean("forceTextureFiltering", false);
// Whether or not fog is disabled. // Whether or not fog is disabled.
boolean fogIsDisabled = prefs.getBoolean("disableFog", false); boolean fogIsDisabled = prefs.getBoolean("disableFog", false);
// CPU related Settings // CPU related Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore); NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False"); NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
// General Video Settings // General Video Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend); NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
NativeLibrary.SetConfig("Dolphin.ini", "Android", "ScreenControls", drawingOnscreenControls ? "True" : "False"); NativeLibrary.SetConfig("Dolphin.ini", "Android", "ScreenControls", drawingOnscreenControls ? "True" : "False");
// Video Hack Settings // Video Hack Settings
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", skipEFBAccess ? "False" : "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", skipEFBAccess ? "False" : "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", ignoreFormatChanges ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", ignoreFormatChanges ? "True" : "False");
// Set EFB Copy Method // Set EFB Copy Method
if (efbCopyMethod.equals("Off")) if (efbCopyMethod.equals("Off"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
} }
else if (efbCopyMethod.equals("Texture")) else if (efbCopyMethod.equals("Texture"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "True");
} }
else if (efbCopyMethod.equals("RAM (uncached)")) else if (efbCopyMethod.equals("RAM (uncached)"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False");
} }
else if (efbCopyMethod.equals("RAM (cached)")) else if (efbCopyMethod.equals("RAM (cached)"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "True");
} }
// Set texture cache accuracy // Set texture cache accuracy
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", textureCacheAccuracy); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", textureCacheAccuracy);
// Set external frame buffer. // Set external frame buffer.
if (externalFrameBuffer.equals("Disabled")) if (externalFrameBuffer.equals("Disabled"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "False");
} }
else if (externalFrameBuffer.equals("Virtual")) else if (externalFrameBuffer.equals("Virtual"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
} }
else if (externalFrameBuffer.equals("Real")) else if (externalFrameBuffer.equals("Real"))
{ {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "True"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "True");
} }
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", dlistCachingEnabled ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", dlistCachingEnabled ? "True" : "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", disableDstAlphaPass ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", disableDstAlphaPass ? "True" : "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", useFastDepthCalc ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", useFastDepthCalc ? "True" : "False");
//-- Enhancement Settings --// //-- Enhancement Settings --//
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EFBScale", internalResolution); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EFBScale", internalResolution);
NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", anisotropicFiltLevel); NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", anisotropicFiltLevel);
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBScaledCopy", usingScaledEFBCopy ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBScaledCopy", usingScaledEFBCopy ? "True" : "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", usingPerPixelLighting ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", usingPerPixelLighting ? "True" : "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "True" : "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DisableFog", fogIsDisabled ? "True" : "False"); NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DisableFog", fogIsDisabled ? "True" : "False");
} }
} }

View File

@ -25,177 +25,177 @@ import android.preference.PreferenceFragment;
*/ */
public final class VideoSettingsFragment extends PreferenceFragment public final class VideoSettingsFragment extends PreferenceFragment
{ {
private Activity m_activity; private Activity m_activity;
static public class VersionCheck public static class VersionCheck
{ {
EGL10 mEGL; EGL10 mEGL;
EGLDisplay mEGLDisplay; EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs; EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig; EGLConfig mEGLConfig;
EGLContext mEGLContext; EGLContext mEGLContext;
EGLSurface mEGLSurface; EGLSurface mEGLSurface;
GL10 mGL; GL10 mGL;
String mThreadOwner; String mThreadOwner;
public VersionCheck() public VersionCheck()
{ {
int[] version = new int[2]; int[] version = new int[2];
int[] attribList = new int[] { int[] attribList = new int[] {
EGL10.EGL_WIDTH, 1, EGL10.EGL_WIDTH, 1,
EGL10.EGL_HEIGHT, 1, EGL10.EGL_HEIGHT, 1,
EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_RENDERABLE_TYPE, 4,
EGL10.EGL_NONE EGL10.EGL_NONE
}; };
int EGL_CONTEXT_CLIENT_VERSION = 0x3098; int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
int[] ctx_attribs = new int[] { int[] ctx_attribs = new int[] {
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE EGL10.EGL_NONE
}; };
// No error checking performed, minimum required code to elucidate logic // No error checking performed, minimum required code to elucidate logic
mEGL = (EGL10) EGLContext.getEGL(); mEGL = (EGL10) EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
mEGL.eglInitialize(mEGLDisplay, version); mEGL.eglInitialize(mEGLDisplay, version);
mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated
mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, ctx_attribs); mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, ctx_attribs);
mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList); mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList);
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
mGL = (GL10) mEGLContext.getGL(); mGL = (GL10) mEGLContext.getGL();
// Record thread owner of OpenGL context // Record thread owner of OpenGL context
mThreadOwner = Thread.currentThread().getName(); mThreadOwner = Thread.currentThread().getName();
} }
public String getVersion() public String getVersion()
{ {
return mGL.glGetString(GL10.GL_VERSION); return mGL.glGetString(GL10.GL_VERSION);
} }
public String getVendor() public String getVendor()
{ {
return mGL.glGetString(GL10.GL_VENDOR); return mGL.glGetString(GL10.GL_VENDOR);
} }
public String getRenderer() public String getRenderer()
{ {
return mGL.glGetString(GL10.GL_RENDERER); return mGL.glGetString(GL10.GL_RENDERER);
} }
private EGLConfig chooseConfig() private EGLConfig chooseConfig()
{ {
int[] attribList = new int[] { int[] attribList = new int[] {
EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0,
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_NONE EGL10.EGL_NONE
}; };
// No error checking performed, minimum required code to elucidate logic // No error checking performed, minimum required code to elucidate logic
// Expand on this logic to be more selective in choosing a configuration // Expand on this logic to be more selective in choosing a configuration
int[] numConfig = new int[1]; int[] numConfig = new int[1];
mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig); mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig);
int configSize = numConfig[0]; int configSize = numConfig[0];
mEGLConfigs = new EGLConfig[configSize]; mEGLConfigs = new EGLConfig[configSize];
mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig); mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig);
return mEGLConfigs[0]; // Best match is probably the first configuration return mEGLConfigs[0]; // Best match is probably the first configuration
} }
} }
static public boolean SupportsGLES3() public static boolean SupportsGLES3()
{ {
VersionCheck mbuffer = new VersionCheck(); VersionCheck mbuffer = new VersionCheck();
String m_GLVersion = mbuffer.getVersion(); String m_GLVersion = mbuffer.getVersion();
String m_GLVendor = mbuffer.getVendor(); String m_GLVendor = mbuffer.getVendor();
String m_GLRenderer = mbuffer.getRenderer(); String m_GLRenderer = mbuffer.getRenderer();
boolean mSupportsGLES3 = false; boolean mSupportsGLES3 = false;
// Check for OpenGL ES 3 support (General case). // Check for OpenGL ES 3 support (General case).
if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0"))) if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0")))
mSupportsGLES3 = true; mSupportsGLES3 = true;
// Checking for OpenGL ES 3 support for certain Qualcomm devices. // Checking for OpenGL ES 3 support for certain Qualcomm devices.
if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm")) if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm"))
{ {
if (m_GLRenderer.contains("Adreno (TM) 3")) if (m_GLRenderer.contains("Adreno (TM) 3"))
{ {
int mVStart = m_GLVersion.indexOf("V@") + 2; int mVStart = m_GLVersion.indexOf("V@") + 2;
int mVEnd = 0; int mVEnd = 0;
float mVersion; float mVersion;
for (int a = mVStart; a < m_GLVersion.length(); ++a) for (int a = mVStart; a < m_GLVersion.length(); ++a)
{ {
if (m_GLVersion.charAt(a) == ' ') if (m_GLVersion.charAt(a) == ' ')
{ {
mVEnd = a; mVEnd = a;
break; break;
} }
} }
mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd)); mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd));
if (mVersion >= 14.0f) if (mVersion >= 14.0f)
mSupportsGLES3 = true; mSupportsGLES3 = true;
} }
} }
return mSupportsGLES3; return mSupportsGLES3;
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState)
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Load the preferences from an XML resource // Load the preferences from an XML resource
addPreferencesFromResource(R.xml.video_prefs); addPreferencesFromResource(R.xml.video_prefs);
// //
// Setting valid video backends. // Setting valid video backends.
// //
final ListPreference videoBackends = (ListPreference) findPreference("gpuPref"); final ListPreference videoBackends = (ListPreference) findPreference("gpuPref");
final boolean deviceSupportsGLES3 = SupportsGLES3(); final boolean deviceSupportsGLES3 = SupportsGLES3();
if (deviceSupportsGLES3) if (deviceSupportsGLES3)
{ {
videoBackends.setEntries(R.array.videoBackendEntriesGLES3); videoBackends.setEntries(R.array.videoBackendEntriesGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesGLES3); videoBackends.setEntryValues(R.array.videoBackendValuesGLES3);
} }
else else
{ {
videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3); videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3); videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3);
} }
} }
@Override @Override
public void onAttach(Activity activity) public void onAttach(Activity activity)
{ {
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try try
{ {
m_activity = activity; m_activity = activity;
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new ClassCastException(activity.toString()); throw new ClassCastException(activity.toString());
} }
} }
@Override @Override
public void onDestroy() public void onDestroy()
{ {
super.onDestroy(); super.onDestroy();
// When the fragment is done being used, save the settings to the Dolphin ini file. // When the fragment is done being used, save the settings to the Dolphin ini file.
UserPreferences.SaveConfigToDolphinIni(m_activity); UserPreferences.SaveConfigToDolphinIni(m_activity);
} }
} }

View File

@ -27,29 +27,29 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
public SideMenuItem getItem(int i) public SideMenuItem getItem(int i)
{ {
return items.get(i); return items.get(i);
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent)
{ {
View v = convertView; View v = convertView;
if (v == null) if (v == null)
{ {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null); v = vi.inflate(id, null);
} }
final SideMenuItem item = items.get(position); final SideMenuItem item = items.get(position);
if (item != null) if (item != null)
{ {
TextView title = (TextView) v.findViewById(R.id.SideMenuTitle); TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
if(title != null) if (title != null)
title.setText(item.getName()); title.setText(item.getName());
} }
return v; return v;
} }
} }

View File

@ -12,47 +12,47 @@ package org.dolphinemu.dolphinemu.sidemenu;
*/ */
public final class SideMenuItem implements Comparable<SideMenuItem> public final class SideMenuItem implements Comparable<SideMenuItem>
{ {
private final String m_name; private final String m_name;
private final int m_id; private final int m_id;
/** /**
* Constructor * Constructor
* *
* @param name The name of the SideMenuItem. * @param name The name of the SideMenuItem.
* @param id ID number of this specific SideMenuItem. * @param id ID number of this specific SideMenuItem.
*/ */
public SideMenuItem(String name, int id) public SideMenuItem(String name, int id)
{ {
m_name = name; m_name = name;
m_id = id; m_id = id;
} }
/** /**
* Gets the name of this SideMenuItem. * Gets the name of this SideMenuItem.
* *
* @return the name of this SideMenuItem. * @return the name of this SideMenuItem.
*/ */
public String getName() public String getName()
{ {
return m_name; return m_name;
} }
/** /**
* Gets the ID of this SideMenuItem. * Gets the ID of this SideMenuItem.
* *
* @return the ID of this SideMenuItem. * @return the ID of this SideMenuItem.
*/ */
public int getID() public int getID()
{ {
return m_id; return m_id;
} }
public int compareTo(SideMenuItem o) public int compareTo(SideMenuItem o)
{ {
if(this.m_name != null) if (this.m_name != null)
return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase()); return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase());
else else
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }