[Android] Implement a ViewPager for the settings. Also, move classes into appropriate packages to make things cleaner.

This commit is contained in:
Lioncash 2013-08-20 19:39:00 -04:00
parent a3a4f21284
commit 00996c8d38
26 changed files with 689 additions and 423 deletions

View File

@ -4,45 +4,51 @@
android:versionCode="10"
android:versionName="0.10" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<uses-feature android:name="android.hardware.screen.landscape" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="14" />
<uses-feature android:glEsVersion="0x00020000" >
</uses-feature>
<uses-feature android:name="android.hardware.screen.landscape" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/launcher"
android:label="@string/app_name">
android:label="@string/app_name" >
<activity
android:name=".DolphinEmulator"
android:name="org.dolphinemu.dolphinemu.DolphinEmulator"
android:configChanges="locale|keyboard|keyboardHidden|navigation|fontScale|uiMode"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
android:configChanges="locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="org.dolphinemu.dolphinemu.FolderBrowser"
android:label="@string/app_name"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
android:name="org.dolphinemu.dolphinemu.folderbrowser.FolderBrowser"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode"
android:label="@string/app_name" >
</activity>
<activity
android:name=".InputConfigFragment"
android:label="@string/app_name"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
android:name="org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode"
android:label="@string/app_name" >
</activity>
<activity android:name="org.dolphinemu.dolphinemu.settings.PrefsFragment" >
</activity>
<activity android:name="org.dolphinemu.dolphinemu.gamelist.GameListActivity" >
</activity>
<activity android:name="org.dolphinemu.dolphinemu.AboutFragment" >
</activity>
<activity
android:name=".PrefsFragment" >
</activity>
<activity
android:name=".GameListActivity" >
</activity>
<activity
android:name=".AboutFragment" >
android:name="org.dolphinemu.dolphinemu.settings.PrefsActivity"
android:label="@string/settings" >
</activity>
</application>

View File

@ -0,0 +1,6 @@
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefsActivity" />

View File

@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View File

@ -3,22 +3,22 @@
<!-- Title of the app -->
<string name="app_name">Dolphin Emulator</string>
<!-- Navigation-related Strings -->
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<!-- About Fragment -->
<string name="build_revision">Build Revision:</string>
<string name="supports_gles3">Supports OpenGL ES 3:</string>
<!-- Folder Browser -->
<string name="current_dir">Current Dir: </string>
<string name="parent_directory">Parent Directory</string>
<string name="folder">Folder</string>
<string name="file_size">File Size: </string>
<string name="cant_use_compressed_filetypes">Can not use compressed file types</string>
<!-- Game List Activity -->
<string name="game_list">Game List</string>
<string name="browse_folder">Browse Folder</string>
@ -28,7 +28,7 @@
<!-- Game List Fragment -->
<string name="file_clicked">File clicked: </string>
<!-- Input Config Fragment -->
<string name="draw_onscreen_controls">Draw on-screen controls</string>
<string name="button_a">Button A</string>
@ -51,11 +51,10 @@
<string name="c_stick_right">C Stick Right</string>
<string name="trigger_left">Trigger L</string>
<string name="trigger_right">Trigger R</string>
<string name="not_drawing_onscreen_controls">Not drawing on-screen controls</string>
<string name="drawing_onscreen_controls">Drawing on-screen controls</string>
<string name="press_button_to_config">Press button to configure %1$s</string>
<!-- Prefs Fragment -->
<string name="interpreter">Interpreter</string>
<string name="jit64_recompiler">JIT64 Recompiler</string>
@ -66,7 +65,6 @@
<string name="emu_core_to_use">Emulation core to use</string>
<string name="dual_core">Dual Core</string>
<string name="on_off">On/Off</string>
<string name="video_settings">Video Settings</string>
<string name="software_renderer">Software Renderer</string>
<string name="opengl_es3">OpenGL ES 3</string>
@ -121,5 +119,6 @@
<string name="no">No</string>
<string name="disabled">Disabled</string>
<string name="other">Other</string>
</resources>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- CPU Settings -->
<CheckBoxPreference
android:key="dualCorePref"
android:summary="@string/on_off"
android:title="@string/dual_core" />
<ListPreference
android:key="cpuCorePref"
android:summary="@string/emu_core_to_use"
android:title="@string/cpu_core" />
</PreferenceScreen>

View File

