Merge branch 'Android-trash' since it is no longer quite so trashy.

This commit is contained in:
Ryan Houdek 2013-04-14 23:36:00 -05:00
commit 7772f0d071
52 changed files with 4187 additions and 148 deletions

View File

@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 2.6)
option(ANDROID "Enables a build for Android" OFF)
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
option(USE_X11 "Enables X11 Support" ON)
option(USE_WAYLAND "Enables Wayland Support" OFF)
option(USE_GLES "Enables GLES And EGL, disables OGL" OFF)
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
@ -265,16 +267,28 @@ if(USE_GLES)
add_definitions(-DUSE_EGL=1)
set(USE_EGL True)
endif()
# For now Wayland and EGL are tied to each other.
# The alternative would be an shm path
if(USE_WAYLAND)
add_definitions(-DUSE_EGL)
set(USE_EGL 1)
endif()
if(USE_EGL)
message("EGL OpenGL interface enabled")
add_definitions(-DUSE_EGL=1)
else()
# Using GLX
set(USE_X11 1)
set(USE_WAYLAND 0)
endif()
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
if(ANDROID)
message("Building for Android")
add_definitions(-DANDROID)
set(USE_X11 0)
set(USE_WAYLAND 0)
endif()
########################################
# Dependency checking
@ -350,29 +364,53 @@ if(NOT ANDROID)
message("OpenAL NOT found, disabling OpenAL sound backend")
endif(OPENAL_FOUND)
if(UNIX AND NOT APPLE)
# Note: The convention is to check USE_X11 or USE_WAYLAND where needed.
# This is where we detect platforms and set the variables accordingly.
pkg_check_modules(WAYLAND wayland-egl wayland-client wayland-cursor)
if(USE_WAYLAND AND WAYLAND_FOUND)
pkg_check_modules(XKBCOMMON xkbcommon)
if(XKBCOMMON_FOUND)
set(USE_WAYLAND 1)
add_definitions(-DHAVE_WAYLAND)
include_directories(${WAYLAND_INCLUDE_DIR})
message("Wayland support enabled")
endif(XKBCOMMON_FOUND)
else()
set(USE_WAYLAND 0)
message("Wayland support disabled")
add_definitions(-DHAVE_WAYLAND=0)
endif(USE_WAYLAND AND WAYLAND_FOUND)
# Note: We do not need to explicitly check for X11 as it is done in the cmake
# FindOpenGL module on linux.
if(UNIX AND NOT APPLE)
if(X11_FOUND)
if(USE_X11 AND X11_FOUND)
set(USE_X11 1)
add_definitions(-DHAVE_X11=1)
include_directories(${X11_INCLUDE_DIR})
message("X11 found")
message("X11 support enabled")
else()
message(FATAL_ERROR "X11 is required but not found")
endif(X11_FOUND)
else()
add_definitions(-DHAVE_X11=0)
set(USE_X11 0)
SET(X11_FOUND "")
message("X11 support disabled")
add_definitions(-DHAVE_X11=0)
endif(USE_X11 AND X11_FOUND)
if (NOT USE_WAYLAND AND NOT USE_X11)
message(FATAL_ERROR "\n"
"No suitable display platform found\n"
"Requires wayland or x11 to run")
endif()
endif()
if(X11_FOUND)
if(USE_X11)
check_lib(XRANDR Xrandr)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
else()
add_definitions(-DHAVE_XRANDR=0)
endif(XRANDR_FOUND)
endif()
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
else()
add_definitions(-DHAVE_XRANDR=0)
endif(XRANDR_FOUND)
if(ENCODE_FRAMEDUMPS)
check_libav()
endif()
@ -444,6 +482,13 @@ else()
set(LZO lzo2)
endif()
if(ANDROID)
message("Using static libpng from Externals")
add_subdirectory(Externals/libpng)
include_directories(Externals/libpng)
set(PNG libpng)
endif()
if(OPENAL_FOUND)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
check_lib(SOUNDTOUCH SoundTouch soundtouch/soundtouch.h QUIET)

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

7
Source/Android/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
gen
obj
#ui_atlas.zim
ui_atlas.zim.png
#assets/ui_atlas.zim
#jni/ui_atlas.cpp
#jni/ui_atlas.h

