diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index 8d81fcf9c..b00702000 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -315,9 +315,10 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_run(JNIEnv *env,jobje jsamples=env->NewShortArray(SAMPLE_COUNT*2); writemid=env->GetMethodID(env->GetObjectClass(track),"WriteBuffer","([SI)I"); + //showMessageMid=env->GetMethodID(env->GetObjectClass(track),"WriteBuffer","([SI)I"); + //dieMid=env->GetMethodID(env->GetObjectClass(track),"Die","([SI)I"); dc_run(); - } JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,jobject obj,jobject sip) diff --git a/shell/android/src/com/reicast/emulator/FileBrowser.java b/shell/android/src/com/reicast/emulator/FileBrowser.java index 80347ba2f..cb5095ecb 100644 --- a/shell/android/src/com/reicast/emulator/FileBrowser.java +++ b/shell/android/src/com/reicast/emulator/FileBrowser.java @@ -66,11 +66,6 @@ public class FileBrowser extends Fragment { super.onCreate(savedInstanceState); mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - sdcard = getActivity().getExternalFilesDir(null); - home_directory = sdcard + "/dc"; - game_directory = sdcard + "/dc"; - } home_directory = mPrefs.getString(Config.pref_home, home_directory); game_directory = mPrefs.getString(Config.pref_games, game_directory); diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index beef10062..b180bea4e 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -282,10 +282,10 @@ public class GL2JNIActivity extends Activity { GL2JNIView.rt[playerNum] = (int) (R2 * 255); if (prefs.getBoolean("right_buttons", true)) { - if (RS_Y > 0.5) { + if (RS_Y > 0.25) { handle_key(playerNum, pad.map[playerNum][0]/* A */, true); pad.wasKeyStick[playerNum] = true; - } else if (RS_Y < 0.5) { + } else if (RS_Y < 0.25) { handle_key(playerNum, pad.map[playerNum][1]/* B */, true); pad.wasKeyStick[playerNum] = true; } else if (pad.wasKeyStick[playerNum]){ @@ -294,10 +294,10 @@ public class GL2JNIActivity extends Activity { pad.wasKeyStick[playerNum] = false; } } else { - if (RS_Y > 0.5) { + if (RS_Y > 0.25) { GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); GL2JNIView.lt[playerNum] = (int) (L2 * 255); - } else if (RS_Y < 0.5) { + } else if (RS_Y < 0.25) { GL2JNIView.rt[playerNum] = (int) (R2 * 255); GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); } diff --git a/shell/android/src/com/reicast/emulator/GL2JNINative.java b/shell/android/src/com/reicast/emulator/GL2JNINative.java index 7c8bcb6f7..8d69f40cc 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNINative.java +++ b/shell/android/src/com/reicast/emulator/GL2JNINative.java @@ -372,10 +372,10 @@ public class GL2JNINative extends NativeActivity { GL2JNIView.rt[playerNum] = (int) (R2 * 255); if (prefs.getBoolean("right_buttons", true)) { - if (RS_Y > 0.5) { + if (RS_Y > 0.25) { handle_key(playerNum, pad.map[playerNum][0]/* A */, true); pad.wasKeyStick[playerNum] = true; - } else if (RS_Y < 0.5) { + } else if (RS_Y < 0.25) { handle_key(playerNum, pad.map[playerNum][1]/* B */, true); pad.wasKeyStick[playerNum] = true; } else if (pad.wasKeyStick[playerNum]){ @@ -384,10 +384,10 @@ public class GL2JNINative extends NativeActivity { pad.wasKeyStick[playerNum] = false; } } else { - if (RS_Y > 0.5) { + if (RS_Y > 0.25) { GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); GL2JNIView.lt[playerNum] = (int) (L2 * 255); - } else if (RS_Y < 0.5) { + } else if (RS_Y < 0.25) { GL2JNIView.rt[playerNum] = (int) (R2 * 255); GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); } diff --git a/shell/android/src/com/reicast/emulator/config/OptionsFragment.java b/shell/android/src/com/reicast/emulator/config/OptionsFragment.java index 4c76beef4..8c3985152 100644 --- a/shell/android/src/com/reicast/emulator/config/OptionsFragment.java +++ b/shell/android/src/com/reicast/emulator/config/OptionsFragment.java @@ -1,12 +1,10 @@ package com.reicast.emulator.config; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.channels.FileChannel; import android.app.Activity; import android.content.SharedPreferences; @@ -85,11 +83,6 @@ public class OptionsFragment extends Fragment { // setContentView(R.layout.activity_main); //parentActivity = getActivity(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - sdcard = getActivity().getExternalFilesDir(null); - home_directory = sdcard + "/dc"; - game_directory = sdcard + "/dc"; - } mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); @@ -124,11 +117,6 @@ public class OptionsFragment extends Fragment { Toast.makeText(getActivity(), R.string.data_folder, Toast.LENGTH_SHORT).show(); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - cleanHouse(getActivity().getExternalFilesDir(null)); - buildHouse(new File(home_directory), getActivity().getExternalFilesDir(null)); - home_directory = sdcard + "/dc"; - } mPrefs.edit().putString("home_directory", home_directory) .commit(); } @@ -518,43 +506,6 @@ public class OptionsFragment extends Fragment { }); } - private void cleanHouse(File dir) { - File[] existing = dir.listFiles(); - for (File item: existing) { - if (item.isDirectory()) { - cleanHouse(item); - } else { - item.delete(); - } - } - } - - private void buildHouse(File dir, File root) { - File[] existing = dir.listFiles(); - for (File item: existing) { - if (item.isDirectory()) { - item.mkdirs(); - buildHouse(item, item); - } else { - try { - copy(item, new File(root + "/" + item)); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public void copy(File src, File dst) throws IOException { - FileInputStream inStream = new FileInputStream(src); - FileOutputStream outStream = new FileOutputStream(dst); - FileChannel inChannel = inStream.getChannel(); - FileChannel outChannel = outStream.getChannel(); - inChannel.transferTo(0, inChannel.size(), outChannel); - inStream.close(); - outStream.close(); - } - private void flashBios(String localized) { File local = new File(home_directory, "data/dc_flash[" + localized + "].bin"); diff --git a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java index ae64512ad..45c4f9480 100644 --- a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java @@ -291,7 +291,7 @@ public class GL2JNIView extends GLSurfaceView vjoy[i][3] = vbase(vjoy_d[i][3],scl); } - for(int i=0;ivjoy[j][0] && x<=(vjoy[j][0]+vjoy[j][2])) { - int pre=(int)(event.getPressure(i)*255); - if (pre>20) - { - pre-=20; - pre*=7; - } - if (pre>255) pre=255; + /* + //Disable pressure sensitive R/L + //Doesn't really work properly + + int pre=(int)(event.getPressure(i)*255); + if (pre>20) + { + pre-=20; + pre*=7; + } + if (pre>255) pre=255; + */ + + int pre = 255; if(y>vjoy[j][1] && y<=(vjoy[j][1]+vjoy[j][3])) { @@ -564,7 +571,8 @@ public class GL2JNIView extends GLSurfaceView public void onSurfaceChanged(GL10 gl,int width,int height) { - JNIdc.rendinit(sWidth,sHeight); + gl.glViewport(0, 0, width, height); + JNIdc.rendinit(width,height); } public void onSurfaceCreated(GL10 gl,EGLConfig config) @@ -673,6 +681,44 @@ public class GL2JNIView extends GLSurfaceView } } + void showMessage(String msg) { + /* + activity.runOnUiThread(new Runnable() { + public void run() { + + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( + context); + + // set title + alertDialogBuilder.setTitle("Ooops"); + + // set dialog message + alertDialogBuilder + .setMessage(msg) + .setCancelable(false) + .setPositiveButton("Okay...",new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog,int id) { + // if this button is clicked, close + // current activity + MainActivity.this.finish(); + } + }); + + // create alert dialog + AlertDialog alertDialog = alertDialogBuilder.create(); + + // show it + alertDialog.show(); + } + }); + */ + } + + void die() { + showMessage("Something went very bad. Please report this on the reicast forums."); + onStop(); + } + public void onStop() { // TODO Auto-generated method stub System.exit(0); diff --git a/shell/android/src/com/reicast/emulator/periph/VJoy.java b/shell/android/src/com/reicast/emulator/periph/VJoy.java index d7ff9e6c1..431644d76 100644 --- a/shell/android/src/com/reicast/emulator/periph/VJoy.java +++ b/shell/android/src/com/reicast/emulator/periph/VJoy.java @@ -19,6 +19,8 @@ public class VJoy { public static final int LAYER_TYPE_SOFTWARE = 1; public static final int LAYER_TYPE_HARDWARE = 2; + public static int VJoyCount = 13; + public static float[][] baseVJoy() { return new float[][] { new float[] { 24+0, 24+64, 64,64, VJoy.key_CONT_DPAD_LEFT, 0}, @@ -38,6 +40,11 @@ public class VJoy { new float[] { 0, 128+224, 128,128, -3, 0}, new float[] { 96, 320, 32,32, -4, 0}, + + new float[] { 20+0 , 288+0 , 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_UP, 0}, + new float[] { 20+128, 288+0 , 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_UP, 0}, + new float[] { 20+0 , 288+128, 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_DOWN, 0}, + new float[] { 20+128, 288+128, 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_DOWN, 0}, }; } @@ -73,6 +80,11 @@ public class VJoy { 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}, + + new float[] { 20+0*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_LEFT|key_CONT_DPAD_UP}, + new float[] { 20+128*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_RIGHT|key_CONT_DPAD_UP}, + new float[] { 20+0*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_LEFT|key_CONT_DPAD_DOWN}, + new float[] { 20+128*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_RIGHT|key_CONT_DPAD_DOWN}, }; }