Merge pull request #266 from NoblesseOblige/master

If you can't combine the activity, share the static functions
This commit is contained in:
TwistedUmbrella 2014-02-11 22:58:24 -05:00
commit 853db5110e
11 changed files with 482 additions and 1340 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -21,7 +21,6 @@ import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class EditVJoyActivity extends Activity {
GL2JNIView mView;
GL2JNIViewV6 mView6;
PopupWindow popUp;
LayoutParams params;
@ -47,17 +46,10 @@ public class EditVJoyActivity extends Activity {
super.onCreate(icicle);
// Create the actual GLES view
if (MainActivity.force_gpu) {
mView6 = new GL2JNIViewV6(getApplication(), null, false, 24, 0, true);
setContentView(mView6);
vjoy_d_cached = GL2JNIView.readCustomVjoyValues(getApplicationContext());
} else {
mView = new GL2JNIView(getApplication(), null, false, 24, 0, true);
setContentView(mView);
vjoy_d_cached = GL2JNIView.readCustomVjoyValues(getApplicationContext());
}
mView = new GL2JNIView(getApplication(), null, false, 24, 0, true);
setContentView(mView);
vjoy_d_cached = VJoy.readCustomVjoyValues(getApplicationContext());
JNIdc.show_osd();
@ -68,20 +60,12 @@ public class EditVJoyActivity extends Activity {
@Override
protected void onPause() {
super.onPause();
if (MainActivity.force_gpu) {
mView6.onPause();
} else {
mView.onPause();
}
mView.onPause();
}
@Override
protected void onStop() {
if (MainActivity.force_gpu) {
mView6.onStop();
} else {
mView.onStop();
}
mView.onStop();
super.onStop();
}
@ -89,11 +73,7 @@ public class EditVJoyActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
if (MainActivity.force_gpu) {
mView6.onResume();
} else {
mView.onResume();
}
mView.onResume();
}
PopupWindow createVJoyPopup() {
@ -116,22 +96,18 @@ public class EditVJoyActivity extends Activity {
hlay.addView(addbut(R.drawable.reset, new OnClickListener() {
public void onClick(View v) {
// Reset VJoy positions and scale
if (MainActivity.force_gpu) {
mView6.resetCustomVjoyValues();
} else {
mView.resetCustomVjoyValues();
}
VJoy.resetCustomVjoyValues(getApplicationContext());
mView.vjoy_d_custom = VJoy
.readCustomVjoyValues(getApplicationContext());
mView.resetEditMode();
mView.requestLayout();
popUp.dismiss();
}
}), params);
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
public void onClick(View v) {
if (MainActivity.force_gpu) {
mView6.restoreCustomVjoyValues(vjoy_d_cached);
} else {
mView.restoreCustomVjoyValues(vjoy_d_cached);
}
mView.restoreCustomVjoyValues(vjoy_d_cached);
popUp.dismiss();
}
}), params);
@ -144,11 +120,7 @@ public class EditVJoyActivity extends Activity {
if (keyCode == KeyEvent.KEYCODE_MENU
|| keyCode == KeyEvent.KEYCODE_BACK) {
if (!popUp.isShowing()) {
if (MainActivity.force_gpu) {
popUp.showAtLocation(mView6, Gravity.BOTTOM, 0, 0);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
} else {

View File

@ -26,7 +26,6 @@ import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class GL2JNIActivity extends Activity {
GL2JNIView mView;
GL2JNIViewV6 mView6;
OnScreenMenu menu;
PopupWindow popUp;
MOGAInput moga = new MOGAInput();
@ -253,13 +252,8 @@ public class GL2JNIActivity extends Activity {
fileName = Uri.decode(intent.getData().toString());
// Create the actual GLES view
if (MainActivity.force_gpu) {
mView6 = new GL2JNIViewV6(getApplication(), fileName, false, 24, 0, false);
setContentView(mView6);
} else {
mView = new GL2JNIView(getApplication(), fileName, false, 24, 0, false);
setContentView(mView);
}
mView = new GL2JNIView(getApplication(), fileName, false, 24, 0, false);
setContentView(mView);
String menu_spec;
if (android.os.Build.MODEL.equals("R800")
@ -358,19 +352,11 @@ public class GL2JNIActivity extends Activity {
globalLS_Y[playerNum] = LS_Y;
}
if (MainActivity.force_gpu) {
GL2JNIViewV6.lt[playerNum] = (int) (L2 * 255);
GL2JNIViewV6.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIViewV6.jx[playerNum] = (int) (LS_X * 126);
GL2JNIViewV6.jy[playerNum] = (int) (LS_Y * 126);
} else {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
}
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
}
}
@ -399,17 +385,10 @@ public class GL2JNIActivity extends Activity {
globalLS_X[playerNum] = 0;
globalLS_Y[playerNum] = 0;
}
if (MainActivity.force_gpu) {
GL2JNIViewV6.lt[playerNum] = (int) (L2 * 255);
GL2JNIViewV6.rt[playerNum] = (int) (R2 * 255);
GL2JNIViewV6.jx[playerNum] = (int) (0 * 126);
GL2JNIViewV6.jy[playerNum] = (int) (0 * 126);
} else {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (0 * 126);
GL2JNIView.jy[playerNum] = (int) (0 * 126);
}
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (0 * 126);
GL2JNIView.jy[playerNum] = (int) (0 * 126);
}
if ((jsCompat[playerNum] || xbox[playerNum] || nVidia[playerNum])
&& ((globalLS_X[playerNum] == previousLS_X[playerNum] && globalLS_Y[playerNum] == previousLS_Y[playerNum]) || (previousLS_X[playerNum] == 0.0f && previousLS_Y[playerNum] == 0.0f)))
@ -474,17 +453,10 @@ public class GL2JNIActivity extends Activity {
boolean rav = false;
for (int i = 0; i < map[playerNum].length; i += 2) {
if (map[playerNum][i + 0] == kc) {
if (MainActivity.force_gpu) {
if (down)
GL2JNIViewV6.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIViewV6.kcode_raw[playerNum] |= map[playerNum][i + 1];
} else {
if (down)
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
}
if (down)
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
rav = true;
break;
}
@ -498,21 +470,13 @@ public class GL2JNIActivity extends Activity {
}
public void displayPopUp(PopupWindow popUp) {
if (MainActivity.force_gpu) {
popUp.showAtLocation(mView6, Gravity.BOTTOM, 0, 0);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayConfig(PopupWindow popUpConfig) {
if (MainActivity.force_gpu) {
popUpConfig.showAtLocation(mView6, Gravity.BOTTOM, 0, 0);
} else {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
popUpConfig.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
@ -586,11 +550,7 @@ public class GL2JNIActivity extends Activity {
@Override
protected void onPause() {
super.onPause();
if (MainActivity.force_gpu) {
mView6.onPause();
} else {
mView.onPause();
}
mView.onPause();
moga.onPause();
}
@ -604,11 +564,7 @@ public class GL2JNIActivity extends Activity {
protected void onStop() {
// TODO Auto-generated method stub
JNIdc.stop();
if (MainActivity.force_gpu) {
mView6.onStop();
} else {
mView.onStop();
}
mView.onStop();
super.onStop();
}
@ -620,11 +576,7 @@ public class GL2JNIActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
if (MainActivity.force_gpu) {
mView6.onResume();
} else {
mView.onResume();
}
mView.onResume();
moga.onResume();
}
}

View File

@ -26,7 +26,6 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View.OnSystemUiVisibilityChangeListener;
import android.view.View;
@ -55,19 +54,7 @@ class GL2JNIView extends GLSurfaceView
//private AudioThread audioThread;
private EmuThread ethd = new EmuThread();
private static final boolean DEBUG = false;
private static final int key_CONT_B = 0x0002;
private static final int key_CONT_A = 0x0004;
private static final int key_CONT_START = 0x0008;
private static final int key_CONT_DPAD_UP = 0x0010;
private static final int key_CONT_DPAD_DOWN = 0x0020;
private static final int key_CONT_DPAD_LEFT = 0x0040;
private static final int key_CONT_DPAD_RIGHT = 0x0080;
private static final int key_CONT_Y = 0x0200;
private static final int key_CONT_X = 0x0400;
public static final int LAYER_TYPE_SOFTWARE = 1;
public static final int LAYER_TYPE_HARDWARE = 2;
public static final boolean DEBUG = false;
Vibrator vib;
@ -75,138 +62,18 @@ class GL2JNIView extends GLSurfaceView
private int selectedVjoyElement = -1;
private ScaleGestureDetector scaleGestureDetector;
private static float[][] vjoy_d_custom;
public float[][] vjoy_d_custom;
private static final float[][] vjoy = new float[][]
{
new float[] { 24+0, 24+64, 64,64, key_CONT_DPAD_LEFT, 0},
new float[] { 24+64, 24+0, 64,64, key_CONT_DPAD_UP, 0},
new float[] { 24+128, 24+64, 64,64, key_CONT_DPAD_RIGHT, 0},
new float[] { 24+64, 24+128, 64,64, key_CONT_DPAD_DOWN, 0},
new float[] { 440+0, 280+64, 64,64, key_CONT_X, 0},
new float[] { 440+64, 280+0, 64,64, key_CONT_Y, 0},
new float[] { 440+128, 280+64, 64,64, key_CONT_B, 0},
new float[] { 440+64, 280+128, 64,64, key_CONT_A, 0},
new float[] { 320-32, 360+32, 64,64, key_CONT_START, 0},
new float[] { 440, 200, 90,64, -1, 0},
new float[] { 542, 200, 90,64, -2, 0},
new float[] { 0, 128+224, 128,128, -3, 0},
new float[] { 96, 320, 32,32, -4, 0},
};
private static final float[][] vjoy = VJoy.baseVJoy();
Renderer rend;
private boolean touchVibrationEnabled;
Context context;
private static float[][] getVjoy_d(float[][] vjoy_d_custom) {
return new float[][]
{
new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT},
new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_UP},
new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT},
new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_DOWN},
new float[] { 448+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_X},
new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_Y},
new float[] { 448+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_B},
new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_A},
new float[] { 320-32+vjoy_d_custom[2][0], 288+128+vjoy_d_custom[2][1], 64*vjoy_d_custom[2][2],64*vjoy_d_custom[2][2], key_CONT_START},
new float[] { 440+vjoy_d_custom[3][0], 200+vjoy_d_custom[3][1], 90*vjoy_d_custom[3][2],64*vjoy_d_custom[3][2], -1},
new float[] { 542+vjoy_d_custom[4][0], 200+vjoy_d_custom[4][1], 90*vjoy_d_custom[4][2],64*vjoy_d_custom[4][2], -2},
new float[] { 16+vjoy_d_custom[5][0], 24+32+vjoy_d_custom[5][1], 128*vjoy_d_custom[5][2],128*vjoy_d_custom[5][2], -3},
new float[] { 96+vjoy_d_custom[5][0], 320+vjoy_d_custom[5][1], 32*vjoy_d_custom[5][2],32*vjoy_d_custom[5][2], -4},
};
}
private static void writeCustomVjoyValues(float[][] vjoy_d_custom, Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putFloat("touch_x_shift_dpad", vjoy_d_custom[0][0]).commit();
prefs.edit().putFloat("touch_y_shift_dpad", vjoy_d_custom[0][1]).commit();
prefs.edit().putFloat("touch_scale_dpad", vjoy_d_custom[0][2]).commit();
prefs.edit().putFloat("touch_x_shift_buttons", vjoy_d_custom[1][0]).commit();
prefs.edit().putFloat("touch_y_shift_buttons", vjoy_d_custom[1][1]).commit();
prefs.edit().putFloat("touch_scale_buttons", vjoy_d_custom[1][2]).commit();
prefs.edit().putFloat("touch_x_shift_start", vjoy_d_custom[2][0]).commit();
prefs.edit().putFloat("touch_y_shift_start", vjoy_d_custom[2][1]).commit();
prefs.edit().putFloat("touch_scale_start", vjoy_d_custom[2][2]).commit();
prefs.edit().putFloat("touch_x_shift_left_trigger", vjoy_d_custom[3][0]).commit();
prefs.edit().putFloat("touch_y_shift_left_trigger", vjoy_d_custom[3][1]).commit();
prefs.edit().putFloat("touch_scale_left_trigger", vjoy_d_custom[3][2]).commit();
prefs.edit().putFloat("touch_x_shift_right_trigger", vjoy_d_custom[4][0]).commit();
prefs.edit().putFloat("touch_y_shift_right_trigger", vjoy_d_custom[4][1]).commit();
prefs.edit().putFloat("touch_scale_right_trigger", vjoy_d_custom[4][2]).commit();
prefs.edit().putFloat("touch_x_shift_analog", vjoy_d_custom[5][0]).commit();
prefs.edit().putFloat("touch_y_shift_analog", vjoy_d_custom[5][1]).commit();
prefs.edit().putFloat("touch_scale_analog", vjoy_d_custom[5][2]).commit();
}
public static float[][] readCustomVjoyValues(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return new float[][]
{
// x-shift, y-shift, sizing-factor
new float[] { prefs.getFloat("touch_x_shift_dpad", 0), prefs.getFloat("touch_y_shift_dpad", 0), prefs.getFloat("touch_scale_dpad", 1) }, // DPAD
new float[] { prefs.getFloat("touch_x_shift_buttons", 0), prefs.getFloat("touch_y_shift_buttons", 0), prefs.getFloat("touch_scale_buttons", 1) }, // X, Y, B, A Buttons
new float[] { prefs.getFloat("touch_x_shift_start", 0), prefs.getFloat("touch_y_shift_start", 0), prefs.getFloat("touch_scale_start", 1) }, // Start
new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0), prefs.getFloat("touch_y_shift_left_trigger", 0), prefs.getFloat("touch_scale_left_trigger", 1) }, // Left Trigger
new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0), prefs.getFloat("touch_y_shift_right_trigger", 0), prefs.getFloat("touch_scale_right_trigger", 1) }, // Right Trigger
new float[] { prefs.getFloat("touch_x_shift_analog", 0), prefs.getFloat("touch_y_shift_analog", 0), prefs.getFloat("touch_scale_analog", 1) } // Analog Stick
};
}
public void resetCustomVjoyValues() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().remove("touch_x_shift_dpad").commit();
prefs.edit().remove("touch_y_shift_dpad").commit();
prefs.edit().remove("touch_scale_dpad").commit();
prefs.edit().remove("touch_x_shift_buttons").commit();
prefs.edit().remove("touch_y_shift_buttons").commit();
prefs.edit().remove("touch_scale_buttons").commit();
prefs.edit().remove("touch_x_shift_start").commit();
prefs.edit().remove("touch_y_shift_start").commit();
prefs.edit().remove("touch_scale_start").commit();
prefs.edit().remove("touch_x_shift_left_trigger").commit();
prefs.edit().remove("touch_y_shift_left_trigger").commit();
prefs.edit().remove("touch_scale_left_trigger").commit();
prefs.edit().remove("touch_x_shift_right_trigger").commit();
prefs.edit().remove("touch_y_shift_right_trigger").commit();
prefs.edit().remove("touch_scale_right_trigger").commit();
prefs.edit().remove("touch_x_shift_analog").commit();
prefs.edit().remove("touch_y_shift_analog").commit();
prefs.edit().remove("touch_scale_analog").commit();
vjoy_d_custom = readCustomVjoyValues(context);
resetEditMode();
requestLayout();
}
public void restoreCustomVjoyValues(float[][] vjoy_d_cached) {
vjoy_d_custom = vjoy_d_cached;
writeCustomVjoyValues(vjoy_d_cached, context);
VJoy.writeCustomVjoyValues(vjoy_d_cached, context);
resetEditMode();
requestLayout();
@ -254,7 +121,7 @@ class GL2JNIView extends GLSurfaceView
} catch (InvocationTargetException e) {
}
vjoy_d_custom = readCustomVjoyValues(context);
vjoy_d_custom = VJoy.readCustomVjoyValues(context);
scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener());
@ -274,20 +141,29 @@ class GL2JNIView extends GLSurfaceView
// format here, using PixelFormat.TRANSLUCENT for GL Surfaces
// is interpreted as any 32-bit surface with alpha by SurfaceFlinger.
if(translucent) this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
if (MainActivity.force_gpu) {
setEGLContextFactory(new ContextFactory());
setEGLConfigChooser(
translucent?
new ConfigChooser(8, 8, 8, 8, depth, stencil)
: new ConfigChooser(5, 6, 5, 0, depth, stencil)
);
} else {
// Setup the context factory for 2.0 rendering.
// See ContextFactory class definition below
setEGLContextFactory(new ContextFactory());
// Setup the context factory for 2.0 rendering.
// See ContextFactory class definition below
setEGLContextFactory(new ContextFactory());
// We need to choose an EGLConfig that matches the format of
// our surface exactly. This is going to be done in our
// custom config chooser. See ConfigChooser class definition
// below.
setEGLConfigChooser(
translucent?
new ConfigChooser(8, 8, 8, 8, depth, stencil)
: new ConfigChooser(5, 6, 5, 0, depth, stencil)
);
// We need to choose an EGLConfig that matches the format of
// our surface exactly. This is going to be done in our
// custom config chooser. See ConfigChooser class definition
// below.
setEGLConfigChooser(
translucent?
new ConfigChooser(8, 8, 8, 8, depth, stencil)
: new ConfigChooser(5, 6, 5, 0, depth, stencil)
);
}
// Set the renderer responsible for frame rendering
setRenderer(rend=new Renderer());
@ -356,7 +232,7 @@ class GL2JNIView extends GLSurfaceView
float a_x = -tx+ 24*scl;
float a_y=- 24*scl;
float[][] vjoy_d = getVjoy_d(vjoy_d_custom);
float[][] vjoy_d = VJoy.getVjoy_d(vjoy_d_custom);
for(int i=0;i<vjoy.length;i++)
{
@ -377,7 +253,7 @@ class GL2JNIView extends GLSurfaceView
JNIdc.vjoy(i,vjoy[i][0],vjoy[i][1],vjoy[i][2],vjoy[i][3]);
reset_analog();
writeCustomVjoyValues(vjoy_d_custom, context);
VJoy.writeCustomVjoyValues(vjoy_d_custom, context);
}
/*
@ -406,7 +282,7 @@ class GL2JNIView extends GLSurfaceView
}
*/
private void resetEditMode() {
public void resetEditMode() {
editLastX = 0;
editLastY = 0;
}
@ -914,6 +790,14 @@ private static class ContextFactory implements GLSurfaceView.EGLContextFactory
onSurfaceChanged(gl, 800, 480);
}
}
public void audioDisable(boolean disabled) {
if (disabled) {
ethd.Player.pause();
} else {
ethd.Player.play();
}
}
class EmuThread extends Thread

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,243 @@
package com.reicast.emulator;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import android.opengl.EGL14;
import android.opengl.EGLExt;
import android.opengl.GLSurfaceView;
import android.util.Log;
public class GLCFactory6 {
private static void LOGI(String S) { Log.i("GL2JNIView-v6",S); }
private static void LOGW(String S) { Log.w("GL2JNIView-v6",S); }
private static void LOGE(String S) { Log.e("GL2JNIView-v6",S); }
public static class ContextFactory implements GLSurfaceView.EGLContextFactory
{
private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl,EGLDisplay display,EGLConfig eglConfig)
{
int[] attrList = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
LOGI("Creating OpenGL ES X context");
checkEglError("Before eglCreateContext",egl);
EGLContext context = egl.eglCreateContext(display,eglConfig,EGL10.EGL_NO_CONTEXT,attrList);
checkEglError("After eglCreateContext",egl);
return(context);
}
public void destroyContext(EGL10 egl,EGLDisplay display,EGLContext context)
{
LOGI("Destroying OpenGL ES X context");
egl.eglDestroyContext(display,context);
}
}
private static void checkEglError(String prompt,EGL10 egl)
{
int error;
while((error=egl.eglGetError()) != EGL14.EGL_SUCCESS)
LOGE(String.format("%s: EGL error: 0x%x",prompt,error));
}
public static class ConfigChooser implements GLSurfaceView.EGLConfigChooser
{
// Subclasses can adjust these values:
protected int mRedSize;
protected int mGreenSize;
protected int mBlueSize;
protected int mAlphaSize;
protected int mDepthSize;
protected int mStencilSize;
private int[] mValue = new int[1];
public ConfigChooser(int r,int g,int b,int a,int depth,int stencil)
{
mRedSize = r;
mGreenSize = g;
mBlueSize = b;
mAlphaSize = a;
mDepthSize = depth;
mStencilSize = stencil;
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
mValue = new int[1];
int glAPIToTry = EGLExt.EGL_OPENGL_ES3_BIT_KHR;
int[] configSpec = null;
do {
EGL14.eglBindAPI(glAPIToTry);
int renderableType;
if (glAPIToTry == EGLExt.EGL_OPENGL_ES3_BIT_KHR) {
renderableType = EGLExt.EGL_OPENGL_ES3_BIT_KHR;
// If this API does not work, try ES2 next.
glAPIToTry = EGL14.EGL_OPENGL_ES2_BIT;
} else {
renderableType = EGL14.EGL_OPENGL_ES2_BIT;
// If this API does not work, try ES next.
glAPIToTry = EGL14.EGL_OPENGL_ES_API;
}
configSpec = new int[] {
EGL14.EGL_RED_SIZE, 4,
EGL14.EGL_GREEN_SIZE, 4,
EGL14.EGL_BLUE_SIZE, 4,
EGL14.EGL_RENDERABLE_TYPE, renderableType,
EGL14.EGL_DEPTH_SIZE, 24,
EGL14.EGL_NONE
};
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
configSpec[9] = 16;
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
throw new IllegalArgumentException("Could not get context count");
}
}
} while (glAPIToTry != EGL14.EGL_OPENGL_ES_API && mValue[0]<=0);
if (mValue[0]<=0) {
throw new IllegalArgumentException("No configs match configSpec");
}
// Get all matching configurations.
EGLConfig[] configs = new EGLConfig[mValue[0]];
if (GL2JNIView.DEBUG)
LOGW(String.format("%d configurations", configs.length));
if (!egl.eglChooseConfig(display, configSpec, configs, mValue[0], mValue)) {
throw new IllegalArgumentException("Could not get config data");
}
for (int i = 0; i < configs.length; ++i) {
EGLConfig config = configs[i];
int d = findConfigAttrib(egl, display, config,
EGL14.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL14.EGL_STENCIL_SIZE, 0);
// We need at least mDepthSize and mStencilSize bits
if (d >= mDepthSize || s >= mStencilSize) {
// We want an *exact* match for red/green/blue/alpha
int r = findConfigAttrib(egl, display, config,
EGL14.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config,
EGL14.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config,
EGL14.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config,
EGL14.EGL_ALPHA_SIZE, 0);
if (r == mRedSize && g == mGreenSize && b == mBlueSize
&& a == mAlphaSize)
if (GL2JNIView.DEBUG) {
LOGW(String.format("Configuration %d:", i));
printConfig(egl, display, configs[i]);
}
return config;
}
}
throw new IllegalArgumentException("Could not find suitable EGL config");
}
private int findConfigAttrib(EGL10 egl,EGLDisplay display,EGLConfig config,int attribute,int defaultValue)
{
return(egl.eglGetConfigAttrib(display,config,attribute,mValue)? mValue[0] : defaultValue);
}
private void printConfig(EGL10 egl,EGLDisplay display,EGLConfig config)
{
final int[] attributes =
{
EGL14.EGL_BUFFER_SIZE,
EGL14.EGL_ALPHA_SIZE,
EGL14.EGL_BLUE_SIZE,
EGL14.EGL_GREEN_SIZE,
EGL14.EGL_RED_SIZE,
EGL14.EGL_DEPTH_SIZE,
EGL14.EGL_STENCIL_SIZE,
EGL14.EGL_CONFIG_CAVEAT,
EGL14.EGL_CONFIG_ID,
EGL14.EGL_LEVEL,
EGL14.EGL_MAX_PBUFFER_HEIGHT,
EGL14.EGL_MAX_PBUFFER_PIXELS,
EGL14.EGL_MAX_PBUFFER_WIDTH,
EGL14.EGL_NATIVE_RENDERABLE,
EGL14.EGL_NATIVE_VISUAL_ID,
EGL14.EGL_NATIVE_VISUAL_TYPE,
0x3030, // EGL14.EGL_PRESERVED_RESOURCES,
EGL14.EGL_SAMPLES,
EGL14.EGL_SAMPLE_BUFFERS,
EGL14.EGL_SURFACE_TYPE,
EGL14.EGL_TRANSPARENT_TYPE,
EGL14.EGL_TRANSPARENT_RED_VALUE,
EGL14.EGL_TRANSPARENT_GREEN_VALUE,
EGL14.EGL_TRANSPARENT_BLUE_VALUE,
0x3039, // EGL14.EGL_BIND_TO_TEXTURE_RGB,
0x303A, // EGL14.EGL_BIND_TO_TEXTURE_RGBA,
0x303B, // EGL14.EGL_MIN_SWAP_INTERVAL,
0x303C, // EGL14.EGL_MAX_SWAP_INTERVAL,
EGL14.EGL_LUMINANCE_SIZE,
EGL14.EGL_ALPHA_MASK_SIZE,
EGL14.EGL_COLOR_BUFFER_TYPE,
EGL14.EGL_RENDERABLE_TYPE,
0x3042 // EGL14.EGL_CONFORMANT
};
final String[] names =
{
"EGL_BUFFER_SIZE",
"EGL_ALPHA_SIZE",
"EGL_BLUE_SIZE",
"EGL_GREEN_SIZE",
"EGL_RED_SIZE",
"EGL_DEPTH_SIZE",
"EGL_STENCIL_SIZE",
"EGL_CONFIG_CAVEAT",
"EGL_CONFIG_ID",
"EGL_LEVEL",
"EGL_MAX_PBUFFER_HEIGHT",
"EGL_MAX_PBUFFER_PIXELS",
"EGL_MAX_PBUFFER_WIDTH",
"EGL_NATIVE_RENDERABLE",
"EGL_NATIVE_VISUAL_ID",
"EGL_NATIVE_VISUAL_TYPE",
"EGL_PRESERVED_RESOURCES",
"EGL_SAMPLES",
"EGL_SAMPLE_BUFFERS",
"EGL_SURFACE_TYPE",
"EGL_TRANSPARENT_TYPE",
"EGL_TRANSPARENT_RED_VALUE",
"EGL_TRANSPARENT_GREEN_VALUE",
"EGL_TRANSPARENT_BLUE_VALUE",
"EGL_BIND_TO_TEXTURE_RGB",
"EGL_BIND_TO_TEXTURE_RGBA",
"EGL_MIN_SWAP_INTERVAL",
"EGL_MAX_SWAP_INTERVAL",
"EGL_LUMINANCE_SIZE",
"EGL_ALPHA_MASK_SIZE",
"EGL_COLOR_BUFFER_TYPE",
"EGL_RENDERABLE_TYPE",
"EGL_CONFORMANT"
};
int[] value = new int[1];
for(int i=0 ; i<attributes.length ; i++)
if(egl.eglGetConfigAttrib(display,config,attributes[i],value))
LOGI(String.format(" %s: %d\n",names[i],value[0]));
else
while(egl.eglGetError()!=EGL14.EGL_SUCCESS);
}
}
}

