[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;
public final class DolphinEmulator<MainActivity> extends Activity
{
static private NativeGLSurfaceView GLview = null;
static private boolean Running = false;
{
private static NativeGLSurfaceView GLview = null;
private static boolean Running = false;
private float screenWidth;
private float screenHeight;
private void CopyAsset(String asset, String output)
{
InputStream in = null;
OutputStream out = null;
try
{
in = getAssets().open(asset);
out = new FileOutputStream(output);
copyFile(in, out);
in.close();
out.close();
}
catch(IOException e)
{
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e);
}
InputStream in = null;
OutputStream out = null;
try
{
in = getAssets().open(asset);
out = new FileOutputStream(output);
copyFile(in, out);
in.close();
out.close();
}
catch (IOException e)
{
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e);
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException
{
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1)
{
out.write(buffer, 0, read);
}
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1)
{
out.write(buffer, 0, read);
}
}
@Override
public void onStop()
{
@ -64,7 +64,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running)
NativeLibrary.StopEmulation();
}
@Override
public void onPause()
{
@ -72,7 +72,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running)
NativeLibrary.PauseEmulation();
}
@Override
public void onResume()
{
@ -81,7 +81,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
NativeLibrary.UnPauseEmulation();
}
/** Called when the activity is first created. */
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
@ -90,12 +90,12 @@ public final class DolphinEmulator<MainActivity> extends Activity
{
Intent ListIntent = new Intent(this, GameListActivity.class);
startActivityForResult(ListIntent, 1);
// Make the assets directory
String BaseDir = Environment.getExternalStorageDirectory()+File.separator+"dolphin-emu";
File directory = new File(BaseDir);
directory.mkdirs();
String ConfigDir = BaseDir + File.separator + "Config";
directory = new File(ConfigDir);
directory.mkdirs();
@ -144,7 +144,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
wm.getDefaultDisplay().getMetrics(displayMetrics);
screenWidth = displayMetrics.widthPixels;
screenHeight = displayMetrics.heightPixels;
String FileName = data.getStringExtra("Select");
GLview = new NativeGLSurfaceView(this);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -155,14 +155,14 @@ public final class DolphinEmulator<MainActivity> extends Activity
Running = true;
}
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
float X = event.getX();
float Y = event.getY();
int Action = event.getActionMasked();
// Converts button locations 0 - 1 to OGL screen coords -1.0 - 1.0
float ScreenX = ((X / screenWidth) * 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)
{
NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis()));
NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis()));
}
return true;

View File

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

View File

@ -30,7 +30,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{
return items.get(i);
}
@Override
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);
v = vi.inflate(id, parent, false);
}
final FolderBrowserItem item = items.get(position);
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 subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle);
@ -57,7 +57,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
mainText.setTextColor(0xFFFF0000);
}
}
if(subtitleText != null)
{
// 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());
}
}
if (iconView != null)
{
if (item.isDirectory())
{
iconView.setImageResource(R.drawable.ic_menu_folder);
}
else
{
iconView.setImageResource(R.drawable.ic_menu_file);
}
if (item.isDirectory())
{
iconView.setImageResource(R.drawable.ic_menu_folder);
}
else
{
iconView.setImageResource(R.drawable.ic_menu_file);
}
}
}
return v;
}

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public final class GameListFragment extends Fragment
{
// Empty constructor required for fragment subclasses
}
private void Fill()
{
List<GameListItem> fls = new ArrayList<GameListItem>();
@ -60,13 +60,13 @@ public final class GameListFragment extends Fragment
File[] dirs = currentDir.listFiles();
try
{
for(File entry : dirs)
for (File entry : dirs)
{
String entryName = entry.getName();
if (entryName.charAt(0) != '.')
{
if(!entry.isDirectory())
if (!entry.isDirectory())
{
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));
@ -74,12 +74,12 @@ public final class GameListFragment extends Fragment
}
}
}
catch(Exception ignored)
catch (Exception ignored)
{
}
}
Collections.sort(fls);
// Remove any duplicate items from the list.
// 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.
for (int i = 0; i < fls.size(); i++)
{
int indexNext = i+1;
if (indexNext < fls.size() && fls.get(indexNext).getPath().contains(fls.get(i).getPath()))
{
fls.remove(indexNext);
}
int indexNext = i+1;
if (indexNext < fls.size() && fls.get(indexNext).getPath().contains(fls.get(i).getPath()))
{
fls.remove(indexNext);
}
}
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
@ -112,19 +112,19 @@ public final class GameListFragment extends Fragment
return mMainList;
}
private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
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());
}
}
};
private void onFileClick(String o)
{
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.finish();
}
@Override
public void onAttach(Activity activity)
{

View File

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

View File

@ -34,7 +34,7 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
{
return items.get(i);
}
@Override
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);
v = vi.inflate(id, parent, false);
}
final InputConfigItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.FolderTitle);
TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle);
if(title != null)
title.setText(item.getName());
if(subtitle != null)
subtitle.setText(item.getBind());
if (title != null)
title.setText(item.getName());
if (subtitle != null)
subtitle.setText(item.getBind());
}
return v;
}
}

