mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 01:30:51 +00:00
(Android) Renamed GUI to RetroArch Android - Phoenix will be Java-only,
and the RetroArch program itself will be a native activity
This commit is contained in:
parent
18191b2f18
commit
ad27bedcb4
@ -20,6 +20,7 @@
|
||||
</activity>
|
||||
<activity android:label="@string/app_name" android:name="rombrowser" />
|
||||
<activity android:label="@string/app_name" android:name="com.retroarch.fileio.FileChooser" />
|
||||
<activity android:name=".rgl" android:label="@string/app_name" />
|
||||
</application>
|
||||
<!-- Tell the system this app requires OpenGL ES 2.0. -->
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
@ -38,58 +38,36 @@
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad( JavaVM *vm, void *pvt)
|
||||
{
|
||||
RARCH_LOG("JNI_OnLoad.\n" );
|
||||
|
||||
rarch_main_clear_state();
|
||||
|
||||
config_set_defaults();
|
||||
input_null.init();
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.\n" );
|
||||
|
||||
const input_driver_t *input = &input_null;
|
||||
|
||||
bool find_libretro_file = false;
|
||||
|
||||
snprintf(default_paths.config_file, sizeof(default_paths.config_file), "/mnt/extsd/retroarch.cfg");
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.1.\n" );
|
||||
|
||||
rarch_init_msg_queue();
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.2.\n" );
|
||||
|
||||
rarch_settings_set_default();
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.3.\n" );
|
||||
//rarch_input_set_controls_default(input);
|
||||
rarch_config_load(default_paths.config_file, find_libretro_file);
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.4.\n" );
|
||||
init_libretro_sym();
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.5.\n" );
|
||||
|
||||
|
||||
input_null.post_init();
|
||||
RARCH_LOG("JNI_OnLoad #1.6.\n" );
|
||||
|
||||
//video_gl.start();
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.7.\n" );
|
||||
|
||||
//driver.video = &video_gl;
|
||||
|
||||
RARCH_LOG("JNI_OnLoad #1.8.\n" );
|
||||
|
||||
RARCH_LOG("Reached end of JNI_OnLoad.\n" );
|
||||
|
||||
return JNI_VERSION_1_2;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL JNI_OnUnLoad( JavaVM *vm, void *pvt)
|
||||
{
|
||||
RARCH_LOG("JNI_OnUnLoad.\n" );
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_retroarch_rruntime_load_1game
|
||||
@ -158,7 +136,7 @@ JNIEXPORT void JNICALL Java_com_retroarch_rruntime_settings_1change
|
||||
JNIEXPORT void JNICALL Java_com_retroarch_rruntime_settings_1set_1defaults
|
||||
(JNIEnv *env, jclass class)
|
||||
{
|
||||
RARCH_LOG("* rruntime_settings_set_defaults.\n" );
|
||||
RARCH_LOG("rruntime_settings_set_defaults.\n" );
|
||||
rarch_settings_set_default();
|
||||
}
|
||||
|
||||
|
@ -1,146 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch 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 Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.retroarch;
|
||||
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioTrack;
|
||||
|
||||
public class audio_android
|
||||
{
|
||||
private static AudioTrack _track;
|
||||
private static int _minSamples;
|
||||
private static float _volume = AudioTrack.getMaxVolume();
|
||||
|
||||
private static int _rate;
|
||||
private static int _bits;
|
||||
private static int _channels;
|
||||
|
||||
|
||||
private audio_android()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void pause()
|
||||
{
|
||||
if (_track != null && _track.getPlayState() != AudioTrack.PLAYSTATE_PAUSED)
|
||||
_track.pause();
|
||||
}
|
||||
|
||||
|
||||
public static void resume()
|
||||
{
|
||||
if (_track != null && _track.getPlayState() != AudioTrack.PLAYSTATE_PLAYING)
|
||||
_track.play();
|
||||
}
|
||||
|
||||
public int getMinSamples()
|
||||
{
|
||||
return _minSamples;
|
||||
}
|
||||
|
||||
|
||||
public static int write(short[] data, int size)
|
||||
{
|
||||
int retVal = 0;
|
||||
if (_track == null)
|
||||
return retVal;
|
||||
|
||||
retVal = _track.write(data, 0, size);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
void set_volume(int vol)
|
||||
{
|
||||
final float min = AudioTrack.getMinVolume();
|
||||
final float max = AudioTrack.getMaxVolume();
|
||||
_volume = min + (max - min) * vol / 100;
|
||||
|
||||
if (_track != null)
|
||||
_track.setStereoVolume(_volume, _volume);
|
||||
}
|
||||
|
||||
|
||||
public static void free()
|
||||
{
|
||||
if (_track != null)
|
||||
{
|
||||
_track.pause();
|
||||
_track.release();
|
||||
_track = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean init(int rate, int bits, int channels)
|
||||
{
|
||||
_track = null;
|
||||
_rate = rate;
|
||||
_bits = bits;
|
||||
_channels = channels;
|
||||
|
||||
// generate format
|
||||
int format = (_bits == 16
|
||||
? AudioFormat.ENCODING_PCM_16BIT
|
||||
: AudioFormat.ENCODING_PCM_8BIT);
|
||||
|
||||
// determine channel config
|
||||
int channelConfig = (_channels == 2
|
||||
? AudioFormat.CHANNEL_OUT_STEREO
|
||||
: AudioFormat.CHANNEL_OUT_MONO);
|
||||
|
||||
int bufferSize = AudioTrack.getMinBufferSize(_rate, channelConfig,
|
||||
format);
|
||||
|
||||
_minSamples = bufferSize;
|
||||
|
||||
try
|
||||
{
|
||||
_track = new AudioTrack(
|
||||
AudioManager.STREAM_MUSIC,
|
||||
_rate,
|
||||
channelConfig,
|
||||
format,
|
||||
bufferSize,
|
||||
AudioTrack.MODE_STREAM);
|
||||
|
||||
if (_track.getState() == AudioTrack.STATE_UNINITIALIZED)
|
||||
_track = null;
|
||||
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
_track = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// set max volume
|
||||
_track.setStereoVolume(_volume, _volume);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static int getMaxBufferSize()
|
||||
{
|
||||
return _minSamples;
|
||||
}
|
||||
}
|
@ -34,7 +34,6 @@ public class main extends Activity
|
||||
{
|
||||
static private final int ACTIVITY_LOAD_ROM = 0;
|
||||
|
||||
private GLSurfaceView ctx_gl;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
@ -42,8 +41,6 @@ public class main extends Activity
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.setTitle("RetroArch | Main");
|
||||
ctx_gl = new rgl_context(this);
|
||||
setContentView(ctx_gl);
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
@ -92,23 +89,11 @@ public class main extends Activity
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
ctx_gl.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
ctx_gl.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
class rgl_context extends GLSurfaceView
|
||||
{
|
||||
public rgl_context(Context context)
|
||||
{
|
||||
super(context);
|
||||
setEGLContextClientVersion(2);
|
||||
setRenderer(new rgl());
|
||||
}
|
||||
}
|
||||
|
@ -1,111 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch 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 Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.retroarch;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
public class rgl implements GLSurfaceView.Renderer
|
||||
{
|
||||
private int cprg;
|
||||
private int v_position_handle;
|
||||
private FloatBuffer triangle_vbo;
|
||||
|
||||
private void triangles_init()
|
||||
{
|
||||
float triangle_coords[] = {
|
||||
// X, Y, Z
|
||||
-0.5f, -0.25f, 0,
|
||||
0.5f, -0.25f, 0,
|
||||
0.0f, 0.559016994f, 0
|
||||
};
|
||||
|
||||
ByteBuffer vbb = ByteBuffer.allocateDirect(triangle_coords.length * 4);
|
||||
vbb.order(ByteOrder.nativeOrder());
|
||||
triangle_vbo = vbb.asFloatBuffer();
|
||||
triangle_vbo.put(triangle_coords);
|
||||
triangle_vbo.position(0);
|
||||
}
|
||||
|
||||
private void shader_init()
|
||||
{
|
||||
final String vprg =
|
||||
"attribute vec4 vPosition; \n" +
|
||||
"void main(){ \n" +
|
||||
" gl_Position = vPosition; \n" +
|
||||
"} \n";
|
||||
final String fprg =
|
||||
"precision mediump float; \n" +
|
||||
"void main(){ \n" +
|
||||
" gl_FragColor = vec4 (0.63671875, 0.76953125, 0.22265625, 1.0); \n" +
|
||||
"} \n";
|
||||
|
||||
int vertex_shader, fragment_shader;
|
||||
|
||||
vertex_shader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
|
||||
|
||||
GLES20.glShaderSource(vertex_shader, vprg);
|
||||
GLES20.glCompileShader(vertex_shader);
|
||||
|
||||
fragment_shader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
|
||||
|
||||
GLES20.glShaderSource(fragment_shader, fprg);
|
||||
GLES20.glCompileShader(fragment_shader);
|
||||
|
||||
cprg = GLES20.glCreateProgram();
|
||||
GLES20.glAttachShader(cprg, vertex_shader);
|
||||
GLES20.glAttachShader(cprg, fragment_shader);
|
||||
GLES20.glLinkProgram(cprg);
|
||||
|
||||
//get handle to the vertex shader's vPosition member
|
||||
v_position_handle = GLES20.glGetAttribLocation(cprg, "vPosition");
|
||||
; }
|
||||
|
||||
public void onSurfaceCreated(GL10 unused, EGLConfig config)
|
||||
{
|
||||
//background color
|
||||
GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
triangles_init();
|
||||
shader_init();
|
||||
}
|
||||
|
||||
public void onDrawFrame(GL10 unused)
|
||||
{
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
GLES20.glUseProgram(cprg);
|
||||
|
||||
// Triangle
|
||||
GLES20.glVertexAttribPointer(v_position_handle, 3, GLES20.GL_FLOAT, false, 12, triangle_vbo);
|
||||
GLES20.glEnableVertexAttribArray(v_position_handle);
|
||||
|
||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 unused, int width, int height)
|
||||
{
|
||||
GLES20.glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch 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 Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch 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 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.retroarch;
|
||||
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
public class rruntime
|
||||
{
|
||||
static
|
||||
{
|
||||
System.loadLibrary("retroarch");
|
||||
}
|
||||
|
||||
private rruntime()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static native void load_game(final String j_path, final int j_extract_zip_mode);
|
||||
|
||||
public static native boolean run_frame();
|
||||
|
||||
public static native void startup(String j_config_path);
|
||||
|
||||
public static native void deinit();
|
||||
|
||||
public static native void load_state();
|
||||
|
||||
public static native void save_state();
|
||||
|
||||
public static native void settings_change(final int j_setting);
|
||||
|
||||
public static native void settings_set_defaults();
|
||||
|
||||
public static native void set_window(SurfaceHolder surface);
|
||||
|
||||
public static native void free_window(SurfaceHolder surface);
|
||||
}
|
@ -17,6 +17,8 @@
|
||||
#include "../../driver.h"
|
||||
#include "../gl_common.h"
|
||||
|
||||
#include <android/native_window.h>
|
||||
|
||||
#include <EGL/egl.h> /* Requires NDK r5 or newer */
|
||||
#include <GLES/gl.h>
|
||||
|
||||
@ -30,7 +32,7 @@ enum RenderThreadMessage {
|
||||
|
||||
enum RenderThreadMessage _msg;
|
||||
|
||||
ANativeWindow *window; /* Requires NDK r5 or newer */
|
||||
EGLNativeWindowType window; /* Requires NDK r5 or newer */
|
||||
|
||||
static EGLContext g_egl_ctx;
|
||||
static EGLSurface g_egl_surf;
|
||||
@ -90,6 +92,8 @@ static void gfx_ctx_destroy(void)
|
||||
_height = 0;
|
||||
}
|
||||
|
||||
EGLNativeWindowType android_createDisplaySurface(void);
|
||||
|
||||
static bool gfx_ctx_init(void)
|
||||
{
|
||||
const EGLint attribs[] = {
|
||||
@ -113,6 +117,8 @@ static bool gfx_ctx_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
window = NULL;
|
||||
|
||||
EGLint egl_major, egl_minor;
|
||||
if (!eglInitialize(g_egl_dpy, &egl_major, &egl_minor)) {
|
||||
RARCH_ERR("eglInitialize() returned error %d.\n", eglGetError());
|
||||
@ -134,7 +140,11 @@ static bool gfx_ctx_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
ANativeWindow_setBuffersGeometry(window, 0, 0, format);
|
||||
if (!(g_egl_ctx = eglCreateContext(g_egl_dpy, config, 0, 0))) {
|
||||
RARCH_ERR("eglCreateContext() returned error %d.\n", eglGetError());
|
||||
gfx_ctx_destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(g_egl_surf = eglCreateWindowSurface(g_egl_dpy, config, window, 0))) {
|
||||
RARCH_ERR("eglCreateWindowSurface() returned error %d.\n", eglGetError());
|
||||
@ -142,11 +152,6 @@ static bool gfx_ctx_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(g_egl_ctx = eglCreateContext(g_egl_dpy, config, 0, 0))) {
|
||||
RARCH_ERR("eglCreateContext() returned error %d.\n", eglGetError());
|
||||
gfx_ctx_destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) {
|
||||
RARCH_ERR("eglMakeCurrent() returned error %d.\n", eglGetError());
|
||||
@ -164,6 +169,8 @@ static bool gfx_ctx_init(void)
|
||||
_width = width;
|
||||
_height = height;
|
||||
|
||||
RARCH_LOG("Window specs: %d*%d.\n", _width, _height);
|
||||
|
||||
/*
|
||||
glDisable(GL_DITHER);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
|
Loading…
Reference in New Issue
Block a user