View File

@ -6,7 +6,6 @@ package com.reicast.emulator;
import tv.ouya.console.api.OuyaController;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.widget.Toast;
@ -208,17 +207,10 @@ public class MOGAInput
for (int i = 0; i < map.length; i += 2) {
if (map[playerNum][i + 0] == event.getKeyCode()) {
if (MainActivity.force_gpu) {
if (event.getAction() == 0) //FIXME to const
GL2JNIViewV6.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIViewV6.kcode_raw[playerNum] |= map[playerNum][i + 1];
} else {
if (event.getAction() == 0) //FIXME to const
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
}
if (event.getAction() == 0) //FIXME to const
GL2JNIView.kcode_raw[playerNum] &= ~map[playerNum][i + 1];
else
GL2JNIView.kcode_raw[playerNum] |= map[playerNum][i + 1];
break;
}
}
@ -233,17 +225,10 @@ public class MOGAInput
globalLS_X[playerNum] = 0;
globalLS_Y[playerNum] = 0;
}
if (MainActivity.force_gpu) {
GL2JNIViewV6.lt[playerNum] = (int) (L2 * 255);
GL2JNIViewV6.rt[playerNum] = (int) (R2 * 255);
GL2JNIViewV6.jx[playerNum] = (int) (0 * 126);
GL2JNIViewV6.jy[playerNum] = (int) (0 * 126);
} else {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (0 * 126);
GL2JNIView.jy[playerNum] = (int) (0 * 126);
}
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (0 * 126);
GL2JNIView.jy[playerNum] = (int) (0 * 126);
}
public void onMotionEvent(MotionEvent event)
@ -270,19 +255,11 @@ public class MOGAInput
}
if (MainActivity.force_gpu) {
GL2JNIViewV6.lt[playerNum] = (int) (L2 * 255);
GL2JNIViewV6.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIViewV6.jx[playerNum] = (int) (S_X * 126);
GL2JNIViewV6.jy[playerNum] = (int) (S_Y * 126);
} else {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
GL2JNIView.jx[playerNum] = (int) (S_X * 126);
GL2JNIView.jy[playerNum] = (int) (S_Y * 126);
}
GL2JNIView.jx[playerNum] = (int) (S_X * 126);
GL2JNIView.jy[playerNum] = (int) (S_Y * 126);
/*
for(final Entry<Integer, ExampleFloat> entry : mMotions.entrySet())

View File

@ -23,6 +23,7 @@ public class OnScreenMenu {
private int frameskip;
private boolean widescreen;
private boolean limitframes;
private boolean audiodisabled;
private File sdcard = Environment.getExternalStorageDirectory();
private String home_directory = sdcard + "/dc";
@ -197,6 +198,27 @@ public class OnScreenMenu {
});
}
hlay.addView(framelimit, params);
View audiosetting;
if (!audiodisabled) {
audiosetting = addbut(R.drawable.mute_sound,
new OnClickListener() {
public void onClick(View v) {
mContext.mView.audioDisable(true);
popUpConfig.dismiss();
audiodisabled = true;
}
});
} else {
audiosetting = addbut(R.drawable.enable_sound,
new OnClickListener() {
public void onClick(View v) {
mContext.mView.audioDisable(false);
popUpConfig.dismiss();
audiodisabled = false;
}
});
}
hlay.addView(audiosetting, params);
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
public void onClick(View v) {
popUpConfig.dismiss();

View File

@ -0,0 +1,134 @@
package com.reicast.emulator;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class VJoy {
public static final int key_CONT_B = 0x0002;
public static final int key_CONT_A = 0x0004;
public static final int key_CONT_START = 0x0008;
public static final int key_CONT_DPAD_UP = 0x0010;
public static final int key_CONT_DPAD_DOWN = 0x0020;
public static final int key_CONT_DPAD_LEFT = 0x0040;
public static final int key_CONT_DPAD_RIGHT = 0x0080;
public static final int key_CONT_Y = 0x0200;
public static final int key_CONT_X = 0x0400;
public static final int LAYER_TYPE_SOFTWARE = 1;
public static final int LAYER_TYPE_HARDWARE = 2;
public static float[][] baseVJoy() {
return new float[][] {
new float[] { 24+0, 24+64, 64,64, VJoy.key_CONT_DPAD_LEFT, 0},
new float[] { 24+64, 24+0, 64,64, VJoy.key_CONT_DPAD_UP, 0},
new float[] { 24+128, 24+64, 64,64, VJoy.key_CONT_DPAD_RIGHT, 0},
new float[] { 24+64, 24+128, 64,64, VJoy.key_CONT_DPAD_DOWN, 0},
new float[] { 440+0, 280+64, 64,64, VJoy.key_CONT_X, 0},
new float[] { 440+64, 280+0, 64,64, VJoy.key_CONT_Y, 0},
new float[] { 440+128, 280+64, 64,64, VJoy.key_CONT_B, 0},
new float[] { 440+64, 280+128, 64,64, VJoy.key_CONT_A, 0},
new float[] { 320-32, 360+32, 64,64, VJoy.key_CONT_START, 0},
new float[] { 440, 200, 90,64, -1, 0},
new float[] { 542, 200, 90,64, -2, 0},
new float[] { 0, 128+224, 128,128, -3, 0},
new float[] { 96, 320, 32,32, -4, 0},
};
}
public static float[][] readCustomVjoyValues(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return new float[][] {
// x-shift, y-shift, sizing-factor
new float[] { prefs.getFloat("touch_x_shift_dpad", 0), prefs.getFloat("touch_y_shift_dpad", 0), prefs.getFloat("touch_scale_dpad", 1) }, // DPAD
new float[] { prefs.getFloat("touch_x_shift_buttons", 0), prefs.getFloat("touch_y_shift_buttons", 0), prefs.getFloat("touch_scale_buttons", 1) }, // X, Y, B, A Buttons
new float[] { prefs.getFloat("touch_x_shift_start", 0), prefs.getFloat("touch_y_shift_start", 0), prefs.getFloat("touch_scale_start", 1) }, // Start
new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0), prefs.getFloat("touch_y_shift_left_trigger", 0), prefs.getFloat("touch_scale_left_trigger", 1) }, // Left Trigger
new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0), prefs.getFloat("touch_y_shift_right_trigger", 0), prefs.getFloat("touch_scale_right_trigger", 1) }, // Right Trigger
new float[] { prefs.getFloat("touch_x_shift_analog", 0), prefs.getFloat("touch_y_shift_analog", 0), prefs.getFloat("touch_scale_analog", 1) } // Analog Stick
};
}
public static float[][] getVjoy_d(float[][] vjoy_d_custom) {
return new float[][] {
new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT},
new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_UP},
new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT},
new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_DOWN},
new float[] { 448+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_X},
new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_Y},
new float[] { 448+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_B},
new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_A},
new float[] { 320-32+vjoy_d_custom[2][0], 288+128+vjoy_d_custom[2][1], 64*vjoy_d_custom[2][2],64*vjoy_d_custom[2][2], key_CONT_START},
new float[] { 440+vjoy_d_custom[3][0], 200+vjoy_d_custom[3][1], 90*vjoy_d_custom[3][2],64*vjoy_d_custom[3][2], -1},
new float[] { 542+vjoy_d_custom[4][0], 200+vjoy_d_custom[4][1], 90*vjoy_d_custom[4][2],64*vjoy_d_custom[4][2], -2},
new float[] { 16+vjoy_d_custom[5][0], 24+32+vjoy_d_custom[5][1], 128*vjoy_d_custom[5][2],128*vjoy_d_custom[5][2], -3},
new float[] { 96+vjoy_d_custom[5][0], 320+vjoy_d_custom[5][1], 32*vjoy_d_custom[5][2],32*vjoy_d_custom[5][2], -4},
};
}
public static void writeCustomVjoyValues(float[][] vjoy_d_custom, Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putFloat("touch_x_shift_dpad", vjoy_d_custom[0][0]).commit();
prefs.edit().putFloat("touch_y_shift_dpad", vjoy_d_custom[0][1]).commit();
prefs.edit().putFloat("touch_scale_dpad", vjoy_d_custom[0][2]).commit();
prefs.edit().putFloat("touch_x_shift_buttons", vjoy_d_custom[1][0]).commit();
prefs.edit().putFloat("touch_y_shift_buttons", vjoy_d_custom[1][1]).commit();
prefs.edit().putFloat("touch_scale_buttons", vjoy_d_custom[1][2]).commit();
prefs.edit().putFloat("touch_x_shift_start", vjoy_d_custom[2][0]).commit();
prefs.edit().putFloat("touch_y_shift_start", vjoy_d_custom[2][1]).commit();
prefs.edit().putFloat("touch_scale_start", vjoy_d_custom[2][2]).commit();
prefs.edit().putFloat("touch_x_shift_left_trigger", vjoy_d_custom[3][0]).commit();
prefs.edit().putFloat("touch_y_shift_left_trigger", vjoy_d_custom[3][1]).commit();
prefs.edit().putFloat("touch_scale_left_trigger", vjoy_d_custom[3][2]).commit();
prefs.edit().putFloat("touch_x_shift_right_trigger", vjoy_d_custom[4][0]).commit();
prefs.edit().putFloat("touch_y_shift_right_trigger", vjoy_d_custom[4][1]).commit();
prefs.edit().putFloat("touch_scale_right_trigger", vjoy_d_custom[4][2]).commit();
prefs.edit().putFloat("touch_x_shift_analog", vjoy_d_custom[5][0]).commit();
prefs.edit().putFloat("touch_y_shift_analog", vjoy_d_custom[5][1]).commit();
prefs.edit().putFloat("touch_scale_analog", vjoy_d_custom[5][2]).commit();
}
public static void resetCustomVjoyValues(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().remove("touch_x_shift_dpad").commit();
prefs.edit().remove("touch_y_shift_dpad").commit();
prefs.edit().remove("touch_scale_dpad").commit();
prefs.edit().remove("touch_x_shift_buttons").commit();
prefs.edit().remove("touch_y_shift_buttons").commit();
prefs.edit().remove("touch_scale_buttons").commit();
prefs.edit().remove("touch_x_shift_start").commit();
prefs.edit().remove("touch_y_shift_start").commit();
prefs.edit().remove("touch_scale_start").commit();
prefs.edit().remove("touch_x_shift_left_trigger").commit();
prefs.edit().remove("touch_y_shift_left_trigger").commit();
prefs.edit().remove("touch_scale_left_trigger").commit();
prefs.edit().remove("touch_x_shift_right_trigger").commit();
prefs.edit().remove("touch_y_shift_right_trigger").commit();
prefs.edit().remove("touch_scale_right_trigger").commit();
prefs.edit().remove("touch_x_shift_analog").commit();
prefs.edit().remove("touch_y_shift_analog").commit();
prefs.edit().remove("touch_scale_analog").commit();
}
}