[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

@ -20,43 +20,43 @@ import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import org.dolphinemu.dolphinemu.settings.UserPreferences; 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
public void onStop() public void onStop()
{ {
@ -64,7 +64,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running) if (Running)
NativeLibrary.StopEmulation(); NativeLibrary.StopEmulation();
} }
@Override @Override
public void onPause() public void onPause()
{ {
@ -72,7 +72,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running) if (Running)
NativeLibrary.PauseEmulation(); NativeLibrary.PauseEmulation();
} }
@Override @Override
public void onResume() public void onResume()
{ {
@ -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)
{ {
@ -90,12 +90,12 @@ public final class DolphinEmulator<MainActivity> extends Activity
{ {
Intent ListIntent = new Intent(this, GameListActivity.class); Intent ListIntent = new Intent(this, GameListActivity.class);
startActivityForResult(ListIntent, 1); startActivityForResult(ListIntent, 1);
// Make the assets directory // Make the assets directory
String BaseDir = Environment.getExternalStorageDirectory()+File.separator+"dolphin-emu"; String BaseDir = Environment.getExternalStorageDirectory()+File.separator+"dolphin-emu";
File directory = new File(BaseDir); File directory = new File(BaseDir);
directory.mkdirs(); directory.mkdirs();
String ConfigDir = BaseDir + File.separator + "Config"; String ConfigDir = BaseDir + File.separator + "Config";
directory = new File(ConfigDir); directory = new File(ConfigDir);
directory.mkdirs(); directory.mkdirs();
@ -144,7 +144,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
wm.getDefaultDisplay().getMetrics(displayMetrics); wm.getDefaultDisplay().getMetrics(displayMetrics);
screenWidth = displayMetrics.widthPixels; screenWidth = displayMetrics.widthPixels;
screenHeight = displayMetrics.heightPixels; screenHeight = displayMetrics.heightPixels;
String FileName = data.getStringExtra("Select"); String FileName = data.getStringExtra("Select");
GLview = new NativeGLSurfaceView(this); GLview = new NativeGLSurfaceView(this);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -155,14 +155,14 @@ public final class DolphinEmulator<MainActivity> extends Activity
Running = true; Running = true;
} }
} }
@Override @Override
public boolean onTouchEvent(MotionEvent event) public boolean onTouchEvent(MotionEvent event)
{ {
float X = event.getX(); float X = event.getX();
float Y = event.getY(); float Y = event.getY();
int Action = event.getActionMasked(); int Action = event.getActionMasked();
// Converts button locations 0 - 1 to OGL screen coords -1.0 - 1.0 // Converts button locations 0 - 1 to OGL screen coords -1.0 - 1.0
float ScreenX = ((X / screenWidth) * 2.0f) - 1.0f; float ScreenX = ((X / screenWidth) * 2.0f) - 1.0f;
float ScreenY = ((Y / screenHeight) * -2.0f) + 1.0f; float ScreenY = ((Y / screenHeight) * -2.0f) + 1.0f;
@ -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)
{ {
@ -44,7 +45,7 @@ public final class NativeGLSurfaceView extends SurfaceView
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
}); });
Created = true; Created = true;
} }
} }

View File

@ -30,7 +30,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{ {
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)
{ {
@ -40,11 +40,11 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
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 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);
@ -57,7 +57,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
mainText.setTextColor(0xFFFF0000); mainText.setTextColor(0xFFFF0000);
} }
} }
if(subtitleText != null) if(subtitleText != null)
{ {
// Remove the subtitle for all folders, except for the parent directory folder. // Remove the subtitle for all folders, except for the parent directory folder.
@ -70,19 +70,18 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
subtitleText.setText(item.getSubtitle()); subtitleText.setText(item.getSubtitle());
} }
} }
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

