mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Convert the Android source code to the directory structure of a Gradle-based Android Studio project.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,67 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion "20.0.0"
|
||||
|
||||
task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
|
||||
destinationDir file("$buildDir/native-libs")
|
||||
baseName 'native-libs'
|
||||
extension 'jar'
|
||||
from fileTree(dir: 'libs', include: '**/*.so')
|
||||
into 'lib/'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
compileTask -> compileTask.dependsOn(nativeLibsToJar)
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
// This is important as it will run lint but not abort on error
|
||||
// Lint has some overly obnoxious "errors" that should really be warnings
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.dolphinemu.dolphinemu"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 21
|
||||
versionCode 13
|
||||
versionName "0.13"
|
||||
}
|
||||
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
if (project.hasProperty('keystore')) {
|
||||
storeFile file(project.property('keystore'))
|
||||
storePassword project.property('storepass')
|
||||
keyAlias project.property('keyalias')
|
||||
keyPassword project.property('keypass')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
// Signed by release key, allowing for upload to Play Store.
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
|
||||
// Signed by debug key disallowing distribution on Play Store.
|
||||
// Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
versionNameSuffix '-debug'
|
||||
jniDebuggable true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
|
||||
|
||||
compile 'com.android.support:support-v4:22.0.0'
|
||||
compile 'com.android.support:support-v13:22.0.0'
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/sigma/apps/android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.dolphinemu.dolphinemu">
|
||||
|
||||
<uses-feature android:glEsVersion="0x00030000" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:allowBackup="true"
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name="org.dolphinemu.dolphinemu.gamelist.GameListActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Holo.Light" >
|
||||
|
||||
<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->
|
||||
<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.about.AboutActivity"
|
||||
android:theme="@android:style/Theme.Holo.Light" />
|
||||
|
||||
<activity
|
||||
android:name="org.dolphinemu.dolphinemu.emulation.EmulationActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
|
||||
<activity
|
||||
android:name="org.dolphinemu.dolphinemu.settings.input.overlayconfig.OverlayConfigActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
|
||||
|
||||
<activity
|
||||
android:name="org.dolphinemu.dolphinemu.settings.PrefsActivity"
|
||||
android:label="@string/settings"
|
||||
android:theme="@android:style/Theme.Holo.Light" />
|
||||
|
||||
<service android:name=".AssetCopyService"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import org.dolphinemu.dolphinemu.settings.UserPreferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* A service that spawns its own thread in order to copy several binary and shader files
|
||||
* from the Dolphin APK to the external file system.
|
||||
*/
|
||||
public final class AssetCopyService extends IntentService
|
||||
{
|
||||
private static final String TAG = "DolphinEmulator";
|
||||
|
||||
public AssetCopyService()
|
||||
{
|
||||
// Superclass constructor is called to name the thread on which this service executes.
|
||||
super("AssetCopyService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent)
|
||||
{
|
||||
String BaseDir = NativeLibrary.GetUserDirectory();
|
||||
String ConfigDir = BaseDir + File.separator + "Config";
|
||||
String GCDir = BaseDir + File.separator + "GC";
|
||||
|
||||
// Copy assets if needed
|
||||
File file = new File(GCDir + File.separator + "font_sjis.bin");
|
||||
if(!file.exists())
|
||||
{
|
||||
NativeLibrary.CreateUserFolders();
|
||||
copyAsset("dsp_coef.bin", GCDir + File.separator + "dsp_coef.bin");
|
||||
copyAsset("dsp_rom.bin", GCDir + File.separator + "dsp_rom.bin");
|
||||
copyAsset("font_ansi.bin", GCDir + File.separator + "font_ansi.bin");
|
||||
copyAsset("font_sjis.bin", GCDir + File.separator + "font_sjis.bin");
|
||||
copyAssetFolder("Shaders", BaseDir + File.separator + "Shaders");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.v(TAG, "Skipping asset copy operation.");
|
||||
}
|
||||
|
||||
// Always copy over the GCPad config in case of change or corruption.
|
||||
// Not a user configurable file.
|
||||
copyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini");
|
||||
|
||||
// Load the configuration keys set in the Dolphin ini and gfx ini files
|
||||
// into the application's shared preferences.
|
||||
UserPreferences.LoadIniToPrefs(this);
|
||||
}
|
||||
|
||||
private void copyAsset(String asset, String output)
|
||||
{
|
||||
Log.v(TAG, "Copying " + asset + " to " + 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(TAG, "Failed to copy asset file: " + asset, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyAssetFolder(String assetFolder, String outputFolder)
|
||||
{
|
||||
Log.v(TAG, "Copying " + assetFolder + " to " + outputFolder);
|
||||
|
||||
try
|
||||
{
|
||||
for (String file : getAssets().list(assetFolder))
|
||||
{
|
||||
copyAsset(assetFolder + File.separator + file, outputFolder + File.separator + file);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.e(TAG, "Failed to copy asset folder: " + assetFolder, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright 2013 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
|
||||
/**
|
||||
* Class which contains methods that interact
|
||||
* with the native side of the Dolphin code.
|
||||
*/
|
||||
public final class NativeLibrary
|
||||
{
|
||||
/**
|
||||
* Button type for use in onTouchEvent
|
||||
*/
|
||||
public static final class ButtonType
|
||||
{
|
||||
public static final int BUTTON_A = 0;
|
||||
public static final int BUTTON_B = 1;
|
||||
public static final int BUTTON_START = 2;
|
||||
public static final int BUTTON_X = 3;
|
||||
public static final int BUTTON_Y = 4;
|
||||
public static final int BUTTON_Z = 5;
|
||||
public static final int BUTTON_UP = 6;
|
||||
public static final int BUTTON_DOWN = 7;
|
||||
public static final int BUTTON_LEFT = 8;
|
||||
public static final int BUTTON_RIGHT = 9;
|
||||
public static final int STICK_MAIN = 10;
|
||||
public static final int STICK_MAIN_UP = 11;
|
||||
public static final int STICK_MAIN_DOWN = 12;
|
||||
public static final int STICK_MAIN_LEFT = 13;
|
||||
public static final int STICK_MAIN_RIGHT = 14;
|
||||
public static final int STICK_C = 15;
|
||||
public static final int STICK_C_UP = 16;
|
||||
public static final int STICK_C_DOWN = 17;
|
||||
public static final int STICK_C_LEFT = 18;
|
||||
public static final int STICK_C_RIGHT = 19;
|
||||
public static final int TRIGGER_L = 20;
|
||||
public static final int TRIGGER_R = 21;
|
||||
}
|
||||
|
||||
/**
|
||||
* Button states
|
||||
*/
|
||||
public static final class ButtonState
|
||||
{
|
||||
public static final int RELEASED = 0;
|
||||
public static final int PRESSED = 1;
|
||||
}
|
||||
|
||||
private NativeLibrary()
|
||||
{
|
||||
// Disallows instantiation.
|
||||
}
|
||||
|
||||
/**
|
||||
* Default touchscreen device
|
||||
*/
|
||||
public static final String TouchScreenDevice = "Touchscreen";
|
||||
|
||||
/**
|
||||
* Handles button press events for a gamepad.
|
||||
*
|
||||
* @param Device The input descriptor of the gamepad.
|
||||
* @param Button Key code identifying which button was pressed.
|
||||
* @param Action Mask identifying which action is happing (button pressed down, or button released).
|
||||
*
|
||||
* @return If we handled the button press.
|
||||
*/
|
||||
public static native boolean onGamePadEvent(String Device, int Button, int Action);
|
||||
|
||||
/**
|
||||
* Handles gamepad movement events.
|
||||
*
|
||||
* @param Device The device ID of the gamepad.
|
||||
* @param Axis The axis ID
|
||||
* @param Value The value of the axis represented by the given ID.
|
||||
*/
|
||||
public static native void onGamePadMoveEvent(String Device, int Axis, float Value);
|
||||
|
||||
/**
|
||||
* Gets a value from a key in the given ini-based config file.
|
||||
*
|
||||
* @param configFile The ini-based config file to get the value from.
|
||||
* @param Section The section key that the actual key is in.
|
||||
* @param Key The key to get the value from.
|
||||
* @param Default The value to return in the event the given key doesn't exist.
|
||||
*
|
||||
* @return the value stored at the key, or a default value if it doesn't exist.
|
||||
*/
|
||||
public static native String GetConfig(String configFile, String Section, String Key, String Default);
|
||||
|
||||
/**
|
||||
* Sets a value to a key in the given ini config file.
|
||||
*
|
||||
* @param configFile The ini-based config file to add the value to.
|
||||
* @param Section The section key for the ini key
|
||||
* @param Key The actual ini key to set.
|
||||
* @param Value The string to set the ini key to.
|
||||
*/
|
||||
public static native void SetConfig(String configFile, String Section, String Key, String Value);
|
||||
|
||||
/**
|
||||
* Sets the filename to be run during emulation.
|
||||
*
|
||||
* @param filename The filename to be run during emulation.
|
||||
*/
|
||||
public static native void SetFilename(String filename);
|
||||
|
||||
/**
|
||||
* Gets the embedded banner within the given ISO/ROM.
|
||||
*
|
||||
* @param filename the file path to the ISO/ROM.
|
||||
*
|
||||
* @return an integer array containing the color data for the banner.
|
||||
*/
|
||||
public static native int[] GetBanner(String filename);
|
||||
|
||||
/**
|
||||
* Gets the embedded title of the given ISO/ROM.
|
||||
*
|
||||
* @param filename The file path to the ISO/ROM.
|
||||
*
|
||||
* @return the embedded title of the ISO/ROM.
|
||||
*/
|
||||
public static native String GetTitle(String filename);
|
||||
|
||||
/**
|
||||
* Gets the Dolphin version string.
|
||||
*
|
||||
* @return the Dolphin version string.
|
||||
*/
|
||||
public static native String GetVersionString();
|
||||
|
||||
/**
|
||||
* Returns if the phone supports NEON or not
|
||||
*
|
||||
* @return true if it supports NEON, false otherwise.
|
||||
*/
|
||||
public static native boolean SupportsNEON();
|
||||
|
||||
/**
|
||||
* Saves a screen capture of the game
|
||||
*
|
||||
*/
|
||||
public static native void SaveScreenShot();
|
||||
|
||||
/**
|
||||
* Saves a game state to the slot number.
|
||||
*
|
||||
* @param slot The slot location to save state to.
|
||||
*/
|
||||
public static native void SaveState(int slot);
|
||||
|
||||
/**
|
||||
* Loads a game state from the slot number.
|
||||
*
|
||||
* @param slot The slot location to load state from.
|
||||
*/
|
||||
public static native void LoadState(int slot);
|
||||
|
||||
/**
|
||||
* Creates the initial folder structure in /sdcard/dolphin-emu/
|
||||
*/
|
||||
public static native void CreateUserFolders();
|
||||
|
||||
/**
|
||||
* Sets the current working user directory
|
||||
* If not set, it auto-detects a location
|
||||
*/
|
||||
public static native void SetUserDirectory(String directory);
|
||||
|
||||
/**
|
||||
* Returns the current working user directory
|
||||
*/
|
||||
public static native String GetUserDirectory();
|
||||
|
||||
/**
|
||||
* Begins emulation.
|
||||
*
|
||||
* @param surf The surface to render to.
|
||||
*/
|
||||
public static native void Run(Surface surf);
|
||||
|
||||
/** Unpauses emulation from a paused state. */
|
||||
public static native void UnPauseEmulation();
|
||||
|
||||
/** Pauses emulation. */
|
||||
public static native void PauseEmulation();
|
||||
|
||||
/** Stops emulation. */
|
||||
public static native void StopEmulation();
|
||||
|
||||
/** Native EGL functions not exposed by Java bindings **/
|
||||
public static native void eglBindAPI(int api);
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
System.loadLibrary("main");
|
||||
}
|
||||
catch (UnsatisfiedLinkError ex)
|
||||
{
|
||||
Log.e("NativeLibrary", ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v13.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
||||
|
||||
/**
|
||||
* Activity for the about menu, which displays info
|
||||
* related to the CPU and GPU. Along with misc other info.
|
||||
*/
|
||||
public final class AboutActivity extends Activity
|
||||
{
|
||||
private final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Set the view pager
|
||||
setContentView(R.layout.viewpager);
|
||||
|
||||
// Initialize the viewpager.
|
||||
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
viewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
eglHelper.closeHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link FragmentPagerAdapter} subclass responsible for handling
|
||||
* the individual {@link Fragment}s within the {@link ViewPager}.
|
||||
*/
|
||||
private final class ViewPagerAdapter extends FragmentPagerAdapter
|
||||
{
|
||||
private final String[] pageTitles = {
|
||||
getString(R.string.general),
|
||||
getString(R.string.cpu),
|
||||
getString(R.string.gles_two),
|
||||
getString(R.string.gles_three),
|
||||
getString(R.string.desktop_gl),
|
||||
};
|
||||
|
||||
public ViewPagerAdapter(FragmentManager fm)
|
||||
{
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position)
|
||||
{
|
||||
if (position == 0)
|
||||
{
|
||||
return new DolphinInfoFragment();
|
||||
}
|
||||
else if (position == 1)
|
||||
{
|
||||
return new CPUInfoFragment(); // CPU
|
||||
}
|
||||
else if (position == 2) // GLES 2
|
||||
{
|
||||
return new GLES2InfoFragment();
|
||||
}
|
||||
else if (position == 3) // GLES 3 or OpenGL (depending on circumstances)
|
||||
{
|
||||
if (eglHelper.supportsGLES3())
|
||||
return new GLES3InfoFragment();
|
||||
else
|
||||
return new GLInfoFragment(); // GLES3 not supported, but OpenGL is.
|
||||
}
|
||||
else if (position == 4) // OpenGL fragment
|
||||
{
|
||||
return new GLInfoFragment();
|
||||
}
|
||||
|
||||
// This should never happen.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
if (eglHelper.supportsGLES3() && eglHelper.supportsOpenGL())
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else if (!eglHelper.supportsGLES3() && !eglHelper.supportsOpenGL())
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else // Either regular OpenGL or GLES3 isn't supported
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position)
|
||||
{
|
||||
return pageTitles[position];
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
/**
|
||||
* Represents an item within an info fragment in the About menu.
|
||||
*/
|
||||
final class AboutFragmentItem
|
||||
{
|
||||
private final String title;
|
||||
private final String subtitle;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param title The title of this item.
|
||||
* @param subtitle The subtitle for this item.
|
||||
*/
|
||||
public AboutFragmentItem(String title, String subtitle)
|
||||
{
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title of this item.
|
||||
*
|
||||
* @return the title of this item.
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subtitle of this item.
|
||||
*
|
||||
* @return the subtitle of this item.
|
||||
*/
|
||||
public String getSubTitle()
|
||||
{
|
||||
return subtitle;
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* {@link ArrayAdapter} subclass specifically for the
|
||||
* information fragments within the about menu.
|
||||
*/
|
||||
final class AboutInfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
|
||||
{
|
||||
private final int id;
|
||||
private final List<AboutFragmentItem> items;
|
||||
|
||||
public AboutInfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
|
||||
{
|
||||
super(ctx, id, items);
|
||||
|
||||
this.id = id;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AboutFragmentItem getItem(int index)
|
||||
{
|
||||
return items.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent)
|
||||
{
|
||||
if (convertView == null)
|
||||
{
|
||||
LayoutInflater vi = LayoutInflater.from(getContext());
|
||||
convertView = vi.inflate(id, parent, false);
|
||||
}
|
||||
|
||||
final AboutFragmentItem item = items.get(position);
|
||||
if (item != null)
|
||||
{
|
||||
TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
|
||||
TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
|
||||
|
||||
if (title != null)
|
||||
title.setText(item.getTitle());
|
||||
|
||||
if (subtitle != null)
|
||||
subtitle.setText(item.getSubTitle());
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.utils.CPUHelper;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* {@link ListFragment class that is responsible
|
||||
* for displaying information related to the CPU.
|
||||
*/
|
||||
public final class CPUInfoFragment extends ListFragment
|
||||
{
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||
List<AboutFragmentItem> items = new ArrayList<AboutFragmentItem>();
|
||||
|
||||
CPUHelper cpuHelper = new CPUHelper(getActivity());
|
||||
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_info), cpuHelper.getProcessorInfo()));
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_type), cpuHelper.getProcessorType()));
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_abi_one), Build.CPU_ABI));
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_abi_two), Build.CPU_ABI2));
|
||||
items.add(new AboutFragmentItem(getString(R.string.num_cores), Integer.toString(cpuHelper.getNumCores())));
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_features), cpuHelper.getFeatures()));
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_hardware), Build.HARDWARE));
|
||||
if (CPUHelper.isARM())
|
||||
items.add(new AboutFragmentItem(getString(R.string.cpu_implementer), cpuHelper.getImplementer()));
|
||||
|
||||
AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, items);
|
||||
rootView.setAdapter(adapter);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
/**
|
||||
* Represents the about screen.
|
||||
*/
|
||||
public final class DolphinInfoFragment extends ListFragment
|
||||
{
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||
EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
|
||||
|
||||
final String yes = getString(R.string.yes);
|
||||
final String no = getString(R.string.no);
|
||||
|
||||
List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
|
||||
Input.add(new AboutFragmentItem(getString(R.string.build_revision), NativeLibrary.GetVersionString()));
|
||||
Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), eglHelper.supportsGLES3() ? yes : no));
|
||||
Input.add(new AboutFragmentItem(getString(R.string.supports_neon), NativeLibrary.SupportsNEON() ? yes : no));
|
||||
|
||||
AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
|
||||
rootView.setAdapter(adapter);
|
||||
rootView.setEnabled(false); // Makes the list view non-clickable.
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.opengl.GLES20;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.about.Limit.Type;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link ListFragment} responsible for displaying
|
||||
* information relating to OpenGL ES 2.
|
||||
*/
|
||||
public final class GLES2InfoFragment extends ListFragment
|
||||
{
|
||||
private final Limit[] Limits = {
|
||||
new Limit("Vendor", GLES20.GL_VENDOR, Type.STRING),
|
||||
new Limit("Version", GLES20.GL_VERSION, Type.STRING),
|
||||
new Limit("Renderer", GLES20.GL_RENDERER, Type.STRING),
|
||||
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
|
||||
// GLES 2.0 Limits
|
||||
new Limit("Aliased Point Size", GLES20.GL_ALIASED_POINT_SIZE_RANGE, Type.INTEGER_RANGE),
|
||||
new Limit("Aliased Line Width ", GLES20.GL_ALIASED_LINE_WIDTH_RANGE, Type.INTEGER_RANGE),
|
||||
new Limit("Max Texture Size", GLES20.GL_MAX_TEXTURE_SIZE, Type.INTEGER),
|
||||
new Limit("Viewport Dimensions", GLES20.GL_MAX_VIEWPORT_DIMS, Type.INTEGER_RANGE),
|
||||
new Limit("Subpixel Bits", GLES20.GL_SUBPIXEL_BITS, Type.INTEGER),
|
||||
new Limit("Max Vertex Attributes", GLES20.GL_MAX_VERTEX_ATTRIBS, Type.INTEGER),
|
||||
new Limit("Max Vertex Uniform Vectors", GLES20.GL_MAX_VERTEX_UNIFORM_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Varying Vectors", GLES20.GL_MAX_VARYING_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Combined Texture Units", GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Vertex Texture Units", GLES20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Texture Units", GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Fragment Uniform Vectors", GLES20.GL_MAX_FRAGMENT_UNIFORM_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Cubemap Texture Size", GLES20.GL_MAX_CUBE_MAP_TEXTURE_SIZE, Type.INTEGER),
|
||||
new Limit("Shader Binary Formats", GLES20.GL_NUM_SHADER_BINARY_FORMATS, Type.INTEGER),
|
||||
new Limit("Max Framebuffer Size", GLES20.GL_MAX_RENDERBUFFER_SIZE, Type.INTEGER),
|
||||
};
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
|
||||
|
||||
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||
List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
|
||||
|
||||
for (Limit limit : Limits)
|
||||
{
|
||||
Log.i("GLES2InfoFragment", "Getting enum " + limit.name);
|
||||
Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
|
||||
}
|
||||
|
||||
// Get extensions manually
|
||||
String[] extensions = eglHelper.glGetString(GLES20.GL_EXTENSIONS).split(" ");
|
||||
StringBuilder extensionsBuilder = new StringBuilder();
|
||||
for (String extension : extensions)
|
||||
{
|
||||
extensionsBuilder.append(extension).append('\n');
|
||||
}
|
||||
Input.add(new AboutFragmentItem("OpenGL ES 2.0 Extensions", extensionsBuilder.toString()));
|
||||
|
||||
AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
|
||||
rootView.setAdapter(adapter);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.opengl.GLES30;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.about.Limit.Type;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link ListFragment} responsible for displaying
|
||||
* information relating to OpenGL ES 3.
|
||||
*/
|
||||
public final class GLES3InfoFragment extends ListFragment
|
||||
{
|
||||
private final Limit[] Limits = {
|
||||
new Limit("Vendor", GLES30.GL_VENDOR, Type.STRING),
|
||||
new Limit("Version", GLES30.GL_VERSION, Type.STRING),
|
||||
new Limit("Renderer", GLES30.GL_RENDERER, Type.STRING),
|
||||
new Limit("GLSL version", GLES30.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
|
||||
// GLES 2.0 Limits
|
||||
new Limit("Aliased Point Size", GLES30.GL_ALIASED_POINT_SIZE_RANGE, Type.INTEGER_RANGE),
|
||||
new Limit("Aliased Line Width ", GLES30.GL_ALIASED_LINE_WIDTH_RANGE, Type.INTEGER_RANGE),
|
||||
new Limit("Max Texture Size", GLES30.GL_MAX_TEXTURE_SIZE, Type.INTEGER),
|
||||
new Limit("Viewport Dimensions", GLES30.GL_MAX_VIEWPORT_DIMS, Type.INTEGER_RANGE),
|
||||
new Limit("Subpixel Bits", GLES30.GL_SUBPIXEL_BITS, Type.INTEGER),
|
||||
new Limit("Max Vertex Attributes", GLES30.GL_MAX_VERTEX_ATTRIBS, Type.INTEGER),
|
||||
new Limit("Max Vertex Uniform Vectors", GLES30.GL_MAX_VERTEX_UNIFORM_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Varying Vectors", GLES30.GL_MAX_VARYING_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Combined Texture Units", GLES30.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Vertex Texture Units", GLES30.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Texture Units", GLES30.GL_MAX_TEXTURE_IMAGE_UNITS, Type.INTEGER),
|
||||
new Limit("Max Fragment Uniform Vectors", GLES30.GL_MAX_FRAGMENT_UNIFORM_VECTORS, Type.INTEGER),
|
||||
new Limit("Max Cubemap Texture Size", GLES30.GL_MAX_CUBE_MAP_TEXTURE_SIZE, Type.INTEGER),
|
||||
new Limit("Shader Binary Formats", GLES30.GL_NUM_SHADER_BINARY_FORMATS, Type.INTEGER),
|
||||
new Limit("Max Framebuffer Size", GLES30.GL_MAX_RENDERBUFFER_SIZE, Type.INTEGER),
|
||||
// GLES 3.0 limits
|
||||
new Limit("Max 3D Texture size", GLES30.GL_MAX_3D_TEXTURE_SIZE, Type.INTEGER),
|
||||
new Limit("Max Element Vertices", GLES30.GL_MAX_ELEMENTS_VERTICES, Type.INTEGER),
|
||||
new Limit("Max Element Indices", GLES30.GL_MAX_ELEMENTS_INDICES, Type.INTEGER),
|
||||
new Limit("Max Draw Buffers", GLES30.GL_MAX_DRAW_BUFFERS, Type.INTEGER),
|
||||
new Limit("Max Fragment Uniform Components", GLES30.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max Vertex Uniform Components", GLES30.GL_MAX_VERTEX_UNIFORM_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Number of Extensions", GLES30.GL_NUM_EXTENSIONS, Type.INTEGER),
|
||||
new Limit("Max Array Texture Layers", GLES30.GL_MAX_ARRAY_TEXTURE_LAYERS, Type.INTEGER),
|
||||
new Limit("Min Program Texel Offset", GLES30.GL_MIN_PROGRAM_TEXEL_OFFSET, Type.INTEGER),
|
||||
new Limit("Max Program Texel Offset", GLES30.GL_MAX_PROGRAM_TEXEL_OFFSET, Type.INTEGER),
|
||||
new Limit("Max Varying Components", GLES30.GL_MAX_VARYING_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max TF Varying Length", GLES30.GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, Type.INTEGER),
|
||||
new Limit("Max TF Separate Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max TF Interleaved Components", GLES30.GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max TF Separate Attributes", GLES30.GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, Type.INTEGER),
|
||||
new Limit("Max Color Attachments", GLES30.GL_MAX_COLOR_ATTACHMENTS, Type.INTEGER),
|
||||
new Limit("Max Samples", GLES30.GL_MAX_SAMPLES, Type.INTEGER),
|
||||
new Limit("Max Vertex UBOs", GLES30.GL_MAX_VERTEX_UNIFORM_BLOCKS, Type.INTEGER),
|
||||
new Limit("Max Fragment UBOs", GLES30.GL_MAX_FRAGMENT_UNIFORM_BLOCKS, Type.INTEGER),
|
||||
new Limit("Max Combined UBOs", GLES30.GL_MAX_COMBINED_UNIFORM_BLOCKS, Type.INTEGER),
|
||||
new Limit("Max Uniform Buffer Bindings", GLES30.GL_MAX_UNIFORM_BUFFER_BINDINGS, Type.INTEGER),
|
||||
new Limit("Max UBO Size", GLES30.GL_MAX_UNIFORM_BLOCK_SIZE, Type.INTEGER),
|
||||
new Limit("Max Combined Vertex Uniform Components", GLES30.GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max Combined Fragment Uniform Components", GLES30.GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, Type.INTEGER),
|
||||
new Limit("UBO Alignment", GLES30.GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, Type.INTEGER),
|
||||
new Limit("Max Vertex Output Components", GLES30.GL_MAX_VERTEX_OUTPUT_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max Fragment Input Components", GLES30.GL_MAX_FRAGMENT_INPUT_COMPONENTS, Type.INTEGER),
|
||||
new Limit("Max Server Wait Timeout", GLES30.GL_MAX_SERVER_WAIT_TIMEOUT, Type.INTEGER),
|
||||
new Limit("Program Binary Formats", GLES30.GL_NUM_PROGRAM_BINARY_FORMATS, Type.INTEGER),
|
||||
new Limit("Max Element Index", GLES30.GL_MAX_ELEMENT_INDEX, Type.INTEGER),
|
||||
new Limit("Sample Counts", GLES30.GL_NUM_SAMPLE_COUNTS, Type.INTEGER),
|
||||
};
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);
|
||||
|
||||
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||
List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
|
||||
|
||||
for (Limit limit : Limits)
|
||||
{
|
||||
Log.i("GLES3InfoFragment", "Getting enum " + limit.name);
|
||||
Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
|
||||
}
|
||||
|
||||
// Get extensions manually
|
||||
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
|
||||
StringBuilder extensionsBuilder = new StringBuilder();
|
||||
for (int i = 0; i < numExtensions; i++)
|
||||
{
|
||||
extensionsBuilder.append(eglHelper.glGetStringi(GLES30.GL_EXTENSIONS, i)).append('\n');
|
||||
}
|
||||
Input.add(new AboutFragmentItem("OpenGL ES 3.0 Extensions", extensionsBuilder.toString()));
|
||||
|
||||
AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
|
||||
rootView.setAdapter(adapter);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLES30;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.about.Limit.Type;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
/**
|
||||
* {@link ListFragment} responsible for displaying
|
||||
* information relating to OpenGL.
|
||||
*/
|
||||
public final class GLInfoFragment extends ListFragment
|
||||
{
|
||||
private final Limit[] Limits = {
|
||||
new Limit("Vendor", GL10.GL_VENDOR, Type.STRING),
|
||||
new Limit("Version", GL10.GL_VERSION, Type.STRING),
|
||||
new Limit("Renderer", GL10.GL_RENDERER, Type.STRING),
|
||||
new Limit("GLSL version", GLES20.GL_SHADING_LANGUAGE_VERSION, Type.STRING),
|
||||
};
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);
|
||||
|
||||
ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||
List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
|
||||
|
||||
for (Limit limit : Limits)
|
||||
{
|
||||
Log.i("GLInfoFragment", "Getting enum " + limit.name);
|
||||
Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
|
||||
}
|
||||
|
||||
// Get extensions manually
|
||||
int numExtensions = eglHelper.glGetInteger(GLES30.GL_NUM_EXTENSIONS);
|
||||
StringBuilder extensionsBuilder = new StringBuilder();
|
||||
for (int i = 0; i < numExtensions; i++)
|
||||
{
|
||||
extensionsBuilder.append(eglHelper.glGetStringi(GL10.GL_EXTENSIONS, i)).append('\n');
|
||||
}
|
||||
Input.add(new AboutFragmentItem("OpenGL Extensions", extensionsBuilder.toString()));
|
||||
|
||||
AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
|
||||
rootView.setAdapter(adapter);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright 2014 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.about;
|
||||
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
|
||||
final class Limit
|
||||
{
|
||||
/**
|
||||
* Possible types a Limit can be.
|
||||
*/
|
||||
enum Type
|
||||
{
|
||||
/** Generic string */
|
||||
STRING,
|
||||
/** Integer constant */
|
||||
INTEGER,
|
||||
/** Range of integers */
|
||||
INTEGER_RANGE,
|
||||
}
|
||||
|
||||
/** Name of this limit */
|
||||
public final String name;
|
||||
/** The GL constant that represents this limit.*/
|
||||
public final int glEnum;
|
||||
/** The {@link Type} of this limit. */
|
||||
public final Type type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name Name of the limit.
|
||||
* @param glEnum The GL constant that represents this limit.
|
||||
* @param type The {@link Type} of this limit.
|
||||
*/
|
||||
public Limit(String name, int glEnum, Type type)
|
||||
{
|
||||
this.name = name;
|
||||
this.glEnum = glEnum;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the information represented by this limit.
|
||||
*
|
||||
* @param context {@link EGLHelper} context to retrieve the limit with.
|
||||
*
|
||||
* @return the information represented by this limit.
|
||||
*/
|
||||
public String GetValue(EGLHelper context)
|
||||
{
|
||||
if (type == Type.INTEGER)
|
||||
{
|
||||
return Integer.toString(context.glGetInteger(glEnum));
|
||||
}
|
||||
else if (type == Type.INTEGER_RANGE)
|
||||
{
|
||||
int[] data = new int[2];
|
||||
context.getGL().glGetIntegerv(glEnum, data, 0);
|
||||
|
||||
return String.format("[%d, %d]", data[0], data[1]);
|
||||
}
|
||||
|
||||
// If neither of the above type, assume it's a string.
|
||||
return context.glGetString(glEnum);
|
||||
}
|
||||
}
|
||||
+316
@@ -0,0 +1,316 @@
|
||||
/**
|
||||
* Copyright 2013 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.emulation;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.settings.input.InputConfigFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is the activity where all of the emulation handling happens.
|
||||
* This activity is responsible for displaying the SurfaceView that we render to.
|
||||
*/
|
||||
public final class EmulationActivity extends Activity
|
||||
{
|
||||
private boolean Running;
|
||||
private boolean IsActionBarHidden = false;
|
||||
private SharedPreferences sharedPrefs;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
// Request window features for the emulation view.
|
||||
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);
|
||||
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
|
||||
|
||||
// Set the transparency for the action bar.
|
||||
ColorDrawable actionBarBackground = new ColorDrawable(Color.parseColor("#303030"));
|
||||
actionBarBackground.setAlpha(175);
|
||||
getActionBar().setBackgroundDrawable(actionBarBackground);
|
||||
|
||||
// Get the intent passed from the GameList when the game
|
||||
// was selected. This is so the path of the game can be retrieved
|
||||
// and set on the native side of the code so the emulator can actually
|
||||
// load the game.
|
||||
Intent gameToEmulate = getIntent();
|
||||
NativeLibrary.SetFilename(gameToEmulate.getStringExtra("SelectedGame"));
|
||||
Running = true;
|
||||
|
||||
// Set the emulation window.
|
||||
setContentView(R.layout.emulation_view);
|
||||
|
||||
// If the input overlay was previously disabled, then don't show it.
|
||||
if (!sharedPrefs.getBoolean("showInputOverlay", true))
|
||||
{
|
||||
findViewById(R.id.emulationControlOverlay).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
// Hide the action bar by default so it doesn't get in the way.
|
||||
getActionBar().hide();
|
||||
IsActionBarHidden = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
|
||||
if (Running)
|
||||
NativeLibrary.StopEmulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
|
||||
if (Running)
|
||||
NativeLibrary.PauseEmulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
if (Running)
|
||||
NativeLibrary.UnPauseEmulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
if (Running)
|
||||
{
|
||||
NativeLibrary.StopEmulation();
|
||||
Running = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
// The back button in the emulation
|
||||
// window is the toggle for the action bar.
|
||||
if (IsActionBarHidden)
|
||||
{
|
||||
IsActionBarHidden = false;
|
||||
getActionBar().show();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsActionBarHidden = true;
|
||||
getActionBar().hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.emuwindow_overlay, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu)
|
||||
{
|
||||
// Determine which string the "Enable Input Overlay" menu item should have
|
||||
// depending on its visibility at the time of preparing the options menu.
|
||||
if (!sharedPrefs.getBoolean("showInputOverlay", true))
|
||||
{
|
||||
menu.findItem(R.id.enableInputOverlay).setTitle(R.string.enable_input_overlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.findItem(R.id.enableInputOverlay).setTitle(R.string.disable_input_overlay);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int itemId, MenuItem item)
|
||||
{
|
||||
switch(item.getItemId())
|
||||
{
|
||||
// Enable/Disable input overlay.
|
||||
case R.id.enableInputOverlay:
|
||||
{
|
||||
View overlay = findViewById(R.id.emulationControlOverlay);
|
||||
|
||||
// Show the overlay
|
||||
if (item.getTitle().equals(getString(R.string.enable_input_overlay)))
|
||||
{
|
||||
overlay.setVisibility(View.VISIBLE);
|
||||
item.setTitle(R.string.disable_input_overlay);
|
||||
sharedPrefs.edit().putBoolean("showInputOverlay", true).apply();
|
||||
}
|
||||
else // Hide the overlay
|
||||
{
|
||||
overlay.setVisibility(View.INVISIBLE);
|
||||
item.setTitle(R.string.enable_input_overlay);
|
||||
sharedPrefs.edit().putBoolean("showInputOverlay", false).apply();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Screenshot capturing
|
||||
case R.id.takeScreenshot:
|
||||
NativeLibrary.SaveScreenShot();
|
||||
return true;
|
||||
|
||||
// Save state slots
|
||||
case R.id.saveSlot1:
|
||||
NativeLibrary.SaveState(0);
|
||||
return true;
|
||||
|
||||
case R.id.saveSlot2:
|
||||
NativeLibrary.SaveState(1);
|
||||
return true;
|
||||
|
||||
case R.id.saveSlot3:
|
||||
NativeLibrary.SaveState(2);
|
||||
return true;
|
||||
|
||||
case R.id.saveSlot4:
|
||||
NativeLibrary.SaveState(3);
|
||||
return true;
|
||||
|
||||
case R.id.saveSlot5:
|
||||
NativeLibrary.SaveState(4);
|
||||
return true;
|
||||
|
||||
// Load state slots
|
||||
case R.id.loadSlot1:
|
||||
NativeLibrary.LoadState(0);
|
||||
return true;
|
||||
|
||||
case R.id.loadSlot2:
|
||||
NativeLibrary.LoadState(1);
|
||||
return true;
|
||||
|
||||
case R.id.loadSlot3:
|
||||
NativeLibrary.LoadState(2);
|
||||
return true;
|
||||
|
||||
case R.id.loadSlot4:
|
||||
NativeLibrary.LoadState(3);
|
||||
return true;
|
||||
|
||||
case R.id.loadSlot5:
|
||||
NativeLibrary.LoadState(4);
|
||||
return true;
|
||||
|
||||
case R.id.exitEmulation:
|
||||
{
|
||||
// Create a confirmation method for quitting the current emulation instance.
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.overlay_exit_emulation);
|
||||
builder.setMessage(R.string.overlay_exit_emulation_confirm);
|
||||
builder.setNegativeButton(R.string.no, null);
|
||||
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
onDestroy();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return super.onMenuItemSelected(itemId, item);
|
||||
}
|
||||
}
|
||||
|
||||
// Gets button presses
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event)
|
||||
{
|
||||
int action = 0;
|
||||
|
||||
if (Running)
|
||||
{
|
||||
switch (event.getAction())
|
||||
{
|
||||
case KeyEvent.ACTION_DOWN:
|
||||
// Handling the case where the back button is pressed.
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
|
||||
{
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normal key events.
|
||||
action = NativeLibrary.ButtonState.PRESSED;
|
||||
break;
|
||||
case KeyEvent.ACTION_UP:
|
||||
action = NativeLibrary.ButtonState.RELEASED;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
InputDevice input = event.getDevice();
|
||||
boolean handled = NativeLibrary.onGamePadEvent(InputConfigFragment.getInputDesc(input), event.getKeyCode(), action);
|
||||
return handled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent event)
|
||||
{
|
||||
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running)
|
||||
{
|
||||
return super.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
// Don't attempt to do anything if we are disconnecting a device.
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_CANCEL)
|
||||
return true;
|
||||
|
||||
InputDevice input = event.getDevice();
|
||||
List<InputDevice.MotionRange> motions = input.getMotionRanges();
|
||||
|
||||
for (InputDevice.MotionRange range : motions)
|
||||
{
|
||||
NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2013 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.emulation;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
/**
|
||||
* The {@link SurfaceView} that rendering is performed on.
|
||||
*/
|
||||
public final class NativeGLSurfaceView extends SurfaceView
|
||||
{
|
||||
private static Thread myRun;
|
||||
private static boolean Running = false;
|
||||
private static boolean Created = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param attribs An AttributeSet for retrieving data from XML files.
|
||||
*/
|
||||
public NativeGLSurfaceView(Context context, AttributeSet attribs)
|
||||
{
|
||||
super(context, attribs);
|
||||
|
||||
if (!Created)
|
||||
{
|
||||
myRun = new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
NativeLibrary.Run(getHolder().getSurface());
|
||||
Created = false;
|
||||
Running = false;
|
||||
}
|
||||
};
|
||||
|
||||
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 holder, int format, int width, int height)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void surfaceDestroyed(SurfaceHolder holder)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
});
|
||||
|
||||
Created = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
/**
|
||||
* Copyright 2013 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.emulation.overlay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonState;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonType;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Draws the interactive input overlay on top of the
|
||||
* {@link NativeGLSurfaceView} that is rendering emulation.
|
||||
*/
|
||||
public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||
{
|
||||
private final Set<InputOverlayDrawableButton> overlayButtons = new HashSet<InputOverlayDrawableButton>();
|
||||
private final Set<InputOverlayDrawableJoystick> overlayJoysticks = new HashSet<InputOverlayDrawableJoystick>();
|
||||
|
||||
/**
|
||||
* Resizes a {@link Bitmap} by a given scale factor
|
||||
*
|
||||
* @param context The current {@link Context}
|
||||
* @param bitmap The {@link Bitmap} to scale.
|
||||
* @param scale The scale factor for the bitmap.
|
||||
*
|
||||
* @return The scaled {@link Bitmap}
|
||||
*/
|
||||
public static Bitmap resizeBitmap(Context context, Bitmap bitmap, float scale)
|
||||
{
|
||||
// Retrieve screen dimensions.
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
|
||||
Bitmap bitmapResized = Bitmap.createScaledBitmap(bitmap,
|
||||
(int)(dm.heightPixels * scale),
|
||||
(int)(dm.heightPixels * scale),
|
||||
true);
|
||||
return bitmapResized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param attrs {@link AttributeSet} for parsing XML attributes.
|
||||
*/
|
||||
public InputOverlay(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
|
||||
// Add all the overlay items to the HashSet.
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_a, ButtonType.BUTTON_A));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_b, ButtonType.BUTTON_B));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_x, ButtonType.BUTTON_X));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_y, ButtonType.BUTTON_Y));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_z, ButtonType.BUTTON_Z));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_start, ButtonType.BUTTON_START));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_l, ButtonType.TRIGGER_L));
|
||||
overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_r, ButtonType.TRIGGER_R));
|
||||
overlayJoysticks.add(initializeOverlayJoystick(context,
|
||||
R.drawable.gcpad_joystick_range, R.drawable.gcpad_joystick,
|
||||
ButtonType.STICK_MAIN));
|
||||
|
||||
// Set the on touch listener.
|
||||
setOnTouchListener(this);
|
||||
|
||||
// Force draw
|
||||
setWillNotDraw(false);
|
||||
|
||||
// Request focus for the overlay so it has priority on presses.
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas)
|
||||
{
|
||||
super.draw(canvas);
|
||||
|
||||
for (InputOverlayDrawableButton button : overlayButtons)
|
||||
{
|
||||
button.draw(canvas);
|
||||
}
|
||||
|
||||
for (InputOverlayDrawableJoystick joystick: overlayJoysticks)
|
||||
{
|
||||
joystick.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
int pointerIndex = event.getActionIndex();
|
||||
|
||||
for (InputOverlayDrawableButton button : overlayButtons)
|
||||
{
|
||||
// Determine the button state to apply based on the MotionEvent action flag.
|
||||
switch(event.getAction() & MotionEvent.ACTION_MASK)
|
||||
{
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// If a pointer enters the bounds of a button, press that button.
|
||||
if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex)))
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.PRESSED);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
// If a pointer ends, release the button it was pressing.
|
||||
if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex)))
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (InputOverlayDrawableJoystick joystick : overlayJoysticks)
|
||||
{
|
||||
joystick.TrackEvent(event);
|
||||
int[] axisIDs = joystick.getAxisIDs();
|
||||
float[] axises = joystick.getAxisValues();
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice, axisIDs[i], axises[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an InputOverlayDrawableButton, given by resId, with all of the
|
||||
* parameters set for it to be properly shown on the InputOverlay.
|
||||
* <p>
|
||||
* This works due to the way the X and Y coordinates are stored within
|
||||
* the {@link SharedPreferences}.
|
||||
* <p>
|
||||
* In the input overlay configuration menu,
|
||||
* once a touch event begins and then ends (ie. Organizing the buttons to one's own liking for the overlay).
|
||||
* the X and Y coordinates of the button at the END of its touch event
|
||||
* (when you remove your finger/stylus from the touchscreen) are then stored
|
||||
* within a SharedPreferences instance so that those values can be retrieved here.
|
||||
* <p>
|
||||
* This has a few benefits over the conventional way of storing the values
|
||||
* (ie. within the Dolphin ini file).
|
||||
* <ul>
|
||||
* <li>No native calls</li>
|
||||
* <li>Keeps Android-only values inside the Android environment</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Technically no modifications should need to be performed on the returned
|
||||
* InputOverlayDrawableButton. Simply add it to the HashSet of overlay items and wait
|
||||
* for Android to call the onDraw method.
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param resId The resource ID of the {@link Drawable} to get the {@link Bitmap} of.
|
||||
* @param buttonId Identifier for determining what type of button the initialized InputOverlayDrawableButton represents.
|
||||
*
|
||||
* @return An {@link InputOverlayDrawableButton} with the correct drawing bounds set.
|
||||
*
|
||||
*/
|
||||
private static InputOverlayDrawableButton initializeOverlayButton(Context context, int resId, int buttonId)
|
||||
{
|
||||
// Resources handle for fetching the initial Drawable resource.
|
||||
final Resources res = context.getResources();
|
||||
|
||||
// SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableButton.
|
||||
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
// Decide scale based on button ID
|
||||
float scale;
|
||||
float overlaySize = sPrefs.getInt("controls_size", 25);
|
||||
overlaySize += 25;
|
||||
overlaySize /= 50;
|
||||
|
||||
switch (resId)
|
||||
{
|
||||
case R.drawable.gcpad_b:
|
||||
scale = 0.13f * overlaySize;
|
||||
break;
|
||||
case R.drawable.gcpad_x:
|
||||
case R.drawable.gcpad_y:
|
||||
scale = 0.18f * overlaySize;
|
||||
break;
|
||||
case R.drawable.gcpad_start:
|
||||
scale = 0.12f * overlaySize;
|
||||
break;
|
||||
default:
|
||||
scale = 0.20f * overlaySize;
|
||||
break;
|
||||
}
|
||||
|
||||
// Initialize the InputOverlayDrawableButton.
|
||||
final Bitmap bitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, resId), scale);
|
||||
final InputOverlayDrawableButton overlayDrawable = new InputOverlayDrawableButton(res, bitmap, buttonId);
|
||||
|
||||
// String ID of the Drawable. This is what is passed into SharedPreferences
|
||||
// to check whether or not a value has been set.
|
||||
final String drawableId = res.getResourceEntryName(resId);
|
||||
|
||||
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
|
||||
// These were set in the input overlay configuration menu.
|
||||
int drawableX = (int) sPrefs.getFloat(drawableId+"-X", 0f);
|
||||
int drawableY = (int) sPrefs.getFloat(drawableId+"-Y", 0f);
|
||||
|
||||
// Intrinsic width and height of the InputOverlayDrawableButton.
|
||||
// For any who may not know, intrinsic width/height
|
||||
// are the original unmodified width and height of the image.
|
||||
int intrinWidth = overlayDrawable.getIntrinsicWidth();
|
||||
int intrinHeight = overlayDrawable.getIntrinsicHeight();
|
||||
|
||||
// Now set the bounds for the InputOverlayDrawableButton.
|
||||
// This will dictate where on the screen (and the what the size) the InputOverlayDrawableButton will be.
|
||||
overlayDrawable.setBounds(drawableX, drawableY, drawableX+intrinWidth, drawableY+intrinHeight);
|
||||
|
||||
return overlayDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an {@link InputOverlayDrawableJoystick}
|
||||
*
|
||||
* @param context The current {@link Context}
|
||||
* @param resOuter Resource ID for the outer image of the joystick (the static image that shows the circular bounds).
|
||||
* @param resInner Resource ID for the inner image of the joystick (the one you actually move around).
|
||||
* @param joystick Identifier for which joystick this is.
|
||||
*
|
||||
* @return the initialized {@link InputOverlayDrawableJoystick}.
|
||||
*/
|
||||
private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context, int resOuter, int resInner, int joystick)
|
||||
{
|
||||
// Resources handle for fetching the initial Drawable resource.
|
||||
final Resources res = context.getResources();
|
||||
|
||||
// SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableJoystick.
|
||||
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
// Initialize the InputOverlayDrawableJoystick.
|
||||
float overlaySize = sPrefs.getInt("controls_size", 20);
|
||||
overlaySize += 30;
|
||||
overlaySize /= 50;
|
||||
final Bitmap bitmapOuter = resizeBitmap(context, BitmapFactory.decodeResource(res, resOuter), 0.30f * overlaySize);
|
||||
final Bitmap bitmapInner = BitmapFactory.decodeResource(res, resInner);
|
||||
|
||||
// String ID of the Drawable. This is what is passed into SharedPreferences
|
||||
// to check whether or not a value has been set.
|
||||
final String drawableId = res.getResourceEntryName(resOuter);
|
||||
|
||||
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
|
||||
// These were set in the input overlay configuration menu.
|
||||
int drawableX = (int) sPrefs.getFloat(drawableId+"-X", 0f);
|
||||
int drawableY = (int) sPrefs.getFloat(drawableId+"-Y", 0f);
|
||||
|
||||
// Now set the bounds for the InputOverlayDrawableJoystick.
|
||||
// This will dictate where on the screen (and the what the size) the InputOverlayDrawableJoystick will be.
|
||||
int outerSize = bitmapOuter.getWidth();
|
||||
Rect outerRect = new Rect(drawableX, drawableY, drawableX + outerSize, drawableY + outerSize);
|
||||
Rect innerRect = new Rect(0, 0, outerSize / 4, outerSize / 4);
|
||||
|
||||
final InputOverlayDrawableJoystick overlayDrawable
|
||||
= new InputOverlayDrawableJoystick(res,
|
||||
bitmapOuter, bitmapInner,
|
||||
outerRect, innerRect,
|
||||
joystick);
|
||||
|
||||
|
||||
return overlayDrawable;
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2013 Dolphin Emulator Project
|
||||
* Licensed under GPLv2
|
||||
* Refer to the license.txt file included.
|
||||
*/
|
||||
|
||||
package org.dolphinemu.dolphinemu.emulation.overlay;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
/**
|
||||
* Custom {@link BitmapDrawable} that is capable
|
||||
* of storing it's own ID.
|
||||
*/
|
||||
public final class InputOverlayDrawableButton extends BitmapDrawable
|
||||
{
|
||||
// The ID identifying what type of button this Drawable represents.
|
||||
private int buttonType;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param res {@link Resources} instance.
|
||||
* @param bitmap {@link Bitmap} to use with this Drawable.
|
||||
* @param buttonType Identifier for this type of button.
|
||||
*/
|
||||
public InputOverlayDrawableButton(Resources res, Bitmap bitmap, int buttonType)
|
||||
{
|
||||
super(res, bitmap);
|
||||
|
||||
this.buttonType = buttonType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this InputOverlayDrawableButton's button ID.
|
||||
*
|
||||
* @return this InputOverlayDrawableButton's button ID.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return buttonType;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user