33
Source/Android/.project Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ppsspp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.source=1.5

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.dolphinemu.dolphinemu"
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<uses-feature android:name="android.hardware.screen.landscape" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/launcher"
android:label="@string/app_name">
<activity
android:name=".DolphinEmulator"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NativeListView"
android:label="@string/app_name"
android:theme="@android:style/Theme"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
</activity>
</application>
</manifest>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -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]

92
Source/Android/build.xml Normal file
View File

@ -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>

View File

@ -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>

View File

@ -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)

View File

@ -0,0 +1,4 @@
APP_STL := stlport_static
APP_ABI := armeabi-v7a armeabi
#APP_ABI := armeabi-v7a

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -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>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Dolphin Emulator</string>
</resources>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -57,6 +57,7 @@
DIR_SEP USERDATA_DIR DIR_SEP
#elif defined ANDROID
#define SYSDATA_DIR "/sdcard/dolphin-emu"
#define SHARED_USER_DIR SYSDATA_DIR
#else
#ifdef DATA_DIR
#define SYSDATA_DIR DATA_DIR "sys"

View File

@ -153,7 +153,12 @@ u8* MemArena::Find4GBBase()
}
return base;
#else
void* base = mmap(0, 0x31000000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
#ifdef ANDROID
const u32 MemSize = 0x04000000;
#else
const u32 MemSize = 0x31000000;
#endif
void* base = mmap(0, MemSize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (base == MAP_FAILED) {
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
return 0;

View File

@ -437,8 +437,7 @@ std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input)
std::string result;
#if defined(ANDROID)
result = "Not implemented on Android!";
result = (char*)input.c_str();
#else
iconv_t const conv_desc = iconv_open("UTF-8", fromcode);
if ((iconv_t)-1 == conv_desc)

View File

@ -426,6 +426,8 @@ void SConfig::LoadSettings()
ini.Get("DSP", "Backend", &sBackend, BACKEND_COREAUDIO);
#elif defined _WIN32
ini.Get("DSP", "Backend", &sBackend, BACKEND_DIRECTSOUND);
#elif defined ANDROID
ini.Get("DSP", "Backend", &sBackend, BACKEND_OPENSLES);
#else
ini.Get("DSP", "Backend", &sBackend, BACKEND_NULLSOUND);
#endif

View File

@ -23,6 +23,7 @@
#include "../ConfigManager.h"
#include "../../InputCommon/Src/InputConfig.h"
#include "Host.h"
namespace Pad
{

View File

@ -7,10 +7,19 @@ set(LIBS core
audiocommon
z
sfml-network
${GTK2_LIBRARIES}
${XRANDR_LIBRARIES}
${X11_LIBRARIES})
${GTK2_LIBRARIES})
if(NOT ANDROID)
if(USE_X11)
set(LIBS ${LIBS} ${X11_LIBRARIES}
${XRANDR_LIBRARIES})
endif()
if(USE_WAYLAND)
set(LIBS ${LIBS} ${WAYLAND_LIBRARIES}
${XKBCOMMON_LIBRARIES})
endif()
link_directories(${CMAKE_PREFIX_PATH}/lib)
if(SDL2_FOUND)
# Using shared SDL2
set(LIBS ${LIBS} ${SDL2_LIBRARY})
@ -23,6 +32,8 @@ if(NOT ANDROID)
set(LIBS ${LIBS} SDL)
endif()
endif()
else()
set(LIBS ${LIBS} png)
endif()
if(LIBAV_FOUND)
@ -80,20 +91,25 @@ if(wxWidgets_FOUND)
set(WXLIBS ${wxWidgets_LIBRARIES})
else()
if(ANDROID)
set(SRCS Src/MainAndroid.cpp)
set(SRCS Src/Android/TextureLoader.cpp
Src/MainAndroid.cpp)
else()
set(SRCS Src/MainNoGUI.cpp)
endif()
endif()
if(USE_EGL)
if(NOT ANDROID)
set(SRCS ${SRCS} Src/GLInterface/EGL_X11.cpp
Src/GLInterface/X11_Util.cpp)
set(SRCS ${SRCS} Src/GLInterface/Platform.cpp
Src/GLInterface/EGL.cpp)
if(USE_WAYLAND)
set(SRCS ${SRCS} Src/GLInterface/Wayland_Util.cpp)
endif()
if(USE_X11)
set(SRCS ${SRCS} Src/GLInterface/X11_Util.cpp)
endif()
else()
if(WIN32)
set(SRCS ${SRCS} Src/GLInterface/GLW.cpp)
set(SRCS ${SRCS} Src/GLInterface/WGL.cpp)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
else()
@ -127,10 +143,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND SRCS ${RESOURCES})
set_source_files_properties(${RESOURCES} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
else()
if(NOT ANDROID)
set(SRCS ${SRCS} Src/X11Utils.cpp)
endif()
elseif(USE_X11)
set(SRCS ${SRCS} Src/X11Utils.cpp)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR

View File

@ -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;
}

View File

@ -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);