@ -99,19 +99,19 @@ public final class GameListActivity extends Activity
FragmentManager fragmentManager = getFragmentManager(); FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
public void SwitchPage(int toPage) public void SwitchPage(int toPage)
{ {
if (mCurFragmentNum == toPage) if (mCurFragmentNum == toPage)
return; return;
switch (mCurFragmentNum) switch (mCurFragmentNum)
{ {
// Folder browser // Folder browser
case 1: case 1:
recreateFragment(); recreateFragment();
break; break;
case 3: // Gamepad settings case 3: // Gamepad settings
{ {
InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter(); InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter();
@ -127,14 +127,14 @@ public final class GameListActivity extends Activity
} }
} }
break; break;
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;
} }
switch(toPage) switch(toPage)
{ {
case 0: case 0:
@ -145,7 +145,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 1: case 1:
{ {
mCurFragmentNum = 1; mCurFragmentNum = 1;
@ -154,14 +154,14 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 2: case 2:
{ {
Intent intent = new Intent(this, PrefsActivity.class); Intent intent = new Intent(this, PrefsActivity.class);
startActivity(intent); startActivity(intent);
} }
break; break;
case 3: case 3:
{ {
mCurFragmentNum = 3; mCurFragmentNum = 3;
@ -170,7 +170,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 4: case 4:
{ {
mCurFragmentNum = 4; mCurFragmentNum = 4;
@ -179,12 +179,12 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
default: default:
break; break;
} }
} }
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{ {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -231,7 +231,7 @@ public final class GameListActivity extends Activity
{ {
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -245,7 +245,7 @@ public final class GameListActivity extends Activity
public boolean onMotionEvent(MotionEvent event); public boolean onMotionEvent(MotionEvent event);
public boolean onKeyEvent(KeyEvent event); public boolean onKeyEvent(KeyEvent event);
} }
// Gets move(triggers, joystick) events // Gets move(triggers, joystick) events
@Override @Override
public boolean dispatchGenericMotionEvent(MotionEvent event) public boolean dispatchGenericMotionEvent(MotionEvent event)
@ -255,10 +255,10 @@ public final class GameListActivity extends Activity
if (((OnGameConfigListener)mCurFragment).onMotionEvent(event)) if (((OnGameConfigListener)mCurFragment).onMotionEvent(event))
return true; return true;
} }
return super.dispatchGenericMotionEvent(event); return super.dispatchGenericMotionEvent(event);
} }
// Gets button presses // Gets button presses
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) public boolean dispatchKeyEvent(KeyEvent event)
@ -268,8 +268,7 @@ public final class GameListActivity extends Activity
if (((OnGameConfigListener)mCurFragment).onKeyEvent(event)) if (((OnGameConfigListener)mCurFragment).onKeyEvent(event))
return true; return true;
} }
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