View File

@ -35,7 +35,7 @@ public final class InputConfigFragment extends Fragment
{
if (input == null)
return "null"; // Happens when the inputdevice is from an unknown source
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
return input.getDescriptor();
@ -44,13 +44,14 @@ public final class InputConfigFragment extends Fragment
{
List<InputDevice.MotionRange> motions = input.getMotionRanges();
String fakeid = "";
for (InputDevice.MotionRange range : motions)
fakeid += range.getAxis();
return fakeid;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
@ -84,7 +85,7 @@ public final class InputConfigFragment extends Fragment
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
return mDrawerList;
}
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -107,16 +108,16 @@ public final class InputConfigFragment extends Fragment
o.setBind(bind);
adapter.insert(o, configPosition);
}
public InputConfigAdapter getAdapter()
{
return adapter;
}
// Called from GameListActivity
public boolean onMotionEvent(MotionEvent event)
{
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0))
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)
return false;
InputDevice input = event.getDevice();
@ -131,7 +132,7 @@ public final class InputConfigFragment extends Fragment
{
m_values.add(event.getAxisValue(range.getAxis()));
}
firstEvent = false;
}
else
@ -155,7 +156,7 @@ public final class InputConfigFragment extends Fragment
}
return true;
}
public boolean onKeyEvent(KeyEvent event)
{
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
* that has a default binding of "None"
* that has a default binding of "None".
*
* @param name Name of the input config item.
* @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");
}
/**
* Gets the name of this InputConfigItem.
*
@ -60,7 +60,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{
return m_name;
}
/**
* Gets the config key this InputConfigItem modifies.
*
@ -70,9 +70,9 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{
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
*/
@ -80,7 +80,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
{
return m_bind;
}
/**
* Sets a new binding for this InputConfigItem.
*
@ -93,7 +93,7 @@ public final class InputConfigItem implements Comparable<InputConfigItem>
public int compareTo(InputConfigItem o)
{
if(this.m_name != null)
if (this.m_name != null)
return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase());
else
throw new IllegalArgumentException();

View File

@ -19,62 +19,62 @@ import android.preference.PreferenceFragment;
*/
public final class CPUSettingsFragment extends PreferenceFragment
{
private Activity m_activity;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
private Activity m_activity;
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.cpu_prefs);
final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref");
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//
// Set valid emulation cores depending on the CPU architecture
// 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);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.cpu_prefs);
// 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);
}
final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref");
//
// Set valid emulation cores depending on the CPU architecture
// 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
// 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;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
@ -24,123 +25,128 @@ import android.support.v4.view.ViewPager;
*/
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
* 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
* switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
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.
}
/**
* 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
* 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}.
*/
SectionsPagerAdapter mSectionsPagerAdapter;
public void onTabSelected(Tab tab, FragmentTransaction ft)
{
// When the given tab is selected, switch to the corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
public void onTabUnselected(Tab tab, FragmentTransaction ft)
{
// Do nothing.
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the
* sections/tabs/pages.
*/
public 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 VideoSettingsFragment();
default: // Should never happen.
return null;
}
}
@Override
public int getCount()
{
// Show total pages.
return 2;
}
@Override
public CharSequence getPageTitle(int position)
{
switch(position)
{
case 0:
return getString(R.string.cpu_settings).toUpperCase();
case 1:
return getString(R.string.video_settings).toUpperCase();
default: // Should never happen.
return null;
}
}
}
@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("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 onTabSelected(Tab tab, FragmentTransaction ft)
{
// When the given tab is selected, switch to the corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(Tab tab, FragmentTransaction ft)
{
// 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
{
/**
* 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.
*/
public static void LoadDolphinConfigToPrefs(Context 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"));
/**
* 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.
*/
public static void LoadDolphinConfigToPrefs(Context ctx)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False");
String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
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");
// Get an editor.
SharedPreferences.Editor editor = prefs.edit();
// 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");
}
// 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");
String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False");
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
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
{
private Activity m_activity;
private Activity m_activity;
static public class VersionCheck
{
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
GL10 mGL;
public static class VersionCheck
{
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
GL10 mGL;
String mThreadOwner;
String mThreadOwner;
public VersionCheck()
{
int[] version = new int[2];
int[] attribList = new int[] {
EGL10.EGL_WIDTH, 1,
EGL10.EGL_HEIGHT, 1,
EGL10.EGL_RENDERABLE_TYPE, 4,
EGL10.EGL_NONE
};
int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
int[] ctx_attribs = new int[] {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
};
public VersionCheck()
{
int[] version = new int[2];
int[] attribList = new int[] {
EGL10.EGL_WIDTH, 1,
EGL10.EGL_HEIGHT, 1,
EGL10.EGL_RENDERABLE_TYPE, 4,
EGL10.EGL_NONE
};
int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
int[] ctx_attribs = new int[] {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
};
// No error checking performed, minimum required code to elucidate logic
mEGL = (EGL10) EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
mEGL.eglInitialize(mEGLDisplay, version);
mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated
mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, ctx_attribs);
mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList);
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
mGL = (GL10) mEGLContext.getGL();
// No error checking performed, minimum required code to elucidate logic
mEGL = (EGL10) EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
mEGL.eglInitialize(mEGLDisplay, version);
mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated
mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, ctx_attribs);
mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList);
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
mGL = (GL10) mEGLContext.getGL();
// Record thread owner of OpenGL context
mThreadOwner = Thread.currentThread().getName();
}
// Record thread owner of OpenGL context
mThreadOwner = Thread.currentThread().getName();
}
public String getVersion()
{
return mGL.glGetString(GL10.GL_VERSION);
}
public String getVersion()
{
return mGL.glGetString(GL10.GL_VERSION);
}
public String getVendor()
{
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
};
public String getVendor()
{
return mGL.glGetString(GL10.GL_VENDOR);
}
// 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);
public String getRenderer()
{
return mGL.glGetString(GL10.GL_RENDERER);
}
return mEGLConfigs[0]; // Best match is probably the first configuration
}
}
static public boolean SupportsGLES3()
{
VersionCheck mbuffer = new VersionCheck();
String m_GLVersion = mbuffer.getVersion();
String m_GLVendor = mbuffer.getVendor();
String m_GLRenderer = mbuffer.getRenderer();
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
};
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).
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));
return mEGLConfigs[0]; // Best match is probably the first configuration
}
}
if (mVersion >= 14.0f)
mSupportsGLES3 = true;
}
}
return mSupportsGLES3;
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
public static boolean SupportsGLES3()
{
VersionCheck mbuffer = new VersionCheck();
String m_GLVersion = mbuffer.getVersion();
String m_GLVendor = mbuffer.getVendor();
String m_GLRenderer = mbuffer.getRenderer();
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.video_prefs);
boolean mSupportsGLES3 = false;
//
// Setting valid video backends.
//
final ListPreference videoBackends = (ListPreference) findPreference("gpuPref");
final boolean deviceSupportsGLES3 = SupportsGLES3();
// 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")))
mSupportsGLES3 = true;
if (deviceSupportsGLES3)
{
videoBackends.setEntries(R.array.videoBackendEntriesGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesGLES3);
}
else
{
videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3);
}
}
// 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;
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
for (int a = mVStart; a < m_GLVersion.length(); ++a)
{
if (m_GLVersion.charAt(a) == ' ')
{
mVEnd = a;
break;
}
}
// 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);
}
mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd));
if (mVersion >= 14.0f)
mSupportsGLES3 = true;
}
}
return mSupportsGLES3;
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.video_prefs);
//
// 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 int id;
private final List<SideMenuItem>items;
public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects)
{
super(context, textViewResourceId, objects);
@ -24,32 +24,32 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
id = textViewResourceId;
items = objects;
}
public SideMenuItem getItem(int i)
{
return items.get(i);
return items.get(i);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
final SideMenuItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
if(title != null)
title.setText(item.getName());
}
return v;
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
final SideMenuItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
if (title != null)
title.setText(item.getName());
}
return v;
}
}

View File

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