| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| [GCPad1] | ||
| Device = Android/0/Touchscreen | ||
| Buttons/A = Button 0 | ||
| Buttons/B = Button 1 | ||
| Buttons/X = C | ||
| Buttons/Y = S | ||
| Buttons/Z = D | ||
| Buttons/Start = Button 2 | ||
| Main Stick/Up = Up | ||
| Main Stick/Down = Down | ||
| Main Stick/Left = Left | ||
| Main Stick/Right = Right | ||
| Main Stick/Modifier = Shift_L | ||
| Main Stick/Modifier/Range = 50.000000 | ||
| C-Stick/Up = I | ||
| C-Stick/Down = K | ||
| C-Stick/Left = J | ||
| C-Stick/Right = L | ||
| C-Stick/Modifier = Control_L | ||
| C-Stick/Modifier/Range = 50.000000 | ||
| Triggers/L = Q | ||
| Triggers/R = W | ||
| D-Pad/Up = T | ||
| D-Pad/Down = G | ||
| D-Pad/Left = F | ||
| D-Pad/Right = H | ||
| [GCPad2] | ||
| [GCPad3] | ||
| [GCPad4] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project name="Dolphin Emulator" default="help"> | ||
|
|
||
| <!-- The local.properties file is created and updated by the 'android' tool. | ||
| It contains the path to the SDK. It should *NOT* be checked into | ||
| Version Control Systems. --> | ||
| <property file="local.properties" /> | ||
|
|
||
| <!-- The ant.properties file can be created by you. It is only edited by the | ||
| 'android' tool to add properties to it. | ||
| This is the place to change some Ant specific build properties. | ||
| Here are some properties you may want to change/update: | ||
| source.dir | ||
| The name of the source directory. Default is 'src'. | ||
| out.dir | ||
| The name of the output directory. Default is 'bin'. | ||
| For other overridable properties, look at the beginning of the rules | ||
| files in the SDK, at tools/ant/build.xml | ||
| Properties related to the SDK location or the project target should | ||
| be updated using the 'android' tool with the 'update' action. | ||
| This file is an integral part of the build system for your | ||
| application and should be checked into Version Control Systems. | ||
| --> | ||
| <property file="ant.properties" /> | ||
|
|
||
| <!-- if sdk.dir was not set from one of the property file, then | ||
| get it from the ANDROID_HOME env var. | ||
| This must be done before we load project.properties since | ||
| the proguard config can use sdk.dir --> | ||
| <property environment="env" /> | ||
| <condition property="sdk.dir" value="${env.ANDROID_HOME}"> | ||
| <isset property="env.ANDROID_HOME" /> | ||
| </condition> | ||
|
|
||
| <!-- The project.properties file is created and updated by the 'android' | ||
| tool, as well as ADT. | ||
| This contains project specific properties such as project target, and library | ||
| dependencies. Lower level build properties are stored in ant.properties | ||
| (or in .classpath for Eclipse projects). | ||
| This file is an integral part of the build system for your | ||
| application and should be checked into Version Control Systems. --> | ||
| <loadproperties srcFile="project.properties" /> | ||
|
|
||
| <!-- quick check on sdk.dir --> | ||
| <fail | ||
| message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." | ||
| unless="sdk.dir" | ||
| /> | ||
|
|
||
| <!-- | ||
| Import per project custom build rules if present at the root of the project. | ||
| This is the place to put custom intermediary targets such as: | ||
| -pre-build | ||
| -pre-compile | ||
| -post-compile (This is typically used for code obfuscation. | ||
| Compiled code location: ${out.classes.absolute.dir} | ||
| If this is not done in place, override ${out.dex.input.absolute.dir}) | ||
| -post-package | ||
| -post-build | ||
| -pre-clean | ||
| --> | ||
| <import file="custom_rules.xml" optional="true" /> | ||
|
|
||
| <!-- Import the actual build file. | ||
| To customize existing targets, there are two options: | ||
| - Customize only one target: | ||
| - copy/paste the target into this file, *before* the | ||
| <import> task. | ||
| - customize it to your needs. | ||
| - Customize the whole content of build.xml | ||
| - copy/paste the content of the rules files (minus the top node) | ||
| into this file, replacing the <import> task. | ||
| - customize to your needs. | ||
| *********************** | ||
| ****** IMPORTANT ****** | ||
| *********************** | ||
| In all cases you must update the value of version-tag below to read 'custom' instead of an integer, | ||
| in order to avoid having your file be overridden by tools such as "android update project" | ||
| --> | ||
| <!-- version-tag: 1 --> | ||
| <import file="${sdk.dir}/tools/ant/build.xml" /> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project name="Dolphin" default="help"> | ||
| <property name="ndkbuildopt" value=""/> | ||
| <target name="-pre-build"> | ||
| <exec executable="${ndk.dir}/ndk-build" failonerror="true"> | ||
| <arg line="-j4 ${ndkbuildopt}"/> | ||
| <env key="NDK_MODULE_PATH" path="..:../native/ext"/> | ||
| </exec> | ||
| </target> | ||
| <target name="clean" depends="android_rules.clean"> | ||
| <exec executable="${ndk.dir}/ndk-build" failonerror="true"> | ||
| <arg value="clean"/> | ||
| <env key="NDK_MODULE_PATH" path="..:../native/ext"/> | ||
| </exec> | ||
| </target> | ||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| LOCAL_PATH := $(call my-dir) | ||
|
|
||
| # BEGIN Native Audio Separate Library - copy paste this section to your Android.mk | ||
|
|
||
| include $(CLEAR_VARS) | ||
|
|
||
| LOCAL_MODULE := native_audio | ||
| LOCAL_CFLAGS := -O2 -fsigned-char -ffast-math -Wall -Wno-multichar -Wno-psabi -std=gnu++0x | ||
| NATIVE := ../../native | ||
| LOCAL_SRC_FILES := \ | ||
| $(NATIVE)/android/native-audio-so.cpp | ||
| LOCAL_LDLIBS := -lOpenSLES -llog | ||
|
|
||
| include $(BUILD_SHARED_LIBRARY) | ||
|
|
||
| # END Native Audio Separate Library - copy paste this section to your Android.mk | ||
|
|
||
| include $(CLEAR_VARS) | ||
|
|
||
| #TARGET_PLATFORM := android-8 | ||
|
|
||
| LOCAL_MODULE := ppsspp_jni | ||
|
|
||
| NATIVE := ../../native | ||
| SRC := ../.. | ||
|
|
||
| LOCAL_CFLAGS := -DUSE_PROFILER -DARM -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O2 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math | ||
| LOCAL_CXXFLAGS := -std=gnu++0x | ||
| LOCAL_C_INCLUDES := \ | ||
| $(LOCAL_PATH)/../../Common \ | ||
| $(LOCAL_PATH)/../.. \ | ||
| $(LOCAL_PATH)/$(NATIVE)/base \ | ||
| $(LOCAL_PATH)/$(NATIVE)/ext/libzip \ | ||
| $(LOCAL_PATH)/$(NATIVE) \ | ||
| $(LOCAL_PATH) \ | ||
|
|
||
| LOCAL_STATIC_LIBRARIES := native libzip | ||
| LOCAL_LDLIBS := -lz -lGLESv2 -ldl -llog | ||
|
|
||
|
|
||
| # $(SRC)/Core/EmuThread.cpp \ | ||
| LOCAL_SRC_FILES := \ | ||
| NativeApp.cpp \ | ||
| EmuScreen.cpp \ | ||
| MenuScreens.cpp \ | ||
| UIShader.cpp \ | ||
| GamepadEmu.cpp \ | ||
| ArmEmitterTest.cpp \ | ||
| ui_atlas.cpp \ | ||
| $(SRC)/native/android/app-android.cpp \ | ||
| $(SRC)/ext/disarm.cpp \ | ||
| $(SRC)/ext/libkirk/AES.c \ | ||
| $(SRC)/ext/libkirk/SHA1.c \ | ||
| $(SRC)/ext/libkirk/bn.c \ | ||
| $(SRC)/ext/libkirk/ec.c \ | ||
| $(SRC)/ext/libkirk/kirk_engine.c \ | ||
| $(SRC)/ext/snappy/snappy-c.cpp \ | ||
| $(SRC)/ext/snappy/snappy.cpp \ | ||
| $(SRC)/Common/ArmEmitter.cpp \ | ||
| $(SRC)/Common/ArmCPUDetect.cpp \ | ||
| $(SRC)/Common/ArmThunk.cpp \ | ||
| $(SRC)/Common/LogManager.cpp \ | ||
| $(SRC)/Common/MemArena.cpp \ | ||
| $(SRC)/Common/MemoryUtil.cpp \ | ||
| $(SRC)/Common/MsgHandler.cpp \ | ||
| $(SRC)/Common/IniFile.cpp \ | ||
| $(SRC)/Common/FileUtil.cpp \ | ||
| $(SRC)/Common/StringUtil.cpp \ | ||
| $(SRC)/Common/Thread.cpp \ | ||
| $(SRC)/Common/Timer.cpp \ | ||
| $(SRC)/Common/Misc.cpp \ | ||
| $(SRC)/Common/MathUtil.cpp \ | ||
| $(SRC)/GPU/Math3D.cpp \ | ||
| $(SRC)/GPU/GPUCommon.cpp \ | ||
| $(SRC)/GPU/GPUState.cpp \ | ||
| $(SRC)/GPU/GeDisasm.cpp \ | ||
| $(SRC)/GPU/GLES/Framebuffer.cpp \ | ||
| $(SRC)/GPU/GLES/DisplayListInterpreter.cpp \ | ||
| $(SRC)/GPU/GLES/TextureCache.cpp \ | ||
| $(SRC)/GPU/GLES/IndexGenerator.cpp \ | ||
| $(SRC)/GPU/GLES/TransformPipeline.cpp \ | ||
| $(SRC)/GPU/GLES/StateMapping.cpp \ | ||
| $(SRC)/GPU/GLES/VertexDecoder.cpp \ | ||
| $(SRC)/GPU/GLES/ShaderManager.cpp \ | ||
| $(SRC)/GPU/GLES/VertexShaderGenerator.cpp \ | ||
| $(SRC)/GPU/GLES/FragmentShaderGenerator.cpp \ | ||
| $(SRC)/GPU/Null/NullGpu.cpp \ | ||
| $(SRC)/Core/ELF/ElfReader.cpp \ | ||
| $(SRC)/Core/ELF/PrxDecrypter.cpp \ | ||
| $(SRC)/Core/ELF/ParamSFO.cpp \ | ||
| $(SRC)/Core/HW/MemoryStick.cpp \ | ||
| $(SRC)/Core/HW/MediaEngine.cpp \ | ||
| $(SRC)/Core/HW/SasAudio.cpp \ | ||
| $(SRC)/Core/Core.cpp \ | ||
| $(SRC)/Core/Config.cpp \ | ||
| $(SRC)/Core/CoreTiming.cpp \ | ||
| $(SRC)/Core/CPU.cpp \ | ||
| $(SRC)/Core/Host.cpp \ | ||
| $(SRC)/Core/Loaders.cpp \ | ||
| $(SRC)/Core/PSPLoaders.cpp \ | ||
| $(SRC)/Core/MemMap.cpp \ | ||
| $(SRC)/Core/MemMapFunctions.cpp \ | ||
| $(SRC)/Core/SaveState.cpp \ | ||
| $(SRC)/Core/System.cpp \ | ||
| $(SRC)/Core/PSPMixer.cpp \ | ||
| $(SRC)/Core/Debugger/Breakpoints.cpp \ | ||
| $(SRC)/Core/Debugger/SymbolMap.cpp \ | ||
| $(SRC)/Core/Dialog/PSPDialog.cpp \ | ||
| $(SRC)/Core/Dialog/PSPMsgDialog.cpp \ | ||
| $(SRC)/Core/Dialog/PSPOskDialog.cpp \ | ||
| $(SRC)/Core/Dialog/PSPPlaceholderDialog.cpp \ | ||
| $(SRC)/Core/Dialog/PSPSaveDialog.cpp \ | ||
| $(SRC)/Core/Dialog/SavedataParam.cpp \ | ||
| $(SRC)/Core/HLE/HLETables.cpp \ | ||
| $(SRC)/Core/HLE/HLE.cpp \ | ||
| $(SRC)/Core/HLE/sceAtrac.cpp \ | ||
| $(SRC)/Core/HLE/__sceAudio.cpp \ | ||
| $(SRC)/Core/HLE/sceAudio.cpp \ | ||
| $(SRC)/Core/HLE/sceCtrl.cpp \ | ||
| $(SRC)/Core/HLE/sceDisplay.cpp \ | ||
| $(SRC)/Core/HLE/sceDmac.cpp \ | ||
| $(SRC)/Core/HLE/sceGe.cpp \ | ||
| $(SRC)/Core/HLE/sceFont.cpp \ | ||
| $(SRC)/Core/HLE/sceHprm.cpp \ | ||
| $(SRC)/Core/HLE/sceHttp.cpp \ | ||
| $(SRC)/Core/HLE/sceImpose.cpp \ | ||
| $(SRC)/Core/HLE/sceIo.cpp \ | ||
| $(SRC)/Core/HLE/sceKernel.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelAlarm.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelEventFlag.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelInterrupt.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelMemory.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelModule.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelMutex.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelMbx.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelMsgPipe.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelSemaphore.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelThread.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelTime.cpp \ | ||
| $(SRC)/Core/HLE/sceKernelVTimer.cpp \ | ||
| $(SRC)/Core/HLE/sceMpeg.cpp \ | ||
| $(SRC)/Core/HLE/sceNet.cpp \ | ||
| $(SRC)/Core/HLE/sceOpenPSID.cpp \ | ||
| $(SRC)/Core/HLE/sceParseHttp.cpp \ | ||
| $(SRC)/Core/HLE/sceParseUri.cpp \ | ||
| $(SRC)/Core/HLE/scePower.cpp \ | ||
| $(SRC)/Core/HLE/sceRtc.cpp \ | ||
| $(SRC)/Core/HLE/scePsmf.cpp \ | ||
| $(SRC)/Core/HLE/sceSas.cpp \ | ||
| $(SRC)/Core/HLE/sceSsl.cpp \ | ||
| $(SRC)/Core/HLE/sceUmd.cpp \ | ||
| $(SRC)/Core/HLE/sceUsb.cpp \ | ||
| $(SRC)/Core/HLE/sceUtility.cpp \ | ||
| $(SRC)/Core/HLE/sceVaudio.cpp \ | ||
| $(SRC)/Core/FileSystems/BlockDevices.cpp \ | ||
| $(SRC)/Core/FileSystems/ISOFileSystem.cpp \ | ||
| $(SRC)/Core/FileSystems/MetaFileSystem.cpp \ | ||
| $(SRC)/Core/FileSystems/DirectoryFileSystem.cpp \ | ||
| $(SRC)/Core/MIPS/MIPS.cpp.arm \ | ||
| $(SRC)/Core/MIPS/MIPSAnalyst.cpp \ | ||
| $(SRC)/Core/MIPS/MIPSDis.cpp \ | ||
| $(SRC)/Core/MIPS/MIPSDisVFPU.cpp \ | ||
| $(SRC)/Core/MIPS/MIPSInt.cpp.arm \ | ||
| $(SRC)/Core/MIPS/MIPSIntVFPU.cpp.arm \ | ||
| $(SRC)/Core/MIPS/MIPSTables.cpp.arm \ | ||
| $(SRC)/Core/MIPS/MIPSVFPUUtils.cpp \ | ||
| $(SRC)/Core/MIPS/MIPSCodeUtils.cpp \ | ||
| $(SRC)/Core/MIPS/MIPSDebugInterface.cpp \ | ||
| $(SRC)/Core/MIPS/JitCommon/JitCommon.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmJitCache.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmCompALU.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmCompBranch.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmCompFPU.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmCompLoadStore.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmCompVFPU.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmAsm.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmJit.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmRegCache.cpp \ | ||
| $(SRC)/Core/MIPS/ARM/ArmRegCacheFPU.cpp \ | ||
| $(SRC)/Core/Util/BlockAllocator.cpp \ | ||
| $(SRC)/Core/Util/ppge_atlas.cpp \ | ||
| $(SRC)/Core/Util/PPGeDraw.cpp | ||
|
|
||
|
|
||
| include $(BUILD_SHARED_LIBRARY) | ||
|
|
||
| $(call import-module,libzip) | ||
| $(call import-module,native) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| APP_STL := stlport_static | ||
| APP_ABI := armeabi-v7a armeabi | ||
|
|
||
| #APP_ABI := armeabi-v7a |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # This file is automatically generated by Android Tools. | ||
| # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
| # | ||
| # This file must be checked in Version Control Systems. | ||
| # | ||
| # To customize properties used by the Ant build system edit | ||
| # "ant.properties", and override values to adapt the script to your | ||
| # project structure. | ||
| # | ||
| # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
| #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
|
||
| # Project target. | ||
| target=android-17 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:layout_width="fill_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" > | ||
|
|
||
| <TextView | ||
| android:id="@+id/TextView01" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginLeft="5dip" | ||
| android:layout_marginTop="5dip" | ||
| android:singleLine="true" | ||
| android:text="@+id/TextView01" | ||
| android:textStyle="bold" > | ||
| </TextView> | ||
|
|
||
| <TextView | ||
| android:id="@+id/TextView02" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginLeft="10dip" | ||
| android:text="@+id/TextView02" > | ||
| </TextView> | ||
|
|
||
| </LinearLayout> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
|
|
||
| <string name="app_name">Dolphin Emulator</string> | ||
|
|
||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| package org.dolphinemu.dolphinemu; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.Intent; | ||
| import android.os.Bundle; | ||
| import android.os.Environment; | ||
| import android.util.DisplayMetrics; | ||
| import android.util.Log; | ||
| import android.view.MotionEvent; | ||
| import android.view.WindowManager; | ||
|
|
||
| public class DolphinEmulator<MainActivity> extends Activity | ||
| { | ||
| static private NativeGLSurfaceView GLview = null; | ||
| static private boolean Running = false; | ||
|
|
||
| private float screenWidth; | ||
| private float screenHeight; | ||
|
|
||
| public static native void onTouchEvent(int Action, float X, float Y); | ||
|
|
||
| static | ||
| { | ||
| try | ||
| { | ||
| System.loadLibrary("dolphin-emu-nogui"); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Log.w("me", ex.toString()); | ||
| } | ||
| } | ||
| private void CopyAsset(String asset, String output) { | ||
| InputStream in = null; | ||
| OutputStream out = null; | ||
| try { | ||
| in = getAssets().open(asset); | ||
| out = new FileOutputStream(output); | ||
| copyFile(in, out); | ||
| in.close(); | ||
| in = null; | ||
| out.flush(); | ||
| out.close(); | ||
| out = null; | ||
| } catch(IOException e) { | ||
| Log.e("tag", "Failed to copy asset file: " + asset, e); | ||
| } | ||
| } | ||
| private void copyFile(InputStream in, OutputStream out) throws IOException { | ||
| byte[] buffer = new byte[1024]; | ||
| int read; | ||
| while((read = in.read(buffer)) != -1){ | ||
| out.write(buffer, 0, read); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onStop() | ||
| { | ||
| super.onStop(); | ||
| if (Running) | ||
| NativeGLSurfaceView.StopEmulation(); | ||
| } | ||
| @Override | ||
| public void onPause() | ||
| { | ||
| super.onPause(); | ||
| if (Running) | ||
| NativeGLSurfaceView.PauseEmulation(); | ||
| } | ||
| @Override | ||
| public void onResume() | ||
| { | ||
| super.onResume(); | ||
| if (Running) | ||
| NativeGLSurfaceView.UnPauseEmulation(); | ||
| } | ||
|
|
||
| /** Called when the activity is first created. */ | ||
| @Override | ||
| public void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| if (savedInstanceState == null) | ||
| { | ||
| Intent ListIntent = new Intent(this, NativeListView.class); | ||
| startActivityForResult(ListIntent, 1); | ||
|
|
||
| // Make the assets directory | ||
| File directory = new File( | ||
| Environment.getExternalStorageDirectory()+File.separator+"dolphin-emu"+File.separator+"Config"); | ||
| directory.mkdirs(); | ||
|
|
||
| // Copy assets if needed | ||
| java.io.File file = new java.io.File( | ||
| Environment.getExternalStorageDirectory()+File.separator+"dolphin-emu" + File.separator + "ButtonStart.png"); | ||
| if(!file.exists()) | ||
| { | ||
| CopyAsset("ButtonA.png", | ||
| Environment.getExternalStorageDirectory()+File.separator+ | ||
| "dolphin-emu" + File.separator + "ButtonA.png"); | ||
| CopyAsset("ButtonB.png", | ||
| Environment.getExternalStorageDirectory()+File.separator+ | ||
| "dolphin-emu" + File.separator + "ButtonB.png"); | ||
| CopyAsset("ButtonStart.png", | ||
| Environment.getExternalStorageDirectory()+File.separator+ | ||
| "dolphin-emu" + File.separator + "ButtonStart.png"); | ||
| CopyAsset("GCPadNew.ini", | ||
| Environment.getExternalStorageDirectory()+File.separator+ | ||
| "dolphin-emu" + File.separator +"Config"+ File.separator +"GCPadNew.ini"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onActivityResult(int requestCode, int resultCode, Intent data) | ||
| { | ||
| super.onActivityResult(requestCode, resultCode, data); | ||
|
|
||
| if (resultCode == Activity.RESULT_OK) | ||
| { | ||
| DisplayMetrics displayMetrics = new DisplayMetrics(); | ||
| WindowManager wm = (WindowManager) getApplicationContext().getSystemService(getApplicationContext().WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut | ||
| wm.getDefaultDisplay().getMetrics(displayMetrics); | ||
| screenWidth = displayMetrics.widthPixels; | ||
| screenHeight = displayMetrics.heightPixels; | ||
|
|
||
| String FileName = data.getStringExtra("Select"); | ||
| GLview = new NativeGLSurfaceView(this); | ||
| //this.getWindow().setUiOptions(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN, View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN); | ||
| GLview.SetDimensions(screenWidth, screenHeight); | ||
| GLview.SetFileName(FileName); | ||
| setContentView(GLview); | ||
| Running = true; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onTouchEvent(MotionEvent event) | ||
| { | ||
| float X, Y; | ||
| int Action; | ||
| X = event.getX(); | ||
| Y = event.getY(); | ||
| Action = event.getActionMasked(); | ||
|
|
||
| // Converts button locations 0 - 1 to OGL screen coords -1.0 - 1.0 | ||
| float ScreenX = ((X / screenWidth) * 2.0f) - 1.0f; | ||
| float ScreenY = ((Y / screenHeight) * -2.0f) + 1.0f; | ||
|
|
||
| onTouchEvent(Action, ScreenX, ScreenY); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| public boolean overrideKeys() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package org.dolphinemu.dolphinemu; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import android.content.Context; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.ArrayAdapter; | ||
| import android.widget.TextView; | ||
|
|
||
| public class FileArrayAdapter extends ArrayAdapter<Option>{ | ||
|
|
||
| private Context c; | ||
| private int id; | ||
| private List<Option>items; | ||
|
|
||
| public FileArrayAdapter(Context context, int textViewResourceId, | ||
| List<Option> objects) { | ||
| super(context, textViewResourceId, objects); | ||
| c = context; | ||
| id = textViewResourceId; | ||
| items = objects; | ||
| } | ||
| public Option getItem(int i) | ||
| { | ||
| return items.get(i); | ||
| } | ||
| @Override | ||
| public View getView(int position, View convertView, ViewGroup parent) { | ||
| View v = convertView; | ||
| if (v == null) { | ||
| LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
| v = vi.inflate(id, null); | ||
| } | ||
| final Option o = items.get(position); | ||
| if (o != null) { | ||
| TextView t1 = (TextView) v.findViewById(R.id.TextView01); | ||
| TextView t2 = (TextView) v.findViewById(R.id.TextView02); | ||
|
|
||
| if(t1!=null) | ||
| t1.setText(o.getName()); | ||
| if(t2!=null) | ||
| t2.setText(o.getData()); | ||
|
|
||
| } | ||
| return v; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package org.dolphinemu.dolphinemu; | ||
|
|
||
| import android.content.Context; | ||
| import android.opengl.GLSurfaceView; | ||
| import android.util.Log; | ||
| import android.view.Surface; | ||
| import android.view.SurfaceHolder; | ||
| import android.view.SurfaceView; | ||
|
|
||
| public class NativeGLSurfaceView extends SurfaceView { | ||
| static private String FileName; | ||
| static private Thread myRun; | ||
| static private boolean Running = false; | ||
| static private boolean Created = false; | ||
| static private float width; | ||
| static private float height; | ||
|
|
||
| public static native void main(String File, Surface surf, int width, int height); | ||
| public static native void UnPauseEmulation(); | ||
| public static native void PauseEmulation(); | ||
| public static native void StopEmulation(); | ||
|
|
||
| static | ||
| { | ||
| try | ||
| { | ||
| System.loadLibrary("dolphin-emu-nogui"); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Log.w("me", ex.toString()); | ||
| } | ||
| } | ||
|
|
||
| public NativeGLSurfaceView(Context context) { | ||
| super(context); | ||
| if (!Created) | ||
| { | ||
| myRun = new Thread() | ||
| { | ||
| @Override | ||
| public void run() { | ||
| main(FileName, getHolder().getSurface(), (int)width, (int)height); | ||
| } | ||
| }; | ||
| getHolder().addCallback(new SurfaceHolder.Callback() { | ||
| public void surfaceCreated(SurfaceHolder holder) { | ||
| // TODO Auto-generated method stub | ||
| if (!Running) | ||
| { | ||
| myRun.start(); | ||
| Running = true; | ||
| } | ||
| } | ||
|
|
||
| public void surfaceChanged(SurfaceHolder arg0, int arg1, | ||
| int arg2, int arg3) { | ||
| // TODO Auto-generated method stub | ||
|
|
||
| } | ||
|
|
||
| public void surfaceDestroyed(SurfaceHolder arg0) { | ||
| // TODO Auto-generated method stub | ||
|
|
||
| } | ||
| }); | ||
| Created = true; | ||
| } | ||
| } | ||
|
|
||
| public void SetFileName(String file) | ||
| { | ||
| FileName = file; | ||
| } | ||
|
|
||
| public void SetDimensions(float screenWidth, float screenHeight) | ||
| { | ||
| width = screenWidth; | ||
| height = screenHeight; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package org.dolphinemu.dolphinemu; | ||
|
|
||
| import java.io.File; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import android.app.Activity; | ||
| import android.app.ListActivity; | ||
| import android.content.Intent; | ||
| import android.os.Bundle; | ||
| import android.os.Environment; | ||
| import android.view.View; | ||
| import android.widget.ListView; | ||
| import android.widget.Toast; | ||
|
|
||
| public class NativeListView extends ListActivity { | ||
| private FileArrayAdapter adapter; | ||
| static private File currentDir = null; | ||
|
|
||
| private void Fill(File f) | ||
| { | ||
| File[]dirs = f.listFiles(); | ||
| this.setTitle("Current Dir: " + f.getName()); | ||
| List<Option>dir = new ArrayList<Option>(); | ||
| List<Option>fls = new ArrayList<Option>(); | ||
|
|
||
| try | ||
| { | ||
| for(File ff: dirs) | ||
| { | ||
| if (ff.getName().charAt(0) != '.') | ||
| if(ff.isDirectory()) | ||
| dir.add(new Option(ff.getName(),"Folder",ff.getAbsolutePath())); | ||
| else | ||
| if (ff.getName().toLowerCase().indexOf(".gcm") >= 0 || | ||
| ff.getName().toLowerCase().indexOf(".iso") >= 0 || | ||
| ff.getName().toLowerCase().indexOf(".wbfs") >= 0 || | ||
| ff.getName().toLowerCase().indexOf(".gcz") >= 0 || | ||
| ff.getName().toLowerCase().indexOf(".dol") >= 0 || | ||
| ff.getName().toLowerCase().indexOf(".elf") >= 0) | ||
| fls.add(new Option(ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath())); | ||
| } | ||
| } | ||
| catch(Exception e) | ||
| { | ||
| } | ||
|
|
||
| Collections.sort(dir); | ||
| Collections.sort(fls); | ||
| dir.addAll(fls); | ||
|
|
||
| if(!f.getName().equalsIgnoreCase("sdcard")) | ||
| dir.add(0,new Option("..","Parent Directory",f.getParent())); | ||
| adapter = new FileArrayAdapter(this,R.layout.main,dir); | ||
| this.setListAdapter(adapter); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onListItemClick(ListView l, View v, int position, long id) { | ||
| // TODO Auto-generated method stub | ||
| super.onListItemClick(l, v, position, id); | ||
| Option o = adapter.getItem(position); | ||
| if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){ | ||
| currentDir = new File(o.getPath()); | ||
| Fill(currentDir); | ||
| } | ||
| else | ||
| { | ||
| onFileClick(o.getPath()); | ||
| } | ||
| } | ||
|
|
||
| private void onFileClick(String o) | ||
| { | ||
| Toast.makeText(this, "File Clicked: " + o, Toast.LENGTH_SHORT).show(); | ||
|
|
||
| Intent intent = new Intent(); | ||
| intent.putExtra("Select", o); | ||
| setResult(Activity.RESULT_OK, intent); | ||
|
|
||
| this.finish(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onCreate(Bundle savedInstanceState) | ||
| { | ||
| super.onCreate(savedInstanceState); | ||
|
|
||
| if(currentDir == null) | ||
| currentDir = new File(Environment.getExternalStorageDirectory().getPath()); | ||
| Fill(currentDir); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.dolphinemu.dolphinemu; | ||
|
|
||
| public class Option implements Comparable<Option>{ | ||
| private String name; | ||
| private String data; | ||
| private String path; | ||
|
|
||
| public Option(String n,String d,String p) | ||
| { | ||
| name = n; | ||
| data = d; | ||
| path = p; | ||
| } | ||
|
|
||
| public String getName() | ||
| { | ||
| return name; | ||
| } | ||
|
|
||
| public String getData() | ||
| { | ||
| return data; | ||
| } | ||
|
|
||
| public String getPath() | ||
| { | ||
| return path; | ||
| } | ||
|
|
||
| public int compareTo(Option o) | ||
| { | ||
| if(this.name != null) | ||
| return this.name.toLowerCase().compareTo(o.getName().toLowerCase()); | ||
| else | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include "GLInterface.h" | ||
| #include <png.h> | ||
|
|
||
| GLuint LoadPNG(const char *filename) | ||
| { | ||
| FILE *infile; /* PNG file pointer */ | ||
| png_structp png_ptr; /* internally used by libpng */ | ||
| png_infop info_ptr; /* user requested transforms */ | ||
|
|
||
| char *image_data; /* raw png image data */ | ||
| char sig[8]; /* PNG signature array */ | ||
| /*char **row_pointers; */ | ||
|
|
||
| int bit_depth; | ||
| int color_type; | ||
|
|
||
| png_uint_32 width; /* PNG image width in pixels */ | ||
| png_uint_32 height; /* PNG image height in pixels */ | ||
| unsigned int rowbytes; /* raw bytes at row n in image */ | ||
|
|
||
| image_data = NULL; | ||
| unsigned int i; | ||
| png_bytepp row_pointers = NULL; | ||
|
|
||
| /* Open the file. */ | ||
| infile = fopen(filename, "rb"); | ||
| if (!infile) | ||
| return 0; | ||
|
|
||
| /* | ||
| * 13.3 readpng_init() | ||
| */ | ||
|
|
||
| /* Check for the 8-byte signature */ | ||
| fread(sig, 1, 8, infile); | ||
|
|
||
| if (!png_check_sig((unsigned char *) sig, 8)) { | ||
| fclose(infile); | ||
| return 0; | ||
| } | ||
|
|
||
| /* | ||
| * Set up the PNG structs | ||
| */ | ||
| png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); | ||
| if (!png_ptr) { | ||
| fclose(infile); | ||
| return 4; /* out of memory */ | ||
| } | ||
|
|
||
| info_ptr = png_create_info_struct(png_ptr); | ||
| if (!info_ptr) { | ||
| png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL); | ||
| fclose(infile); | ||
| return 4; /* out of memory */ | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * block to handle libpng errors, | ||
| * then check whether the PNG file had a bKGD chunk | ||
| */ | ||
| if (setjmp(png_jmpbuf(png_ptr))) { | ||
| png_destroy_read_struct(&png_ptr, &info_ptr, NULL); | ||
| fclose(infile); | ||
| return 0; | ||
| } | ||
|
|
||
| /* | ||
| * takes our file stream pointer (infile) and | ||
| * stores it in the png_ptr struct for later use. | ||
| */ | ||
| /* png_ptr->io_ptr = (png_voidp)infile;*/ | ||
| png_init_io(png_ptr, infile); | ||
|
|
||
| /* | ||
| * lets libpng know that we already checked the 8 | ||
| * signature bytes, so it should not expect to find | ||
| * them at the current file pointer location | ||
| */ | ||
| png_set_sig_bytes(png_ptr, 8); | ||
|
|
||
| /* Read the image */ | ||
|
|
||
| /* | ||
| * reads and processes not only the PNG file's IHDR chunk | ||
| * but also any other chunks up to the first IDAT | ||
| * (i.e., everything before the image data). | ||
| */ | ||
|
|
||
| /* read all the info up to the image data */ | ||
| png_read_info(png_ptr, info_ptr); | ||
|
|
||
| png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, | ||
| &color_type, NULL, NULL, NULL); | ||
|
|
||
| /* Set up some transforms. */ | ||
| if (bit_depth > 8) | ||
| png_set_strip_16(png_ptr); | ||
|
|
||
| if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | ||
| png_set_gray_to_rgb(png_ptr); | ||
|
|
||
| if (color_type == PNG_COLOR_TYPE_PALETTE) | ||
| png_set_palette_to_rgb(png_ptr); | ||
|
|
||
| /* Update the png info struct.*/ | ||
| png_read_update_info(png_ptr, info_ptr); | ||
|
|
||
| /* Rowsize in bytes. */ | ||
| rowbytes = png_get_rowbytes(png_ptr, info_ptr); | ||
|
|
||
|
|
||
| /* Allocate the image_data buffer. */ | ||
| if ((image_data = (char *) malloc(rowbytes * height))==NULL) { | ||
| png_destroy_read_struct(&png_ptr, &info_ptr, NULL); | ||
| return 4; | ||
| } | ||
|
|
||
| if ((row_pointers = (png_bytepp)malloc(height*sizeof(png_bytep))) == NULL) { | ||
| png_destroy_read_struct(&png_ptr, &info_ptr, NULL); | ||
| free(image_data); | ||
| image_data = NULL; | ||
| return 4; | ||
| } | ||
|
|
||
|
|
||
| /* set the individual row_pointers to point at the correct offsets */ | ||
|
|
||
| for (i = 0; i < height; ++i) | ||
| row_pointers[i] = (png_byte*)(image_data + i*rowbytes); | ||
|
|
||
|
|
||
| /* now we can go ahead and just read the whole image */ | ||
| png_read_image(png_ptr, row_pointers); | ||
|
|
||
| /* and we're done! (png_read_end() can be omitted if no processing of | ||
| * post-IDAT text/time/etc. is desired) */ | ||
|
|
||
| /* Clean up. */ | ||
| free(row_pointers); | ||
|
|
||
| /* Clean up. */ | ||
| png_destroy_read_struct(&png_ptr, &info_ptr, NULL); | ||
| fclose(infile); | ||
|
|
||
| GLuint Texture = 0; | ||
| glGenTextures(1, &Texture); | ||
|
|
||
| /* create a new texture object | ||
| * and bind it to texname (unsigned integer > 0) | ||
| */ | ||
| glBindTexture(GL_TEXTURE_2D, Texture); | ||
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | ||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); | ||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | ||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | ||
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, | ||
| GL_RGBA, GL_UNSIGNED_BYTE, image_data); | ||
| return Texture; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include "GLInterface.h" | ||
|
|
||
| GLuint LoadPNG(const char *filename); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| // Copyright (C) 2013 Scott Moreau <oreaus@gmail.com> | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include "Host.h" | ||
| #include "Platform.h" | ||
|
|
||
| bool cPlatform::SelectDisplay(void) | ||
| { | ||
| enum egl_platform selected_platform = EGL_PLATFORM_NONE; | ||
| enum egl_platform desired_platform = EGL_PLATFORM_NONE; | ||
| char *platform_env = getenv("DOLPHIN_EGL_PLATFORM"); | ||
|
|
||
| if (platform_env) | ||
| platform_env = strdup(platform_env); | ||
|
|
||
| if (!platform_env) | ||
| printf("Running automatic platform detection\n"); | ||
|
|
||
| // Try to select the platform set in the environment variable first | ||
| #if HAVE_WAYLAND | ||
| bool wayland_possible = WaylandInterface.ServerConnect(); | ||
|
|
||
| if (platform_env && !strcmp(platform_env, "wayland")) | ||
| { | ||
| desired_platform = EGL_PLATFORM_WAYLAND; | ||
| if (wayland_possible) | ||
| selected_platform = EGL_PLATFORM_WAYLAND; | ||
| else | ||
| printf("Wayland display server connection failed\n"); | ||
| } | ||
| #endif | ||
|
|
||
| #if HAVE_X11 | ||
| bool x11_possible = XInterface.ServerConnect(); | ||
|
|
||
| if (platform_env && !strcmp(platform_env, "x11")) | ||
| { | ||
| desired_platform = EGL_PLATFORM_X11; | ||
| if ((selected_platform != EGL_PLATFORM_WAYLAND) && x11_possible) | ||
| selected_platform = EGL_PLATFORM_X11; | ||
| else | ||
| printf("X11 display server connection failed\n"); | ||
| } | ||
| #endif | ||
| // Fall back to automatic detection | ||
| if (selected_platform == EGL_PLATFORM_NONE) | ||
| { | ||
| if (platform_env && (desired_platform == EGL_PLATFORM_NONE)) { | ||
| printf("DOLPHIN_EGL_PLATFORM set to unrecognized platform \"%s\".\n" | ||
| #if HAVE_WAYLAND && !HAVE_X11 | ||
| "Note: Valid value is \"wayland\" (built without x11 support)\n", | ||
| #endif | ||
| #if HAVE_X11 && !HAVE_WAYLAND | ||
| "Note: Valid values is \"x11\" (built without wayland support)\n", | ||
| #endif | ||
| #if HAVE_WAYLAND && HAVE_X11 | ||
| "Note: Valid values are \"wayland\" and \"x11\"\n", | ||
| #endif | ||
| #if !HAVE_WAYLAND && !HAVE_X11 | ||
| "Note: No Valid platform. Must be Android\n", | ||
| #endif | ||
| platform_env); | ||
| free(platform_env); | ||
| platform_env = NULL; | ||
| } | ||
| #if HAVE_WAYLAND | ||
| if (wayland_possible) | ||
| { | ||
| selected_platform = EGL_PLATFORM_WAYLAND; | ||
| platform_env = strdup("wayland"); | ||
| } | ||
| #endif | ||
| #if HAVE_X11 | ||
| if ((selected_platform != EGL_PLATFORM_WAYLAND) && x11_possible) | ||
| { | ||
| selected_platform = EGL_PLATFORM_X11; | ||
| platform_env = strdup("x11"); | ||
| } | ||
| #endif | ||
| #ifdef ANDROID | ||
| selected_platform = EGL_PLATFORM_ANDROID; | ||
| #endif | ||
| if (selected_platform == EGL_PLATFORM_NONE) | ||
| { | ||
| printf("FATAL: Failed to find suitable platform for display connection\n"); | ||
| goto out; | ||
| } | ||
| } | ||
|
|
||
| printf("Using EGL Native Display Platform: %s\n", platform_env); | ||
| out: | ||
| cPlatform::platform = selected_platform; | ||
| free(platform_env); | ||
| #if HAVE_WAYLAND | ||
| if (selected_platform != EGL_PLATFORM_WAYLAND) { | ||
| if (GLWin.wl_display) | ||
| wl_display_disconnect(GLWin.wl_display); | ||
| } | ||
|
|
||
| #endif | ||
| #if HAVE_X11 | ||
| if (selected_platform != EGL_PLATFORM_X11) { | ||
| if (GLWin.dpy) | ||
| XCloseDisplay(GLWin.dpy); | ||
| } | ||
| #endif | ||
| if (selected_platform == EGL_PLATFORM_NONE) | ||
| return false; | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool cPlatform::Init(EGLConfig config) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| if (!WaylandInterface.Initialize(config)) | ||
| return false; | ||
| #endif | ||
| #if HAVE_X11 | ||
| if (cPlatform::platform == EGL_PLATFORM_X11) | ||
| if (!XInterface.Initialize(config)) | ||
| return false; | ||
| #endif | ||
| #ifdef ANDROID | ||
| EGLint format; | ||
| eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format); | ||
| ANativeWindow_setBuffersGeometry((EGLNativeWindowType)Host_GetRenderHandle(), 0, 0, format); | ||
| int none, width, height; | ||
| Host_GetRenderWindowSize(none, none, width, height); | ||
| GLWin.width = width; | ||
| GLWin.height = height; | ||
| GLInterface->SetBackBufferDimensions(width, height); | ||
| #endif | ||
| return true; | ||
| } | ||
|
|
||
| EGLDisplay cPlatform::EGLGetDisplay(void) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| return (EGLDisplay) WaylandInterface.EGLGetDisplay(); | ||
| #endif | ||
| #if HAVE_X11 | ||
| if (cPlatform::platform == EGL_PLATFORM_X11) | ||
| return (EGLDisplay) XInterface.EGLGetDisplay(); | ||
| #endif | ||
| #ifdef ANDROID | ||
| return eglGetDisplay(EGL_DEFAULT_DISPLAY); | ||
| #endif | ||
| return NULL; | ||
| } | ||
|
|
||
| EGLNativeWindowType cPlatform::CreateWindow(void) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| return (EGLNativeWindowType) WaylandInterface.CreateWindow(); | ||
| #endif | ||
| #if HAVE_X11 | ||
| if (cPlatform::platform == EGL_PLATFORM_X11) | ||
| return (EGLNativeWindowType) XInterface.CreateWindow(); | ||
| #endif | ||
| #ifdef ANDROID | ||
| return (EGLNativeWindowType)Host_GetRenderHandle(); | ||
| #endif | ||
| return 0; | ||
| } | ||
|
|
||
| void cPlatform::DestroyWindow(void) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| WaylandInterface.DestroyWindow(); | ||
| #endif | ||
| #if HAVE_X11 | ||
| if (cPlatform::platform == EGL_PLATFORM_X11) | ||
| XInterface.DestroyWindow(); | ||
| #endif | ||
| } | ||
|
|
||
| void cPlatform::UpdateFPSDisplay(const char *text) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| WaylandInterface.UpdateFPSDisplay(text); | ||
| #endif | ||
| #if HAVE_X11 | ||
| if (cPlatform::platform == EGL_PLATFORM_X11) | ||
| XInterface.UpdateFPSDisplay(text); | ||
| #endif | ||
| } | ||
|
|
||
| void | ||
| cPlatform::ToggleFullscreen(bool fullscreen) | ||
| { | ||
| #if HAVE_WAYLAND | ||
| if (cPlatform::platform == EGL_PLATFORM_WAYLAND) | ||
| WaylandInterface.ToggleFullscreen(fullscreen); | ||
| #endif | ||
| #if HAVE_X11 | ||
| // Only wayland uses this function | ||
| #endif | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| // Copyright (C) 2013 Scott Moreau <oreaus@gmail.com> | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
| #ifndef _EGLPLATFORM_H_ | ||
| #define _EGLPLATFORM_H_ | ||
|
|
||
| #include "Thread.h" | ||
| #include "ConfigManager.h" | ||
|
|
||
| #if USE_EGL | ||
| // We must include wayland-egl.h before egl.h so our | ||
| // native types are defined as wayland native types | ||
| #if HAVE_WAYLAND && !HAVE_X11 | ||
| #include <wayland-egl.h> | ||
| #endif | ||
| #include <EGL/egl.h> | ||
| #endif | ||
|
|
||
| #if HAVE_X11 | ||
| #include "X11_Util.h" | ||
| #endif | ||
| #if HAVE_WAYLAND | ||
| #include "Wayland_Util.h" | ||
| #endif | ||
|
|
||
| #if USE_EGL | ||
| // There may be multiple EGL platforms | ||
| enum egl_platform { | ||
| EGL_PLATFORM_NONE, | ||
| EGL_PLATFORM_WAYLAND, | ||
| EGL_PLATFORM_X11, | ||
| EGL_PLATFORM_ANDROID | ||
| }; | ||
|
|
||
| class cPlatform | ||
| { | ||
| private: | ||
| #if HAVE_X11 | ||
| cXInterface XInterface; | ||
| #endif | ||
| #if HAVE_WAYLAND | ||
| cWaylandInterface WaylandInterface; | ||
| #endif | ||
| public: | ||
| enum egl_platform platform; | ||
| bool SelectDisplay(void); | ||
| bool Init(EGLConfig config); | ||
| EGLDisplay EGLGetDisplay(void); | ||
| EGLNativeWindowType CreateWindow(void); | ||
| void DestroyWindow(void); | ||
| void UpdateFPSDisplay(const char *text); | ||
| void ToggleFullscreen(bool fullscreen); | ||
| }; | ||
|
|
||
| #include "GLInterface/EGL.h" | ||
|
|
||
| #if HAVE_WAYLAND | ||
| #include <wayland-egl.h> | ||
| #endif | ||
| #elif defined(__APPLE__) | ||
| #include "GLInterface/AGL.h" | ||
| #elif defined(_WIN32) | ||
| #include "GLInterface/WGL.h" | ||
| #elif HAVE_X11 | ||
| #include "GLInterface/GLX.h" | ||
| #endif | ||
|
|
||
| #if HAVE_WAYLAND | ||
| struct geometry { | ||
| int width; | ||
| int height; | ||
| }; | ||
|
|
||
| struct xkb { | ||
| struct xkb_context *context; | ||
| struct xkb_keymap *keymap; | ||
| struct xkb_state *state; | ||
| xkb_mod_mask_t control_mask; | ||
| xkb_mod_mask_t alt_mask; | ||
| xkb_mod_mask_t shift_mask; | ||
| }; | ||
| #endif | ||
|
|
||
| typedef struct { | ||
| // Currently Wayland/EGL and X11/EGL platforms are supported. | ||
| // The platform may be spelected at run time by setting the | ||
| // environment variable DOLPHIN_EGL_PLATFORM to "wayland" or "x11". | ||
| #if USE_EGL | ||
| EGLSurface egl_surf; | ||
| EGLContext egl_ctx; | ||
| EGLDisplay egl_dpy; | ||
| enum egl_platform platform; | ||
| #endif | ||
| EGLNativeWindowType native_window; | ||
| #if HAVE_WAYLAND | ||
| struct wl_display *wl_display; | ||
| struct wl_registry *wl_registry; | ||
| struct wl_compositor *wl_compositor; | ||
| struct wl_shell *wl_shell; | ||
| struct wl_seat *wl_seat; | ||
| struct { | ||
| struct wl_pointer *wl_pointer; | ||
| uint32_t serial; | ||
| } pointer; | ||
| struct { | ||
| struct wl_keyboard *wl_keyboard; | ||
| struct xkb xkb; | ||
| uint32_t modifiers; | ||
| } keyboard; | ||
| struct wl_shm *wl_shm; | ||
| struct wl_cursor_theme *wl_cursor_theme; | ||
| struct wl_cursor *wl_cursor; | ||
| struct wl_surface *wl_cursor_surface; | ||
| struct geometry geometry, window_size; | ||
| struct wl_egl_window *wl_egl_native; | ||
| struct wl_surface *wl_surface; | ||
| struct wl_shell_surface *wl_shell_surface; | ||
| struct wl_callback *wl_callback; | ||
| bool fullscreen, configured, frame_drawn, swap_complete, running; | ||
| #endif | ||
| #if HAVE_X11 | ||
| int screen; | ||
| // dpy used for egl/glx stuff, evdpy for window events etc. | ||
| // evdpy is to be used by XEventThread only | ||
| Display *dpy; | ||
| Display *evdpy; | ||
| #if !USE_EGL | ||
| GLXContext ctx; | ||
| #endif | ||
| Window win; | ||
| Window parent; | ||
| XVisualInfo *vi; | ||
| XSetWindowAttributes attr; | ||
| std::thread xEventThread; | ||
| int x, y; | ||
| unsigned int width, height; | ||
| #elif defined(ANDROID) | ||
| unsigned int width, height; | ||
| #elif defined(__APPLE__) | ||
| NSWindow *cocoaWin; | ||
| NSOpenGLContext *cocoaCtx; | ||
| #endif | ||
| } GLWindow; | ||
|
|
||
| extern cInterfaceBase *GLInterface; | ||
| extern GLWindow GLWin; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright (C) 2013 Scott Moreau <oreaus@gmail.com> | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
| #ifndef _WAYLAND_UTIL_H_ | ||
| #define _WAYLAND_UTIL_H_ | ||
|
|
||
| #include <wayland-client.h> | ||
| #include <wayland-egl.h> | ||
| #include <wayland-cursor.h> | ||
| #include <xkbcommon/xkbcommon.h> | ||
|
|
||
| #define MOD_SHIFT_MASK 0x01 | ||
| #define MOD_ALT_MASK 0x02 | ||
| #define MOD_CONTROL_MASK 0x04 | ||
|
|
||
|
|
||
| class cWaylandInterface | ||
| { | ||
| public: | ||
| bool ServerConnect(void); | ||
| bool Initialize(void *config); | ||
| void *EGLGetDisplay(void); | ||
| void *CreateWindow(void); | ||
| void DestroyWindow(void); | ||
| void UpdateFPSDisplay(const char *text); | ||
| void ToggleFullscreen(bool fullscreen); | ||
| }; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include <vector> | ||
| #include "GLInterface.h" | ||
| #include "Android/TextureLoader.h" | ||
| #include "Android/ButtonManager.h" | ||
|
|
||
| extern void DrawButton(GLuint tex, float *coords); | ||
|
|
||
| namespace ButtonManager | ||
| { | ||
| std::vector<Button*> m_buttons; | ||
|
|
||
| // XXX: This needs to not be here so we can load the locations from file | ||
| // This will allow customizable button locations in the future | ||
| // These are the OpenGL on screen coordinates | ||
| float m_coords[][8] = { // X, Y, X, EY, EX, EY, EX, Y | ||
| {0.75f, -1.0f, 0.75f, -0.75f, 1.0f, -0.75f, 1.0f, -1.0f}, // A | ||
| {0.50f, -1.0f, 0.50f, -0.75f, 0.75f, -0.75f, 0.75f, -1.0f}, // B | ||
| {-0.10f, -1.0f, -0.10f, -0.80f, 0.10f, -0.80f, 0.10f, -1.0f}, // Start | ||
| }; | ||
|
|
||
| void Init() | ||
| { | ||
| glEnable(GL_BLEND); | ||
| glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
|
|
||
| // Initialize our buttons | ||
| m_buttons.push_back(new Button("ButtonA.png", BUTTON_A, m_coords[0])); | ||
| m_buttons.push_back(new Button("ButtonB.png", BUTTON_B, m_coords[1])); | ||
| m_buttons.push_back(new Button("ButtonStart.png", BUTTON_START, m_coords[2])); | ||
| } | ||
| bool GetButtonPressed(ButtonType button) | ||
| { | ||
| for (auto it = m_buttons.begin(); it != m_buttons.end(); ++it) | ||
| if ((*it)->GetButtonType() == button) | ||
| return (*it)->Pressed(); | ||
| return false; | ||
| } | ||
| void TouchEvent(int action, float x, float y) | ||
| { | ||
| // Actions | ||
| // 0 is press | ||
| // 1 is let go | ||
| // 2 is move | ||
| for (auto it = m_buttons.begin(); it != m_buttons.end(); ++it) | ||
| { | ||
| float *coords = (*it)->GetCoords(); | ||
| if ( x >= coords[0] && | ||
| x <= coords[4] && | ||
| y >= coords[1] && | ||
| y <= coords[3]) | ||
| { | ||
| if (action == 0) | ||
| (*it)->SetState(BUTTON_PRESSED); | ||
| if (action == 1) | ||
| (*it)->SetState(BUTTON_RELEASED); | ||
| if (action == 2) | ||
| ; // XXX: Be used later for analog stick | ||
| } | ||
| } | ||
| } | ||
| void Shutdown() | ||
| { | ||
| for(auto it = m_buttons.begin(); it != m_buttons.end(); ++it) | ||
| delete *it; | ||
| } | ||
|
|
||
| void DrawButtons() | ||
| { | ||
| for(auto it = m_buttons.begin(); it != m_buttons.end(); ++it) | ||
| DrawButton((*it)->GetTexture(), (*it)->GetCoords()); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include <string> | ||
| #include "CommonPaths.h" | ||
| #include "Android/TextureLoader.h" | ||
|
|
||
| namespace ButtonManager | ||
| { | ||
| enum ButtonType | ||
| { | ||
| BUTTON_A = 0, | ||
| BUTTON_B, | ||
| BUTTON_START, | ||
| }; | ||
| enum ButtonState | ||
| { | ||
| BUTTON_RELEASED = 0, | ||
| BUTTON_PRESSED = 1 | ||
| }; | ||
| class Button | ||
| { | ||
| private: | ||
| GLuint m_tex; | ||
| ButtonType m_button; | ||
| ButtonState m_state; | ||
| float m_coords[8]; | ||
| public: | ||
| Button(std::string filename, ButtonType button, float *coords) | ||
| { | ||
| m_tex = LoadPNG((std::string(DOLPHIN_DATA_DIR "/") + filename).c_str()); | ||
| m_button = button; | ||
| memcpy(m_coords, coords, sizeof(float) * 8); | ||
| m_state = BUTTON_RELEASED; | ||
| } | ||
| void SetState(ButtonState state) { m_state = state; } | ||
| bool Pressed() { return m_state == BUTTON_PRESSED; } | ||
| ButtonType GetButtonType() { return m_button; } | ||
| GLuint GetTexture() { return m_tex; } | ||
| float *GetCoords() { return m_coords; } | ||
|
|
||
| ~Button() { glDeleteTextures(1, &m_tex); } | ||
| }; | ||
| void Init(); | ||
| void DrawButtons(); | ||
| bool GetButtonPressed(ButtonType button); | ||
| void TouchEvent(int action, float x, float y); | ||
| void Shutdown(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
|
|
||
| #include "Android.h" | ||
|
|
||
| namespace ciface | ||
| { | ||
|
|
||
| namespace Android | ||
| { | ||
|
|
||
| void Init( std::vector<ControllerInterface::Device*>& devices ) | ||
| { | ||
| devices.push_back(new Touchscreen()); | ||
| } | ||
|
|
||
| // Touchscreens and stuff | ||
| std::string Touchscreen::GetName() const | ||
| { | ||
| return "Touchscreen"; | ||
| } | ||
|
|
||
| std::string Touchscreen::GetSource() const | ||
| { | ||
| return "Android"; | ||
| } | ||
|
|
||
| int Touchscreen::GetId() const | ||
| { | ||
| return 0; | ||
| } | ||
| Touchscreen::Touchscreen() | ||
| { | ||
| AddInput(new Button(ButtonManager::BUTTON_A)); | ||
| AddInput(new Button(ButtonManager::BUTTON_B)); | ||
| AddInput(new Button(ButtonManager::BUTTON_START)); | ||
| } | ||
| // Buttons and stuff | ||
|
|
||
| std::string Touchscreen::Button::GetName() const | ||
| { | ||
| std::ostringstream ss; | ||
| ss << "Button " << (int)m_index; | ||
| return ss.str(); | ||
| } | ||
|
|
||
| ControlState Touchscreen::Button::GetState() const | ||
| { | ||
| return ButtonManager::GetButtonPressed(m_index); | ||
| } | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright (C) 2003 Dolphin Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official SVN repository and contact information can be found at | ||
| // http://code.google.com/p/dolphin-emu/ | ||
| #ifndef _CIFACE_ANDROID_H_ | ||
| #define _CIFACE_ANDROID_H_ | ||
|
|
||
| #include "../ControllerInterface.h" | ||
| #include "Android/ButtonManager.h" | ||
|
|
||
| namespace ciface | ||
| { | ||
| namespace Android | ||
| { | ||
|
|
||
| void Init( std::vector<ControllerInterface::Device*>& devices ); | ||
| class Touchscreen : public ControllerInterface::Device | ||
| { | ||
| private: | ||
| class Button : public Input | ||
| { | ||
| public: | ||
| std::string GetName() const; | ||
| Button(ButtonManager::ButtonType index) : m_index(index) {} | ||
| ControlState GetState() const; | ||
| private: | ||
| const ButtonManager::ButtonType m_index; | ||
| }; | ||
|
|
||
| public: | ||
| bool UpdateInput() { return true; } | ||
| bool UpdateOutput() { return true; } | ||
|
|
||
| Touchscreen(); | ||
| ~Touchscreen() {} | ||
|
|
||
| std::string GetName() const; | ||
| int GetId() const; | ||
| std::string GetSource() const; | ||
| }; | ||
|
|
||
| } | ||
| } | ||
|
|
||
| #endif |