@ -1,144 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- CPU Settings -->
<PreferenceScreen android:title="@string/cpu_settings">
<CheckBoxPreference
android:key="dualCorePref"
android:summary="@string/on_off"
android:title="@string/dual_core" />
<ListPreference
android:key="cpuCorePref"
android:summary="@string/emu_core_to_use"
android:title="@string/cpu_core" />
</PreferenceScreen>
<!-- Video Settings -->
<PreferenceScreen android:title="@string/video_settings">
<!-- Video Enhancements -->
<PreferenceScreen android:title="@string/enhancements">
<ListPreference
android:entries="@array/internalResolutionEntries"
android:entryValues="@array/internalResolutionValues"
android:key="internalResolution"
android:summary="@string/internal_resolution_descrip"
android:title="@string/internal_resolution"/>
<ListPreference
android:entries="@array/anisotropicFilteringEntries"
android:entryValues="@array/anisotropicFilteringValues"
android:key="anisotropicFiltering"
android:summary="@string/anisotropic_filtering_descrip"
android:title="@string/anisotropic_filtering"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="scaledEFBCopy"
android:summary="@string/scaled_efb_copy_descrip"
android:title="@string/scaled_efb_copy"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="perPixelLighting"
android:summary="@string/per_pixel_lighting_descrip"
android:title="@string/per_pixel_lighting"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="forceTextureFiltering"
android:summary="@string/force_texture_filtering_descrip"
android:title="@string/force_texture_filtering"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="disableFog"
android:summary="@string/disable_fog_descrip"
android:title="@string/disable_fog"/>
</PreferenceScreen>
<!-- Video Hacks -->
<PreferenceScreen android:title="@string/hacks">
<PreferenceCategory android:title="@string/embedded_frame_buffer">
<CheckBoxPreference
android:defaultValue="false"
android:key="skipEFBAccess"
android:summary="@string/skip_efb_access_descrip"
android:title="@string/skip_efb_access"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="ignoreFormatChanges"
android:summary="@string/ignore_format_changes_descrip"
android:title="@string/ignore_format_changes"/>
<ListPreference
android:defaultValue="Texture"
android:entries="@array/efbCopyMethodEntries"
android:entryValues="@array/efbCopyMethodValues"
android:key="efbCopyMethod"
android:summary="@string/efb_copy_method_descrip"
android:title="@string/efb_copy_method"/>
</PreferenceCategory>
<!-- Texture Cache -->
<PreferenceCategory android:title="@string/texture_cache">
<ListPreference
android:defaultValue="Low"
android:entries="@array/textureCacheAccuracyEntries"
android:entryValues="@array/textureCacheAccuracyValues"
android:key="textureCacheAccuracy"
android:summary="@string/texture_cache_accuracy_descrip"
android:title="@string/texture_cache_accuracy"/>
</PreferenceCategory>
<!-- External Frame Buffer -->
<PreferenceCategory android:title="@string/external_frame_buffer">
<ListPreference
android:defaultValue="Disabled"
android:entries="@array/externalFrameBufferEntries"
android:entryValues="@array/externalFrameBufferValues"
android:key="externalFrameBuffer"
android:summary="@string/external_frame_buffer_descrip"
android:title="@string/external_frame_buffer"/>
</PreferenceCategory>
<!-- Other Hacks -->
<PreferenceCategory android:title="@string/other">
<CheckBoxPreference
android:defaultValue="false"
android:key="cacheDisplayLists"
android:summary="@string/cache_display_lists_descrip"
android:title="@string/cache_display_lists"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="disableDestinationAlpha"
android:summary="@string/disable_destination_alpha_descrip"
android:title="@string/disable_destination_alpha"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="fastDepthCalculation"
android:summary="@string/fast_depth_calculation_descrip"
android:title="@string/fast_depth_calculation"/>
</PreferenceCategory>
</PreferenceScreen>
<ListPreference
android:key="gpuPref"
android:summary="@string/video_backend_to_use"
android:title="@string/video_backend" />
</PreferenceScreen>
</PreferenceScreen>

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Video Settings -->
<!-- Video Enhancements -->
<PreferenceScreen android:title="@string/enhancements">
<ListPreference
android:entries="@array/internalResolutionEntries"
android:entryValues="@array/internalResolutionValues"
android:key="internalResolution"
android:summary="@string/internal_resolution_descrip"
android:title="@string/internal_resolution"/>
<ListPreference
android:entries="@array/anisotropicFilteringEntries"
android:entryValues="@array/anisotropicFilteringValues"
android:key="anisotropicFiltering"
android:summary="@string/anisotropic_filtering_descrip"
android:title="@string/anisotropic_filtering"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="scaledEFBCopy"
android:summary="@string/scaled_efb_copy_descrip"
android:title="@string/scaled_efb_copy"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="perPixelLighting"
android:summary="@string/per_pixel_lighting_descrip"
android:title="@string/per_pixel_lighting"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="forceTextureFiltering"
android:summary="@string/force_texture_filtering_descrip"
android:title="@string/force_texture_filtering"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="disableFog"
android:summary="@string/disable_fog_descrip"
android:title="@string/disable_fog"/>
</PreferenceScreen>
<!-- Video Hacks -->
<PreferenceScreen android:title="@string/hacks">
<PreferenceCategory android:title="@string/embedded_frame_buffer">
<CheckBoxPreference
android:defaultValue="false"
android:key="skipEFBAccess"
android:summary="@string/skip_efb_access_descrip"
android:title="@string/skip_efb_access"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="ignoreFormatChanges"
android:summary="@string/ignore_format_changes_descrip"
android:title="@string/ignore_format_changes"/>
<ListPreference
android:defaultValue="Texture"
android:entries="@array/efbCopyMethodEntries"
android:entryValues="@array/efbCopyMethodValues"
android:key="efbCopyMethod"
android:summary="@string/efb_copy_method_descrip"
android:title="@string/efb_copy_method"/>
</PreferenceCategory>
<!-- Texture Cache -->
<PreferenceCategory android:title="@string/texture_cache">
<ListPreference
android:defaultValue="Low"
android:entries="@array/textureCacheAccuracyEntries"
android:entryValues="@array/textureCacheAccuracyValues"
android:key="textureCacheAccuracy"
android:summary="@string/texture_cache_accuracy_descrip"
android:title="@string/texture_cache_accuracy"/>
</PreferenceCategory>
<!-- External Frame Buffer -->
<PreferenceCategory android:title="@string/external_frame_buffer">
<ListPreference
android:defaultValue="Disabled"
android:entries="@array/externalFrameBufferEntries"
android:entryValues="@array/externalFrameBufferValues"
android:key="externalFrameBuffer"
android:summary="@string/external_frame_buffer_descrip"
android:title="@string/external_frame_buffer"/>
</PreferenceCategory>
<!-- Other Hacks -->
<PreferenceCategory android:title="@string/other">
<CheckBoxPreference
android:defaultValue="false"
android:key="cacheDisplayLists"
android:summary="@string/cache_display_lists_descrip"
android:title="@string/cache_display_lists"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="disableDestinationAlpha"
android:summary="@string/disable_destination_alpha_descrip"
android:title="@string/disable_destination_alpha"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="fastDepthCalculation"
android:summary="@string/fast_depth_calculation_descrip"
android:title="@string/fast_depth_calculation"/>
</PreferenceCategory>
</PreferenceScreen>
<ListPreference
android:key="gpuPref"
android:summary="@string/video_backend_to_use"
android:title="@string/video_backend" />
</PreferenceScreen>