@ -43,7 +43,7 @@ public final class GameListFragment extends Fragment
{ {
// Empty constructor required for fragment subclasses // Empty constructor required for fragment subclasses
} }
private void Fill() private void Fill()
{ {
List<GameListItem> fls = new ArrayList<GameListItem>(); List<GameListItem> fls = new ArrayList<GameListItem>();
@ -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,12 +74,12 @@ public final class GameListFragment extends Fragment
} }
} }
} }
catch(Exception ignored) catch (Exception ignored)
{ {
} }
} }
Collections.sort(fls); Collections.sort(fls);
// Remove any duplicate items from the list. // Remove any duplicate items from the list.
// We don't need to index these in the game list more than once. // We don't need to index these in the game list more than once.
// //
@ -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);
@ -112,19 +112,19 @@ public final class GameListFragment extends Fragment
return mMainList; return mMainList;
} }
private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
{ {
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());
} }
} }
}; };
private void onFileClick(String o) private void onFileClick(String o)
{ {
Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show();
@ -134,7 +134,7 @@ public final class GameListFragment extends Fragment
mMe.setResult(Activity.RESULT_OK, intent); mMe.setResult(Activity.RESULT_OK, intent);
mMe.finish(); mMe.finish();
} }
@Override @Override
public void onAttach(Activity activity) public void onAttach(Activity activity)
{ {

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
else {
{ image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888); }
}
this.name = NativeLibrary.GetTitle(path);
this.name = NativeLibrary.GetTitle(path); }
} }
}
public String getName()
public String getName() {
{ return name;
return name; }
}
public String getData()
public String getData() {
{ return data;
return data; }
}
public String getPath()
public String getPath() {
{ return path;
return path; }
}
public Bitmap getImage()
public Bitmap getImage() {
{ return image;
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

@ -34,7 +34,7 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
{ {
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)
{ {
@ -44,20 +44,20 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
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 InputConfigItem item = items.get(position); final InputConfigItem item = items.get(position);
if (item != null) if (item != null)
{ {
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

@ -35,7 +35,7 @@ public final class InputConfigFragment extends Fragment
{ {
if (input == null) if (input == null)
return "null"; // Happens when the inputdevice is from an unknown source return "null"; // Happens when the inputdevice is from an unknown source
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{ {
return input.getDescriptor(); return input.getDescriptor();
@ -44,13 +44,14 @@ public final class InputConfigFragment extends Fragment
{ {
List<InputDevice.MotionRange> motions = input.getMotionRanges(); List<InputDevice.MotionRange> motions = input.getMotionRanges();
String fakeid = ""; String fakeid = "";
for (InputDevice.MotionRange range : motions) for (InputDevice.MotionRange range : motions)
fakeid += range.getAxis(); fakeid += range.getAxis();
return fakeid; return fakeid;
} }
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
@ -84,7 +85,7 @@ public final class InputConfigFragment extends Fragment
mDrawerList.setOnItemClickListener(mMenuItemClickListener); mDrawerList.setOnItemClickListener(mMenuItemClickListener);
return mDrawerList; return mDrawerList;
} }
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{ {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -107,16 +108,16 @@ public final class InputConfigFragment extends Fragment
o.setBind(bind); o.setBind(bind);
adapter.insert(o, configPosition); adapter.insert(o, configPosition);
} }
public InputConfigAdapter getAdapter() public InputConfigAdapter getAdapter()
{ {
return adapter; return adapter;
} }
// 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();
@ -131,7 +132,7 @@ public final class InputConfigFragment extends Fragment
{ {
m_values.add(event.getAxisValue(range.getAxis())); m_values.add(event.getAxisValue(range.getAxis()));
} }
firstEvent = false; firstEvent = false;
} }
else else
@ -155,7 +156,7 @@ public final class InputConfigFragment extends Fragment
} }
return true; return true;
} }
public boolean onKeyEvent(KeyEvent event) public boolean onKeyEvent(KeyEvent event)
{ {
Log.w("InputConfigFragment", "Got Event " + event.getAction()); Log.w("InputConfigFragment", "Got Event " + event.getAction());

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.
@ -50,7 +50,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{ {
Init(name, config, "None"); Init(name, config, "None");
} }
/** /**
* Gets the name of this InputConfigItem. * Gets the name of this InputConfigItem.
* *
@ -60,7 +60,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{ {
return m_name; return m_name;
} }
/** /**
* Gets the config key this InputConfigItem modifies. * Gets the config key this InputConfigItem modifies.
* *
@ -70,9 +70,9 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{ {
return m_Config; return m_Config;
} }
/** /**
* 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
*/ */
@ -80,7 +80,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{ {
return m_bind; return m_bind;
} }
/** /**
* Sets a new binding for this InputConfigItem. * Sets a new binding for 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
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource @Override
addPreferencesFromResource(R.xml.cpu_prefs); public void onCreate(Bundle savedInstanceState)
{
final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref"); super.onCreate(savedInstanceState);
// // Load the preferences from an XML resource
// Set valid emulation cores depending on the CPU architecture addPreferencesFromResource(R.xml.cpu_prefs);
// that the Android device is running on.
//
if (Build.CPU_ABI.contains("x86"))
{
cpuCores.setEntries(R.array.emuCoreEntriesX86);
cpuCores.setEntryValues(R.array.emuCoreValuesX86);
}
else if (Build.CPU_ABI.contains("arm"))
{
cpuCores.setEntries(R.array.emuCoreEntriesARM);
cpuCores.setEntryValues(R.array.emuCoreValuesARM);
}
else
{
cpuCores.setEntries(R.array.emuCoreEntriesOther);
cpuCores.setEntryValues(R.array.emuCoreValuesOther);
}
}
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
// This makes sure that the container activity has implemented final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref");
// the callback interface. If not, it throws an exception
try //
{ // Set valid emulation cores depending on the CPU architecture
m_activity = activity; // that the Android device is running on.
} //
catch (ClassCastException e) if (Build.CPU_ABI.contains("x86"))
{ {
throw new ClassCastException(activity.toString()); cpuCores.setEntries(R.array.emuCoreEntriesX86);
} cpuCores.setEntryValues(R.array.emuCoreValuesX86);
} }
else if (Build.CPU_ABI.contains("arm"))
@Override {
public void onDestroy() cpuCores.setEntries(R.array.emuCoreEntriesARM);
{ cpuCores.setEntryValues(R.array.emuCoreValuesARM);
super.onDestroy(); }
else
// When this fragment is destroyed, force the settings to be saved to the ini file. {
UserPreferences.SaveConfigToDolphinIni(m_activity); cpuCores.setEntries(R.array.emuCoreEntriesOther);
} cpuCores.setEntryValues(R.array.emuCoreValuesOther);
}
}
@Override
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
{
m_activity = activity;
}
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString());
}
}
@Override
public void onDestroy()
{
super.onDestroy();
// When this fragment is destroyed, force the settings to be saved to the ini file.
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.
*/
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.prefs_viewpager);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
{
@Override
public void onPageSelected(int position)
{
actionBar.setSelectedNavigationItem(position);
}
} );
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab().setText(R.string.cpu_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 onTabSelected(Tab tab, FragmentTransaction ft) /**
{ * The {@link ViewPager} that will host the section contents.
// When the given tab is selected, switch to the corresponding page in the ViewPager. */
mViewPager.setCurrentItem(tab.getPosition()); ViewPager mViewPager;
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) @Override
{ protected void onCreate(Bundle savedInstanceState)
// Do nothing. {
} super.onCreate(savedInstanceState);
setContentView(R.layout.prefs_viewpager);
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the // Set up the action bar.
* sections/tabs/pages. final ActionBar actionBar = getActionBar();
*/ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
public class SectionsPagerAdapter extends FragmentPagerAdapter
{ // Create the adapter that will return a fragment for each of the three
// primary sections of the app.
public SectionsPagerAdapter(FragmentManager fm) mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
{
super(fm); // Set up the ViewPager with the sections adapter.
} mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
@Override
public Fragment getItem(int position) // When swiping between different sections, select the corresponding
{ // tab. We can also use ActionBar.Tab#select() to do this if we have
switch(position) // a reference to the Tab.
{ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
case 0: {
return new CPUSettingsFragment(); @Override
public void onPageSelected(int position)
case 1: {
return new VideoSettingsFragment(); actionBar.setSelectedNavigationItem(position);
}
default: // Should never happen. } );
return null;
} // Create a tab with text corresponding to the page title defined by
} // the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
@Override // this tab is selected.
public int getCount() actionBar.addTab(actionBar.newTab().setText(R.string.cpu_settings).setTabListener(this));
{ actionBar.addTab(actionBar.newTab().setText("Input Settings").setTabListener(this));
// Show total pages. actionBar.addTab(actionBar.newTab().setText(R.string.video_settings).setTabListener(this));
return 2; }
}
public void onTabReselected(Tab arg0, FragmentTransaction arg1)
@Override {
public CharSequence getPageTitle(int position) // Do nothing.
{ }
switch(position)
{ public void onTabSelected(Tab tab, FragmentTransaction ft)
case 0: {
return getString(R.string.cpu_settings).toUpperCase(); // When the given tab is selected, switch to the corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
case 1: }
return getString(R.string.video_settings).toUpperCase();
public void onTabUnselected(Tab tab, FragmentTransaction ft)
default: // Should never happen. {
return null; // Do nothing.
} }
}
} /**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the
* sections/tabs/pages.
*/
public final class SectionsPagerAdapter extends FragmentPagerAdapter
{
public SectionsPagerAdapter(FragmentManager fm)
{
super(fm);
}
@Override
public Fragment getItem(int position)
{
switch(position)
{
case 0:
return new CPUSettingsFragment();
case 1:
return new InputConfigFragment();
case 2:
return new VideoSettingsFragment();
default: // Should never happen.
return null;
}
}
@Override
public int getCount()
{
// Show total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position)
{
switch(position)
{
case 0:
return getString(R.string.cpu_settings).toUpperCase();
case 1:
return "Input Settings";//getString(R.string)
case 2:
return getString(R.string.video_settings).toUpperCase();
default: // Should never happen.
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.
SharedPreferences.Editor editor = prefs.edit();
// Add the settings.
editor.putString("cpuCorePref", getConfig("Dolphin.ini", "Core", "CPUCore", "3"));
editor.putBoolean("dualCorePref", getConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True"));
editor.putString("gpuPref", getConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer"));
editor.putBoolean("drawOnscreenControls", getConfig("Dolphin.ini", "Android", "ScreenControls", "True").equals("True"));
editor.putString("internalResolution", getConfig("gfx_opengl.ini", "Settings", "EFBScale", "2") );
editor.putString("anisotropicFiltering", getConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", "0"));
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("forceTextureFiltering", getConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", "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("ignoreFormatChanges", getConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", "False").equals("False"));
String efbCopyOn = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
String efbToTexture = getConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
String efbCopyCache = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False");
if (efbCopyOn.equals("False"))
{
editor.putString("efbCopyMethod", "Off");
}
else if (efbCopyOn.equals("True") && efbToTexture.equals("True"))
{
editor.putString("efbCopyMethod", "Texture");
}
else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("False"))
{
editor.putString("efbCopyMethod", "RAM (uncached)");
}
else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("True"))
{
editor.putString("efbCopyMethod", "RAM (cached)");
}
editor.putString("textureCacheAccuracy", getConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", "128"));
String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False"); // Get an editor.
String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False"); SharedPreferences.Editor editor = prefs.edit();
if (usingXFB.equals("False"))
{
editor.putString("externalFrameBuffer", "Disabled");
}
else if (usingXFB.equals("True") && usingRealXFB.equals("False"))
{
editor.putString("externalFrameBuffer", "Virtual");
}
else if (usingXFB.equals("True") && usingRealXFB.equals("True"))
{
editor.putString("externalFrameBuffer", "Real");
}
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("fastDepthCalculation", getConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", "True").equals("True"));
// Apply the changes.
editor.commit();
}
// Small utility method that shortens calls to NativeLibrary.GetConfig.
private static String getConfig(String ini, String section, String key, String defaultValue)
{
return NativeLibrary.GetConfig(ini, section, key, defaultValue);
}
/**
* Writes the config to the Dolphin ini file.
*
* @param ctx The context used to retrieve the user settings.
* */
public static void SaveConfigToDolphinIni(Context ctx)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
// Whether or not the user is using dual core.
boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true);
// Current CPU core being used. Falls back to interpreter upon error.
String currentEmuCore = prefs.getString("cpuCorePref", "0");
// Current video backend being used. Falls back to software rendering upon error.
String currentVideoBackend = prefs.getString("gpuPref", "Software Rendering");
// Whether or not to draw on-screen controls.
boolean drawingOnscreenControls = prefs.getBoolean("drawOnscreenControls", true);
// Whether or not to ignore all EFB access requests from the CPU.
boolean skipEFBAccess = prefs.getBoolean("skipEFBAccess", false);
// Whether or not to ignore changes to the EFB format.
boolean ignoreFormatChanges = prefs.getBoolean("ignoreFormatChanges", false);
// EFB copy method to use.
String efbCopyMethod = prefs.getString("efbCopyMethod", "Off");
// Texture cache accuracy. Falls back to "Fast" up error.
String textureCacheAccuracy = prefs.getString("textureCacheAccuracy", "128");
// External frame buffer emulation. Falls back to disabled upon error.
String externalFrameBuffer = prefs.getString("externalFrameBuffer", "Disabled");
// Whether or not display list caching is enabled.
boolean dlistCachingEnabled = prefs.getBoolean("cacheDisplayLists", false);
// Whether or not to disable destination alpha.
boolean disableDstAlphaPass = prefs.getBoolean("disableDestinationAlpha", false);
// Whether or not to use fast depth calculation.
boolean useFastDepthCalc = prefs.getBoolean("fastDepthCalculation", true);
// Internal resolution. Falls back to 1x Native upon error.
String internalResolution = prefs.getString("internalResolution", "2");
// Anisotropic Filtering Level. Falls back to 1x upon error.
String anisotropicFiltLevel = prefs.getString("anisotropicFiltering", "0");
// Whether or not Scaled EFB copies are used.
boolean usingScaledEFBCopy = prefs.getBoolean("scaledEFBCopy", true);
// Whether or not per-pixel lighting is used.
boolean usingPerPixelLighting = prefs.getBoolean("perPixelLighting", false);
// Whether or not texture filtering is being forced.
boolean isForcingTextureFiltering = prefs.getBoolean("forceTextureFiltering", false);
// Whether or not fog is disabled.
boolean fogIsDisabled = prefs.getBoolean("disableFog", false);
// CPU related Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
// General Video Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
NativeLibrary.SetConfig("Dolphin.ini", "Android", "ScreenControls", drawingOnscreenControls ? "True" : "False");
// Video Hack Settings
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", skipEFBAccess ? "False" : "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", ignoreFormatChanges ? "True" : "False");
// Set EFB Copy Method // Add the settings.
if (efbCopyMethod.equals("Off")) editor.putString("cpuCorePref", getConfig("Dolphin.ini", "Core", "CPUCore", "3"));
{ editor.putBoolean("dualCorePref", getConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True"));
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
} editor.putString("gpuPref", getConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer"));
else if (efbCopyMethod.equals("Texture")) editor.putBoolean("drawOnscreenControls", getConfig("Dolphin.ini", "Android", "ScreenControls", "True").equals("True"));
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); editor.putString("internalResolution", getConfig("gfx_opengl.ini", "Settings", "EFBScale", "2") );
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "True"); editor.putString("anisotropicFiltering", getConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", "0"));
} editor.putBoolean("scaledEFBCopy", getConfig("gfx_opengl.ini", "Hacks", "EFBScaleCopy", "True").equals("True"));
else if (efbCopyMethod.equals("RAM (uncached)")) editor.putBoolean("perPixelLighting", getConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", "False").equals("True"));
{ editor.putBoolean("forceTextureFiltering", getConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", "False").equals("True"));
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); editor.putBoolean("disableFog", getConfig("gfx_opengl.ini", "Settings", "DisableFog", "False").equals("True"));
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False"); editor.putBoolean("skipEFBAccess", getConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", "False").equals("True"));
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False"); editor.putBoolean("ignoreFormatChanges", getConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", "False").equals("False"));
}
else if (efbCopyMethod.equals("RAM (cached)")) String efbCopyOn = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
{ String efbToTexture = getConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True"); String efbCopyCache = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "True"); if (efbCopyOn.equals("False"))
} {
editor.putString("efbCopyMethod", "Off");
// Set texture cache accuracy }
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", textureCacheAccuracy); else if (efbCopyOn.equals("True") && efbToTexture.equals("True"))
{
// Set external frame buffer. editor.putString("efbCopyMethod", "Texture");
if (externalFrameBuffer.equals("Disabled")) }
{ else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("False"))
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "False"); {
} editor.putString("efbCopyMethod", "RAM (uncached)");
else if (externalFrameBuffer.equals("Virtual")) }
{ else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("True"))
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True"); {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False"); editor.putString("efbCopyMethod", "RAM (cached)");
} }
else if (externalFrameBuffer.equals("Real"))
{ editor.putString("textureCacheAccuracy", getConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", "128"));
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "True"); String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False");
} String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", dlistCachingEnabled ? "True" : "False"); if (usingXFB.equals("False"))
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", disableDstAlphaPass ? "True" : "False"); {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", useFastDepthCalc ? "True" : "False"); editor.putString("externalFrameBuffer", "Disabled");
}
//-- Enhancement Settings --// else if (usingXFB.equals("True") && usingRealXFB.equals("False"))
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EFBScale", internalResolution); {
NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", anisotropicFiltLevel); editor.putString("externalFrameBuffer", "Virtual");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBScaledCopy", usingScaledEFBCopy ? "True" : "False"); }
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", usingPerPixelLighting ? "True" : "False"); else if (usingXFB.equals("True") && usingRealXFB.equals("True"))
NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "True" : "False"); {
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DisableFog", fogIsDisabled ? "True" : "False"); editor.putString("externalFrameBuffer", "Real");
} }
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("fastDepthCalculation", getConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", "True").equals("True"));
// Apply the changes.
editor.commit();
}
// Small utility method that shortens calls to NativeLibrary.GetConfig.
private static String getConfig(String ini, String section, String key, String defaultValue)
{
return NativeLibrary.GetConfig(ini, section, key, defaultValue);
}
/**
* Writes the config to the Dolphin ini file.
*
* @param ctx The context used to retrieve the user settings.
* */
public static void SaveConfigToDolphinIni(Context ctx)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
// Whether or not the user is using dual core.
boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true);
// Current CPU core being used. Falls back to interpreter upon error.
String currentEmuCore = prefs.getString("cpuCorePref", "0");
// Current video backend being used. Falls back to software rendering upon error.
String currentVideoBackend = prefs.getString("gpuPref", "Software Rendering");
// Whether or not to draw on-screen controls.
boolean drawingOnscreenControls = prefs.getBoolean("drawOnscreenControls", true);
// Whether or not to ignore all EFB access requests from the CPU.
boolean skipEFBAccess = prefs.getBoolean("skipEFBAccess", false);
// Whether or not to ignore changes to the EFB format.
boolean ignoreFormatChanges = prefs.getBoolean("ignoreFormatChanges", false);
// EFB copy method to use.
String efbCopyMethod = prefs.getString("efbCopyMethod", "Off");
// Texture cache accuracy. Falls back to "Fast" up error.
String textureCacheAccuracy = prefs.getString("textureCacheAccuracy", "128");
// External frame buffer emulation. Falls back to disabled upon error.
String externalFrameBuffer = prefs.getString("externalFrameBuffer", "Disabled");
// Whether or not display list caching is enabled.
boolean dlistCachingEnabled = prefs.getBoolean("cacheDisplayLists", false);
// Whether or not to disable destination alpha.
boolean disableDstAlphaPass = prefs.getBoolean("disableDestinationAlpha", false);
// Whether or not to use fast depth calculation.
boolean useFastDepthCalc = prefs.getBoolean("fastDepthCalculation", true);
// Internal resolution. Falls back to 1x Native upon error.
String internalResolution = prefs.getString("internalResolution", "2");
// Anisotropic Filtering Level. Falls back to 1x upon error.
String anisotropicFiltLevel = prefs.getString("anisotropicFiltering", "0");
// Whether or not Scaled EFB copies are used.
boolean usingScaledEFBCopy = prefs.getBoolean("scaledEFBCopy", true);
// Whether or not per-pixel lighting is used.
boolean usingPerPixelLighting = prefs.getBoolean("perPixelLighting", false);
// Whether or not texture filtering is being forced.
boolean isForcingTextureFiltering = prefs.getBoolean("forceTextureFiltering", false);
// Whether or not fog is disabled.
boolean fogIsDisabled = prefs.getBoolean("disableFog", false);
// CPU related Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
// General Video Settings
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
NativeLibrary.SetConfig("Dolphin.ini", "Android", "ScreenControls", drawingOnscreenControls ? "True" : "False");
// Video Hack Settings
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", skipEFBAccess ? "False" : "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", ignoreFormatChanges ? "True" : "False");
// Set EFB Copy Method
if (efbCopyMethod.equals("Off"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False");
}
else if (efbCopyMethod.equals("Texture"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "True");
}
else if (efbCopyMethod.equals("RAM (uncached)"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False");
}
else if (efbCopyMethod.equals("RAM (cached)"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False");
NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "True");
}
// Set texture cache accuracy
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", textureCacheAccuracy);
// Set external frame buffer.
if (externalFrameBuffer.equals("Disabled"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "False");
}
else if (externalFrameBuffer.equals("Virtual"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
}
else if (externalFrameBuffer.equals("Real"))
{
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseXFB", "True");
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "True");
}
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", "FastDepthCalc", useFastDepthCalc ? "True" : "False");
//-- Enhancement Settings --//
NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EFBScale", internalResolution);
NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", anisotropicFiltLevel);
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", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "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()
{
return mGL.glGetString(GL10.GL_RENDERER);
}
private EGLConfig chooseConfig()
{
int[] attribList = new int[] {
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE, 0,
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_NONE
};
// No error checking performed, minimum required code to elucidate logic public String getRenderer()
// Expand on this logic to be more selective in choosing a configuration {
int[] numConfig = new int[1]; return mGL.glGetString(GL10.GL_RENDERER);
mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig); }
int configSize = numConfig[0];
mEGLConfigs = new EGLConfig[configSize];
mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig);
return mEGLConfigs[0]; // Best match is probably the first configuration private EGLConfig chooseConfig()
} {
} int[] attribList = new int[] {
EGL10.EGL_DEPTH_SIZE, 0,
static public boolean SupportsGLES3() EGL10.EGL_STENCIL_SIZE, 0,
{ EGL10.EGL_RED_SIZE, 8,
VersionCheck mbuffer = new VersionCheck(); EGL10.EGL_GREEN_SIZE, 8,
String m_GLVersion = mbuffer.getVersion(); EGL10.EGL_BLUE_SIZE, 8,
String m_GLVendor = mbuffer.getVendor(); EGL10.EGL_ALPHA_SIZE, 8,
String m_GLRenderer = mbuffer.getRenderer(); EGL10.EGL_NONE
};
boolean mSupportsGLES3 = false; // No error checking performed, minimum required code to elucidate logic
// Expand on this logic to be more selective in choosing a configuration
int[] numConfig = new int[1];
mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig);
int configSize = numConfig[0];
mEGLConfigs = new EGLConfig[configSize];
mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig);
// Check for OpenGL ES 3 support (General case). return mEGLConfigs[0]; // Best match is probably the first configuration
if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0"))) }
mSupportsGLES3 = true; }
// Checking for OpenGL ES 3 support for certain Qualcomm devices.
if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm"))
{
if (m_GLRenderer.contains("Adreno (TM) 3"))
{
int mVStart = m_GLVersion.indexOf("V@") + 2;
int mVEnd = 0;
float mVersion;
for (int a = mVStart; a < m_GLVersion.length(); ++a)
{
if (m_GLVersion.charAt(a) == ' ')
{
mVEnd = a;
break;
}
}
mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd));
if (mVersion >= 14.0f) public static boolean SupportsGLES3()
mSupportsGLES3 = true; {
} VersionCheck mbuffer = new VersionCheck();
} String m_GLVersion = mbuffer.getVersion();
return mSupportsGLES3; String m_GLVendor = mbuffer.getVendor();
} String m_GLRenderer = mbuffer.getRenderer();
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource boolean mSupportsGLES3 = false;
addPreferencesFromResource(R.xml.video_prefs);
// // Check for OpenGL ES 3 support (General case).
// Setting valid video backends. if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0")))
// mSupportsGLES3 = true;
final ListPreference videoBackends = (ListPreference) findPreference("gpuPref");
final boolean deviceSupportsGLES3 = SupportsGLES3();
if (deviceSupportsGLES3) // Checking for OpenGL ES 3 support for certain Qualcomm devices.
{ if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm"))
videoBackends.setEntries(R.array.videoBackendEntriesGLES3); {
videoBackends.setEntryValues(R.array.videoBackendValuesGLES3); if (m_GLRenderer.contains("Adreno (TM) 3"))
} {
else int mVStart = m_GLVersion.indexOf("V@") + 2;
{ int mVEnd = 0;
videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3); float mVersion;
videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3);
}
}
@Override for (int a = mVStart; a < m_GLVersion.length(); ++a)
public void onAttach(Activity activity) {
{ if (m_GLVersion.charAt(a) == ' ')
super.onAttach(activity); {
mVEnd = a;
break;
}
}
// This makes sure that the container activity has implemented mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd));
// the callback interface. If not, it throws an exception
try if (mVersion >= 14.0f)
{ mSupportsGLES3 = true;
m_activity = activity; }
} }
catch (ClassCastException e) return mSupportsGLES3;
{ }
throw new ClassCastException(activity.toString());
} @Override
} public void onCreate(Bundle savedInstanceState)
{
@Override super.onCreate(savedInstanceState);
public void onDestroy()
{ // Load the preferences from an XML resource
super.onDestroy(); addPreferencesFromResource(R.xml.video_prefs);
// When the fragment is done being used, save the settings to the Dolphin ini file. //
UserPreferences.SaveConfigToDolphinIni(m_activity); // Setting valid video backends.
} //
final ListPreference videoBackends = (ListPreference) findPreference("gpuPref");
final boolean deviceSupportsGLES3 = SupportsGLES3();
if (deviceSupportsGLES3)
{
videoBackends.setEntries(R.array.videoBackendEntriesGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesGLES3);
}
else
{
videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3);
}
}
@Override
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
{
m_activity = activity;
}
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString());
}
}
@Override
public void onDestroy()
{
super.onDestroy();
// When the fragment is done being used, save the settings to the Dolphin ini file.
UserPreferences.SaveConfigToDolphinIni(m_activity);
}
} }

View File

@ -16,7 +16,7 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
private final Context c; private final Context c;
private final int id; private final int id;
private final List<SideMenuItem>items; private final List<SideMenuItem>items;
public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects) public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects)
{ {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
@ -24,32 +24,32 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
id = textViewResourceId; id = textViewResourceId;
items = objects; items = objects;
} }
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();
} }
} }