diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 6c47af8b3..8a2f119ad 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -374,7 +374,11 @@ public class GL2JNIActivity extends Activity { } } - mView.pushInput(); + if (MainActivity.force_gpu) { + mView6.pushInput(); + } else { + mView.pushInput(); + } 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))) // Only handle Left Stick on an Xbox 360 controller if there was @@ -489,7 +493,11 @@ public class GL2JNIActivity extends Activity { break; } } - mView.pushInput(); + if (MainActivity.force_gpu) { + mView6.pushInput(); + } else { + mView.pushInput(); + } return rav; } else { diff --git a/shell/android/src/com/reicast/emulator/GL2JNIView.java b/shell/android/src/com/reicast/emulator/GL2JNIView.java index 9ff4a700f..1586b5fd1 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIView.java @@ -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; @@ -56,18 +55,6 @@ class GL2JNIView extends GLSurfaceView 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; Vibrator vib; @@ -79,17 +66,17 @@ class GL2JNIView extends GLSurfaceView 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[] { 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, 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[] { 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, key_CONT_START, 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}, @@ -105,57 +92,6 @@ class GL2JNIView extends GLSurfaceView 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); @@ -206,7 +142,7 @@ class GL2JNIView extends GLSurfaceView 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(); @@ -356,7 +292,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 check for freed analog * */ int anal_id=-1, lt_id=-1, rt_id=-1; - /* - bool intersects(CircleType circle, RectType rect) - { - circleDistance.x = abs(circle.x - rect.x); - circleDistance.y = abs(circle.y - rect.y); - - if (circleDistance.x > (rect.width/2 + circle.r)) { return false; } - if (circleDistance.y > (rect.height/2 + circle.r)) { return false; } - - if (circleDistance.x <= (rect.width/2)) { return true; } - if (circleDistance.y <= (rect.height/2)) { return true; } - - cornerDistance_sq = (circleDistance.x - rect.width/2)^2 + - (circleDistance.y - rect.height/2)^2; - - return (cornerDistance_sq <= (circle.r^2)); - } - */ private void resetEditMode() { editLastX = 0; @@ -604,6 +514,7 @@ class GL2JNIViewV6 extends GLSurfaceView kcode_raw[0] = rv; jx[0] = get_anal(11, 0); jy[0] = get_anal(11, 1); + pushInput(); return(true); } @@ -766,17 +677,6 @@ private static class ContextFactory implements GLSurfaceView.EGLContextFactory { return(egl.eglGetConfigAttrib(display,config,attribute,mValue)? mValue[0] : defaultValue); } - - private void printConfigs(EGL10 egl,EGLDisplay display,EGLConfig[] configs) - { - LOGW(String.format("%d configurations",configs.length)); - - for(int i=0 ; i=8192)? AudioRate:8192; - Latency = AudioLatency>=50? AudioLatency:50; - Chunk = 2048; - Data = new short[Chunk*2]; - start(); - } - - public void stopPlayback() - { Rate=0; } - - public void pausePlayback(boolean Switch) - { - // Must have a valid player - if((Player==null) || (Player.getState()!=AudioTrack.STATE_INITIALIZED)) return; - - // Switch between playback and pause - if(Switch) { if(Player.getPlayState()==AudioTrack.PLAYSTATE_PLAYING) Player.pause(); } - else { if(Player.getPlayState()!=AudioTrack.PLAYSTATE_PLAYING) Player.play(); } - } - - @Override public void run() - { - int Size,Min; - - LOGI("Starting audio thread for Rate="+Rate+"Hz, Latency="+Latency+"ms"); - - // When no audio sampling rate supplied, do not play - if(Rate<=0) return; - - // Compute minimal and requested buffer sizes - Min = AudioTrack.getMinBufferSize(Rate,AudioFormat.CHANNEL_OUT_STEREO,AudioFormat.ENCODING_PCM_16BIT); - Size = 2*2*Chunk*2; - - // Create audio player - Player = new AudioTrack( - AudioManager.STREAM_MUSIC, - Rate, - AudioFormat.CHANNEL_OUT_STEREO, - AudioFormat.ENCODING_PCM_16BIT, - Min>Size? Min:Size, - AudioTrack.MODE_STREAM - ); - - // Start playback - Player.play(); - - // Continue writing data, until requested to quit - while(Rate>0) - { - //Size = JNIdc.play(Data,Chunk); - if(Size>0) Player.write(Data,0,2*Size); else yield(); - } - - // Stop playback - Player.stop(); - Player.flush(); - Player.release(); - - LOGI("Exiting audio thread"); - } - } public void onStop() { // TODO Auto-generated method stub diff --git a/shell/android/src/com/reicast/emulator/VJoy.java b/shell/android/src/com/reicast/emulator/VJoy.java new file mode 100644 index 000000000..a6fdeef2d --- /dev/null +++ b/shell/android/src/com/reicast/emulator/VJoy.java @@ -0,0 +1,72 @@ +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[][] 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(); + } +}