View File

@ -11,6 +11,10 @@ import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowserAdapter;
import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowserItem;
import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
@ -42,7 +46,7 @@ public final class AboutFragment extends Fragment
List<FolderBrowserItem> Input = new ArrayList<FolderBrowserItem>();
Input.add(new FolderBrowserItem(getString(R.string.build_revision), NativeLibrary.GetVersionString(), "", true));
Input.add(new FolderBrowserItem(getString(R.string.supports_gles3), PrefsFragment.SupportsGLES3() ? yes : no, "", true));
Input.add(new FolderBrowserItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no, "", true));
adapter = new FolderBrowserAdapter(m_activity, R.layout.about_layout, Input);
mMainList.setAdapter(adapter);

View File

@ -15,6 +15,10 @@ import android.view.WindowManager;
import java.io.*;
import java.util.List;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import org.dolphinemu.dolphinemu.settings.UserPreferences;
public final class DolphinEmulator<MainActivity> extends Activity
{
static private NativeGLSurfaceView GLview = null;

View File

@ -1,226 +0,0 @@
package org.dolphinemu.dolphinemu;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL10;
//
// TODO: It would be nice to situate the preferences in a ViewPager.
// In such a way that the video settings are divided into sections like
// [General | Enhancements | Hacks]
//
// However I do not know how to correctly get ViewPagers to work with PreferenceFragments
// (at the time of writing), so if anyone else can implement this (AND document it nicely)
// that would be awesome
//
// - Lioncash
//
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
public final class PrefsFragment extends PreferenceFragment
{
private Activity m_activity;
static public class VersionCheck
{
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
GL10 mGL;
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
};
// 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();
}
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
};
// 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);
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();
boolean mSupportsGLES3 = false;
// 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));
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.prefs);
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);
}
//
// 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()
+ " must implement OnGameListZeroListener");
}
}
@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

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.folderbrowser;
import android.app.Activity;
import android.app.Fragment;
@ -14,6 +14,10 @@ import android.widget.Toast;
import java.io.File;
import java.util.*;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
public final class FolderBrowser extends Fragment
{
private Activity m_activity;

View File

@ -1,4 +1,6 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.folderbrowser;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
@ -8,7 +10,7 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import org.dolphinemu.dolphinemu.R;
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.folderbrowser;
import java.io.File;

View File

@ -1,8 +1,9 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.gamelist;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
@ -13,6 +14,17 @@ import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
import org.dolphinemu.dolphinemu.AboutFragment;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowser;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigAdapter;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigItem;
import org.dolphinemu.dolphinemu.settings.PrefsActivity;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuItem;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
@ -144,11 +156,9 @@ public final class GameListActivity extends Activity
break;
case 2:
{
mCurFragmentNum = 2;
mCurFragment = new PrefsFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
{
Intent intent = new Intent(this, PrefsActivity.class);
startActivity(intent);
}
break;

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.gamelist;
import android.content.Context;
import android.view.LayoutInflater;
@ -10,6 +10,8 @@ import android.widget.TextView;
import java.util.List;
import org.dolphinemu.dolphinemu.R;
public final class GameListAdapter extends ArrayAdapter<GameListItem>
{
private final Context c;

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.gamelist;
import android.app.Activity;
import android.app.Fragment;
@ -19,6 +19,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.gamelist;
import android.content.Context;
import android.graphics.Bitmap;
@ -8,6 +8,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.dolphinemu.dolphinemu.NativeLibrary;
public final class GameListItem implements Comparable<GameListItem>
{
private String name;

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.inputconfig;
import android.content.Context;
import android.view.LayoutInflater;
@ -9,6 +9,8 @@ import android.widget.TextView;
import java.util.List;
import org.dolphinemu.dolphinemu.R;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2

View File

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.inputconfig;
import android.app.Activity;
import android.app.Fragment;
@ -13,6 +13,9 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2

View File

@ -4,7 +4,9 @@
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.inputconfig;
import org.dolphinemu.dolphinemu.NativeLibrary;
/**
* Represents a controller input item (button, stick, etc).

View File

@ -0,0 +1,81 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.R;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
/**
* Responsible for the loading of the CPU preferences.
*/
public final class CPUSettingsFragment extends PreferenceFragment
{
private Activity m_activity;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.cpu_prefs);
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()
+ " must implement OnGameListZeroListener");
}
}
@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

@ -0,0 +1,146 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.R;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
/**
* Main activity that manages all of the preference fragments used to display
* the settings to the user.
*/
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.
}
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 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;
}
}
}
}

View File

@ -1,4 +1,12 @@
package org.dolphinemu.dolphinemu;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.NativeLibrary;
import android.content.Context;
import android.content.SharedPreferences;

View File

@ -0,0 +1,202 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.settings;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL10;
import org.dolphinemu.dolphinemu.R;
import android.app.Activity;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
/**
* Responsible for handling the loading of the video preferences.
*/
public final class VideoSettingsFragment extends PreferenceFragment
{
private Activity m_activity;
static public class VersionCheck
{
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
GL10 mGL;
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
};
// 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();
}
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
};
// 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);
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();
boolean mSupportsGLES3 = false;
// 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));
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()
+ " must implement OnGameListZeroListener");
}
}
@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

@ -1,4 +1,4 @@
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.sidemenu;
import android.content.Context;
import android.view.LayoutInflater;
@ -9,6 +9,8 @@ import android.widget.TextView;
import java.util.List;
import org.dolphinemu.dolphinemu.R;
public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
{
private final Context c;

View File

@ -4,7 +4,7 @@
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu;
package org.dolphinemu.dolphinemu.sidemenu;
/**