(Android) Do removal of Android classes sanely - without local working

copy
This commit is contained in:
twinaphex 2012-10-14 01:54:02 +02:00
parent 73194640a0
commit 87cec1a077
5 changed files with 7 additions and 338 deletions

View File

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

View File

@ -7,15 +7,9 @@ import java.util.List;
import java.util.Stack;
import com.retroarch.R;
import com.retroarch.R.layout;
import com.retroarch.rruntime;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.KeyEvent;
@ -24,7 +18,6 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.net.Uri;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
@ -211,13 +204,17 @@ public class FileChooser extends Activity
}
else
{
/*
String path = o.getPath();
int dotIndex = path.lastIndexOf('.');
String ext = null;
if (dotIndex >= 0)
{
ext = path.substring(dotIndex+1).toLowerCase();
}
*/
onFileClick(o);
}

View File

@ -21,29 +21,22 @@ import com.retroarch.fileio.FileChooser;
import android.app.Activity;
import android.content.Intent;
import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
public class main extends Activity
{
static private final int ACTIVITY_LOAD_ROM = 0;
private GLSurfaceView ctx_gl;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setTitle("RetroArch | Main");
ctx_gl = new rgl_context(this);
setContentView(ctx_gl);
this.setTitle("RetroArch Phoenix");
}
public boolean onCreateOptionsMenu(Menu menu)
@ -77,6 +70,7 @@ public class main extends Activity
{
if(requestCode == ACTIVITY_LOAD_ROM)
{
/*
rruntime.settings_set_defaults();
rruntime.load_game(data.getStringExtra("PATH"), 0);
@ -85,6 +79,7 @@ public class main extends Activity
rruntime.startup(video.toString());
while(rruntime.run_frame());
*/
}
}
@ -92,23 +87,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());
}
}

View File

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

View File

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