View File

@ -17,12 +17,18 @@
#ifndef _GLINTERFACE_H_
#define _GLINTERFACE_H_
#if USE_EGL
#include "GLInterface/Platform.h"
#else
#include "Thread.h"
#ifdef ANDROID
#include <GLES2/gl2.h>
#include <GLInterface/InterfaceBase.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include "GLInterface/EGL.h"
#elif defined(USE_EGL) && USE_EGL
#include "GLInterface/EGL_X11.h"
#include "GLInterface/EGL.h"
#elif defined(__APPLE__)
#include "GLInterface/AGL.h"
#elif defined(_WIN32)
@ -34,19 +40,11 @@
#endif
typedef struct {
#ifdef ANDROID
#elif defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
#if defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
int screen;
Display *dpy;
Display *evdpy;
Window win;
Window parent;
EGLSurface egl_surf;
EGLContext egl_ctx;
EGLDisplay egl_dpy;
XVisualInfo *vi;
XSetWindowAttributes attr;
std::thread xEventThread;
int x, y;
unsigned int width, height;
#elif defined(__APPLE__)
@ -72,3 +70,4 @@ extern cInterfaceBase *GLInterface;
extern GLWindow GLWin;
#endif
#endif

View File

@ -19,59 +19,30 @@
#include "RenderBase.h"
#include "../GLInterface.h"
#include "EGL_X11.h"
#include "EGL.h"
// Show the current FPS
void cInterfaceEGL::UpdateFPSDisplay(const char *text)
{
XStoreName(GLWin.dpy, GLWin.win, text);
Platform.UpdateFPSDisplay(text);
}
void cInterfaceEGL::SwapInterval(int Interval)
{
eglSwapInterval(GLWin.egl_dpy, Interval);
}
void cInterfaceEGL::Swap()
{
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
}
void cInterfaceEGL::SwapInterval(int Interval)
{
eglSwapInterval(GLWin.egl_dpy, Interval);
}
// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceEGL::Create(void *&window_handle)
{
int _tx, _ty, _twidth, _theight;
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);
// Control window size and picture scaling
s_backbuffer_width = _twidth;
s_backbuffer_height = _theight;
const char *s;
EGLint egl_major, egl_minor;
GLWin.dpy = XOpenDisplay(NULL);
if (!GLWin.dpy) {
ERROR_LOG(VIDEO, "Error: couldn't open display\n");
return false;
}
GLWin.egl_dpy = eglGetDisplay(GLWin.dpy);
if (!GLWin.egl_dpy) {
ERROR_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
return false;
}
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
ERROR_LOG(VIDEO, "Error: eglInitialize() failed\n");
return false;
}
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VERSION));
INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VENDOR));
INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS));
INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS));
EGLConfig config;
EGLint num_configs;
// attributes for a visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer
@ -93,70 +64,79 @@ bool cInterfaceEGL::Create(void *&window_handle)
#endif
EGL_NONE
};
GLWin.evdpy = XOpenDisplay(NULL);
GLWin.parent = (Window)window_handle;
GLWin.screen = DefaultScreen(GLWin.dpy);
if (GLWin.parent == 0)
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
XVisualInfo visTemplate;
int num_visuals;
EGLConfig config;
EGLint num_configs;
EGLint vid;
if(!Platform.SelectDisplay())
return false;
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
ERROR_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
GLWin.egl_dpy = Platform.EGLGetDisplay();
if (!GLWin.egl_dpy) {
printf("Error: eglGetDisplay() failed\n");
return false;
}
if (!eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
ERROR_LOG(VIDEO, "Error: eglGetConfigAttrib() failed\n");
GLWin.platform = Platform.platform;
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
printf("Error: eglInitialize() failed\n");
return false;
}
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!GLWin.vi) {
ERROR_LOG(VIDEO, "Error: couldn't get X visual\n");
return false;
}
GLWin.x = _tx;
GLWin.y = _ty;
GLWin.width = _twidth;
GLWin.height = _theight;
XWindow.CreateXWindow();
#ifdef USE_GLES
eglBindAPI(EGL_OPENGL_ES_API);
#else
eglBindAPI(EGL_OPENGL_API);
#endif
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
if (!GLWin.egl_ctx) {
ERROR_LOG(VIDEO, "Error: eglCreateContext failed\n");
return false;
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, (NativeWindowType)GLWin.win, NULL);
if (!GLWin.egl_surf) {
ERROR_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
if (!Platform.Init(config))
return false;
s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
printf("EGL_VENDOR = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
printf("EGL_EXTENSIONS = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
printf("EGL_CLIENT_APIS = %s\n", s);
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
if (!GLWin.egl_ctx) {
printf("Error: eglCreateContext failed\n");
exit(1);
}
GLWin.native_window = Platform.CreateWindow();
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config,
GLWin.native_window, NULL);
if (!GLWin.egl_surf) {
printf("Error: eglCreateWindowSurface failed\n");
exit(1);
}
if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) {
ERROR_LOG(VIDEO, "Error: eglMakeCurrent() failed\n");
printf("Error: eglMakeCurrent() failed\n");
return false;
}
INFO_LOG(VIDEO, "GL_VENDOR: %s\n", glGetString(GL_VENDOR));
INFO_LOG(VIDEO, "GL_RENDERER: %s\n", glGetString(GL_RENDERER));
INFO_LOG(VIDEO, "GL_VERSION: %s\n", glGetString(GL_VERSION));
INFO_LOG(VIDEO, "GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
window_handle = (void *)GLWin.win;
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
printf("GL_VERSION: %s\n", glGetString(GL_VERSION));
printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
Platform.ToggleFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
window_handle = (void *)GLWin.native_window;
return true;
}
@ -167,7 +147,7 @@ bool cInterfaceEGL::MakeCurrent()
// Close backend
void cInterfaceEGL::Shutdown()
{
XWindow.DestroyXWindow();
Platform.DestroyWindow();
if (GLWin.egl_ctx && !eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx))
NOTICE_LOG(VIDEO, "Could not release drawing context.");
if (GLWin.egl_ctx)
@ -178,4 +158,3 @@ void cInterfaceEGL::Shutdown()
GLWin.egl_ctx = NULL;
}
}

View File

@ -17,24 +17,23 @@
#ifndef _INTERFACEEGL_H_
#define _INTERFACEEGL_H_
#include <EGL/egl.h>
#ifdef USE_GLES
#if USE_GLES
#include <GLES2/gl2.h>
#include <X11/Xutil.h>
#else
#include <GL/glxew.h>
#include <GL/gl.h>
#endif
#include "X11_Util.h"
#include "InterfaceBase.h"
class cPlatform;
class cInterfaceEGL : public cInterfaceBase
{
private:
cX11Window XWindow;
cPlatform Platform;
public:
friend class cX11Window;
friend class cPlatform;
void SwapInterval(int Interval);
void Swap();
void UpdateFPSDisplay(const char *Text);

View File

@ -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
}

View File

@ -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

View File

@ -0,0 +1,472 @@
// 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 "Core.h"
#include "State.h"
#include "../GLInterface.h"
#include <linux/input.h>
#include <sys/mman.h>
static void
redraw(void *data, struct wl_callback *callback, uint32_t time);
static const struct wl_callback_listener frame_listener = {
redraw
};
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
if (GLWin.wl_callback != callback) {
printf("Got wrong callback from wayland server\n");
exit(-1);
}
GLWin.wl_callback = NULL;
if (callback)
wl_callback_destroy(callback);
if (!GLWin.configured)
return;
// Reset the frame callback
GLWin.wl_callback = wl_surface_frame(GLWin.wl_surface);
wl_callback_add_listener(GLWin.wl_callback, &frame_listener, 0);
// Present rendered buffer on screen
//eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
}
static void
hide_cursor(void)
{
if (!GLWin.pointer.wl_pointer)
return;
wl_pointer_set_cursor(GLWin.pointer.wl_pointer,
GLWin.pointer.serial, NULL, 0, 0);
}
static void
configure_callback(void *data, struct wl_callback *callback, uint32_t time)
{
wl_callback_destroy(callback);
GLWin.configured = true;
if (GLWin.wl_callback == NULL)
redraw(data, NULL, time);
}
static struct wl_callback_listener configure_callback_listener = {
configure_callback,
};
static void
handle_ping(void *data, struct wl_shell_surface *wl_shell_surface,
uint32_t serial)
{
wl_shell_surface_pong(wl_shell_surface, serial);
}
static void
handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
uint32_t edges, int32_t width, int32_t height)
{
if (GLWin.wl_egl_native)
wl_egl_window_resize(GLWin.wl_egl_native, width, height, 0, 0);
GLWin.geometry.width = width;
GLWin.geometry.height = height;
GLInterface->SetBackBufferDimensions(width, height);
if (!GLWin.fullscreen)
GLWin.window_size = GLWin.geometry;
}
static void
handle_popup_done(void *data, struct wl_shell_surface *wl_shell_surface)
{
}
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
handle_popup_done
};
static void
pointer_handle_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t sx, wl_fixed_t sy)
{
GLWin.pointer.serial = serial;
if (GLWin.fullscreen)
hide_cursor();
}
static void
pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface)
{
}
static void
pointer_handle_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
{
}
static void
pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button,
uint32_t state)
{
}
static void
pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
}
static const struct wl_pointer_listener pointer_listener = {
pointer_handle_enter,
pointer_handle_leave,
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
};
void setup_callback_listener()
{
struct wl_callback *callback;
callback = wl_display_sync(GLWin.wl_display);
wl_callback_add_listener(callback, &configure_callback_listener, 0);
}
static void
toggle_fullscreen(bool fullscreen)
{
GLWin.fullscreen = fullscreen;
GLWin.configured = false;
if (fullscreen) {
wl_shell_surface_set_fullscreen(GLWin.wl_shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0, NULL);
} else {
wl_shell_surface_set_toplevel(GLWin.wl_shell_surface);
handle_configure(NULL, GLWin.wl_shell_surface, 0,
GLWin.window_size.width,
GLWin.window_size.height);
}
setup_callback_listener();
}
static void
keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int fd, uint32_t size)
{
char *map_str;
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
close(fd);
return;
}
map_str = (char *) mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map_str == MAP_FAILED) {
close(fd);
return;
}
GLWin.keyboard.xkb.keymap = xkb_map_new_from_string(GLWin.keyboard.xkb.context,
map_str,
XKB_KEYMAP_FORMAT_TEXT_V1,
(xkb_keymap_compile_flags) 0);
munmap(map_str, size);
close(fd);
if (!GLWin.keyboard.xkb.keymap) {
fprintf(stderr, "failed to compile keymap\n");
return;
}
GLWin.keyboard.xkb.state = xkb_state_new(GLWin.keyboard.xkb.keymap);
if (!GLWin.keyboard.xkb.state) {
fprintf(stderr, "failed to create XKB state\n");
xkb_map_unref(GLWin.keyboard.xkb.keymap);
GLWin.keyboard.xkb.keymap = NULL;
return;
}
GLWin.keyboard.xkb.control_mask =
1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Control");
GLWin.keyboard.xkb.alt_mask =
1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Mod1");
GLWin.keyboard.xkb.shift_mask =
1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Shift");
}
static void
keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface,
struct wl_array *keys)
{
}
static void
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface)
{
}
static void
keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t state)
{
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
return;
if (key == KEY_ESC)
GLWin.running = false;
else if ((key == KEY_P) ||
((key == KEY_ENTER) && (GLWin.keyboard.modifiers == 0)))
Core::SetState((Core::GetState() == Core::CORE_RUN) ?
Core::CORE_PAUSE : Core::CORE_RUN);
else if (key == KEY_F)
toggle_fullscreen(!GLWin.fullscreen);
else if ((key == KEY_ENTER) && (GLWin.keyboard.modifiers == MOD_ALT_MASK))
toggle_fullscreen(!GLWin.fullscreen);
else if (key >= KEY_F1 && key <= KEY_F8) {
int slot_number = key - KEY_F1 + 1;
if (GLWin.keyboard.modifiers == MOD_SHIFT_MASK)
State::Save(slot_number);
else
State::Load(slot_number);
}
else if (key == KEY_F9)
Core::SaveScreenShot();
else if (key == KEY_F11)
State::LoadLastSaved();
else if (key == KEY_F12) {
if (GLWin.keyboard.modifiers == MOD_SHIFT_MASK)
State::UndoLoadState();
else
State::UndoSaveState();
}
}
static void
keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched, uint32_t mods_locked,
uint32_t group)
{
xkb_mod_mask_t mask;
xkb_state_update_mask(GLWin.keyboard.xkb.state, mods_depressed, mods_latched,
mods_locked, 0, 0, group);
mask = xkb_state_serialize_mods(GLWin.keyboard.xkb.state,
(xkb_state_component)
(XKB_STATE_DEPRESSED |
XKB_STATE_LATCHED));
GLWin.keyboard.modifiers = 0;
if (mask & GLWin.keyboard.xkb.control_mask)
GLWin.keyboard.modifiers |= MOD_CONTROL_MASK;
if (mask & GLWin.keyboard.xkb.alt_mask)
GLWin.keyboard.modifiers |= MOD_ALT_MASK;
if (mask & GLWin.keyboard.xkb.shift_mask)
GLWin.keyboard.modifiers |= MOD_SHIFT_MASK;
}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_keymap,
keyboard_handle_enter,
keyboard_handle_leave,
keyboard_handle_key,
keyboard_handle_modifiers,
};
static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
uint32_t caps)
{
struct wl_pointer *wl_pointer = NULL;
struct wl_keyboard *wl_keyboard = NULL;
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !wl_pointer) {
wl_pointer = wl_seat_get_pointer(seat);
wl_pointer_add_listener(wl_pointer, &pointer_listener, 0);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && wl_pointer) {
wl_pointer_destroy(wl_pointer);
wl_pointer = NULL;
}
GLWin.pointer.wl_pointer = wl_pointer;
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !wl_keyboard) {
wl_keyboard = wl_seat_get_keyboard(seat);
wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, 0);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && wl_keyboard) {
wl_keyboard_destroy(wl_keyboard);
wl_keyboard = NULL;
}
GLWin.keyboard.wl_keyboard = wl_keyboard;
}
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
};
static void
registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
{
if (strcmp(interface, "wl_compositor") == 0) {
GLWin.wl_compositor = (wl_compositor *)
wl_registry_bind(registry, name,
&wl_compositor_interface, 1);
} else if (strcmp(interface, "wl_shell") == 0) {
GLWin.wl_shell = (wl_shell *) wl_registry_bind(registry, name,
&wl_shell_interface, 1);
} else if (strcmp(interface, "wl_seat") == 0) {
GLWin.wl_seat = (wl_seat *) wl_registry_bind(registry, name,
&wl_seat_interface, 1);
wl_seat_add_listener(GLWin.wl_seat, &seat_listener, 0);
} else if (strcmp(interface, "wl_shm") == 0) {
GLWin.wl_shm = (wl_shm *) wl_registry_bind(registry, name,
&wl_shm_interface, 1);
GLWin.wl_cursor_theme = (wl_cursor_theme *) wl_cursor_theme_load(NULL, 32, GLWin.wl_shm);
GLWin.wl_cursor = (wl_cursor *)
wl_cursor_theme_get_cursor(GLWin.wl_cursor_theme, "left_ptr");
}
}
static void
registry_handle_global_remove(void *data, struct wl_registry *registry,
uint32_t name)
{
}
static const struct wl_registry_listener registry_listener = {
registry_handle_global,
registry_handle_global_remove
};
bool cWaylandInterface::ServerConnect(void)
{
GLWin.wl_display = wl_display_connect(NULL);
if (!GLWin.wl_display)
return false;
return true;
}
bool cWaylandInterface::Initialize(void *config)
{
if (!GLWin.wl_display) {
printf("Error: couldn't open wayland display\n");
return false;
}
GLWin.pointer.wl_pointer = NULL;
GLWin.keyboard.wl_keyboard = NULL;
GLWin.keyboard.xkb.context = xkb_context_new((xkb_context_flags) 0);
if (GLWin.keyboard.xkb.context == NULL) {
fprintf(stderr, "Failed to create XKB context\n");
return NULL;
}
GLWin.wl_registry = wl_display_get_registry(GLWin.wl_display);
wl_registry_add_listener(GLWin.wl_registry,
&registry_listener, NULL);
wl_display_dispatch(GLWin.wl_display);
GLWin.wl_cursor_surface =
wl_compositor_create_surface(GLWin.wl_compositor);
return true;
}
void *cWaylandInterface::EGLGetDisplay(void)
{
#if HAVE_X11
return eglGetDisplay((_XDisplay *) GLWin.wl_display);
#else
return eglGetDisplay(GLWin.wl_display);
#endif
}
void *cWaylandInterface::CreateWindow(void)
{
GLWin.window_size.width = 640;
GLWin.window_size.height = 480;
GLWin.fullscreen = true;
GLWin.frame_drawn = false;
GLWin.swap_complete = false;
GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor);
GLWin.wl_shell_surface = wl_shell_get_shell_surface(GLWin.wl_shell,
GLWin.wl_surface);
wl_shell_surface_add_listener(GLWin.wl_shell_surface,
&shell_surface_listener, 0);
GLWin.wl_egl_native = wl_egl_window_create(GLWin.wl_surface,
GLWin.window_size.width,
GLWin.window_size.height);
#if HAVE_X11
return GLWin.wl_egl_native;
#else
return GLWin.wl_egl_native;
#endif
}
void cWaylandInterface::DestroyWindow(void)
{
wl_egl_window_destroy(GLWin.wl_egl_native);
wl_shell_surface_destroy(GLWin.wl_shell_surface);
wl_surface_destroy(GLWin.wl_surface);
if (GLWin.wl_callback)
wl_callback_destroy(GLWin.wl_callback);
}
void cWaylandInterface::UpdateFPSDisplay(const char *text)
{
wl_shell_surface_set_title(GLWin.wl_shell_surface, text);
}
void cWaylandInterface::ToggleFullscreen(bool fullscreen)
{
toggle_fullscreen(GLWin.fullscreen);
}

View File

@ -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

View File

@ -33,14 +33,17 @@
#include "ConfigManager.h"
#include "LogManager.h"
#include "BootManager.h"
#include "OnScreenDisplay.h"
#include "Android/ButtonManager.h"
#include <jni.h>
#include <android/log.h>
#include <android/native_window_jni.h>
ANativeWindow* surf;
int g_width, g_height;
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__))
bool rendererHasFocus = true;
bool running = true;
void Host_NotifyMapLoaded() {}
void Host_RefreshDSPDebuggerWindow() {}
@ -53,7 +56,7 @@ void Host_Message(int Id)
void* Host_GetRenderHandle()
{
return NULL;
return surf;
}
void* Host_GetInstance() { return NULL; }
@ -79,8 +82,8 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
{
x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;
y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos;
width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth;
height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight;
width = g_width;
height = g_height;
}
void Host_RequestRenderWindowSize(int width, int height) {}
@ -118,25 +121,69 @@ void Host_SysMessage(const char *fmt, ...)
void Host_SetWiiMoteConnectionState(int _State) {}
void OSDCallbacks(u32 UserData)
{
switch(UserData)
{
case 0: // Init
ButtonManager::Init();
break;
case 1: // Draw
ButtonManager::DrawButtons();
break;
case 2: // Shutdown
ButtonManager::Shutdown();
break;
default:
WARN_LOG(COMMON, "Error, wrong OSD type");
break;
}
}
#ifdef __cplusplus
extern "C"
{
#endif
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_dolphinemuactivity_main(JNIEnv *env, jobject obj)
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj)
{
PowerPC::Start();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_PauseEmulation(JNIEnv *env, jobject obj)
{
PowerPC::Pause();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEmulation(JNIEnv *env, jobject obj)
{
PowerPC::Stop();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_onTouchEvent(JNIEnv *env, jobject obj, jint Action, jfloat X, jfloat Y)
{
ButtonManager::TouchEvent(Action, X, Y);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
{
surf = ANativeWindow_fromSurface(env, _surf);
g_width = (int)_width;
g_height = (int)_height;
// Install our callbacks
OSD::AddCallback(OSD::OSD_INIT, OSDCallbacks, 0);
OSD::AddCallback(OSD::OSD_ONFRAME, OSDCallbacks, 1);
OSD::AddCallback(OSD::OSD_SHUTDOWN, OSDCallbacks, 2);
LogManager::Init();
SConfig::Init();
VideoBackend::PopulateList();
VideoBackend::ActivateBackend(SConfig::GetInstance().
m_LocalCoreStartupParameter.m_strVideoBackend);
VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
WiimoteReal::LoadSettings();
const char *File = env->GetStringUTFChars(jFile, NULL);
// No use running the loop when booting fails
if (BootManager::BootCore(""))
{
if ( BootManager::BootCore( File ) )
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();
}
WiimoteReal::Shutdown();
VideoBackend::ClearList();

View File

@ -21,6 +21,10 @@ elseif(X11_FOUND)
set(SRCS ${SRCS}
Src/ControllerInterface/SDL/SDL.cpp
Src/ControllerInterface/Xlib/Xlib.cpp)
elseif(ANDROID)
set(SRCS ${SRCS}
Src/ControllerInterface/Android/Android.cpp
Src/Android/ButtonManager.cpp)
endif()
add_library(inputcommon ${SRCS})

View File

@ -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());
}
}

View File

@ -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();
}

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -15,6 +15,9 @@
#ifdef CIFACE_USE_SDL
#include "SDL/SDL.h"
#endif
#ifdef CIFACE_USE_ANDROID
#include "Android/Android.h"
#endif
#include "Thread.h"
@ -50,6 +53,9 @@ void ControllerInterface::Initialize()
#ifdef CIFACE_USE_SDL
ciface::SDL::Init(m_devices);
#endif
#ifdef CIFACE_USE_ANDROID
ciface::Android::Init(m_devices);
#endif
m_is_init = true;
}
@ -100,6 +106,9 @@ void ControllerInterface::Shutdown()
// TODO: there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
SDL_Quit();
#endif
#ifdef CIFACE_USE_ANDROID
// nothing needed
#endif
m_is_init = false;
}

View File

@ -29,7 +29,10 @@
#if defined(__APPLE__)
#define CIFACE_USE_OSX
#endif
#ifdef ANDROID
#define CIFACE_USE_ANDROID
#endif
// idk in case i wanted to change it to double or somethin, idk what's best
typedef float ControlState;

View File

@ -51,9 +51,7 @@ void VideoBackend::UpdateFPSDisplay(const char *text)
}
void InitInterface()
{
#ifdef ANDROID
GLInterface = new cInterfaceBase;
#elif defined(USE_EGL) && USE_EGL
#if defined(USE_EGL) && USE_EGL
GLInterface = new cInterfaceEGL;
#elif defined(__APPLE__)
GLInterface = new cInterfaceAGL;

View File

@ -77,8 +77,6 @@ void CreateShaders()
uni_tex = glGetUniformLocation(program, "Texture");
attr_pos = glGetAttribLocation(program, "pos");
attr_tex = glGetAttribLocation(program, "TexCoordIn");
}
void SWRenderer::Prepare()
@ -137,7 +135,46 @@ void SWRenderer::DrawDebugText()
SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
}
#ifdef ANDROID
// XXX: This /really/ shouldn't be here
// But for now, we don't have a generic way for all backends to draw the buttons on screen.
// Once that is implemented, we can remove this
void DrawButton(GLuint tex, float *coords)
{
//Texture rectangle uses pixel coordinates
#ifndef USE_GLES
GLfloat u_max = (GLfloat)width;
GLfloat v_max = (GLfloat)height;
static const GLfloat texverts[4][2] = {
{0, v_max},
{0, 0},
{u_max, 0},
{u_max, v_max}
};
#else
static const GLfloat texverts[4][2] = {
{0, 1},
{0, 0},
{1, 0},
{1, 1}
};
#endif
glBindTexture(TEX2D, tex);
glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, coords);
glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
glEnableVertexAttribArray(attr_pos);
glEnableVertexAttribArray(attr_tex);
glActiveTexture(GL_TEXTURE0);
glUniform1i(uni_tex, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(attr_pos);
glDisableVertexAttribArray(attr_tex);
glBindTexture(TEX2D, 0);
}
#endif
void SWRenderer::DrawTexture(u8 *texture, int width, int height)
{
GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();