Merge pull request #272 from LoungeKatt/master
A very solid collaborative menu implementation
This commit is contained in:
commit
10b9df33ea
|
@ -311,14 +311,6 @@ public class ConfigureFragment extends Fragment {
|
||||||
int count) {
|
int count) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button debug_button = (Button) getView()
|
|
||||||
.findViewById(R.id.debug_button);
|
|
||||||
debug_button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
generateErrorLog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateErrorLog() {
|
public void generateErrorLog() {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import com.reicast.emulator.R;
|
||||||
import com.reicast.emulator.emu.GL2JNIView;
|
import com.reicast.emulator.emu.GL2JNIView;
|
||||||
import com.reicast.emulator.emu.JNIdc;
|
import com.reicast.emulator.emu.JNIdc;
|
||||||
import com.reicast.emulator.emu.OnScreenMenu;
|
import com.reicast.emulator.emu.OnScreenMenu;
|
||||||
import com.reicast.emulator.emu.VJoy;
|
import com.reicast.emulator.periph.VJoy;
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||||
public class EditVJoyActivity extends Activity {
|
public class EditVJoyActivity extends Activity {
|
||||||
|
@ -127,7 +127,11 @@ public class EditVJoyActivity extends Activity {
|
||||||
if (keyCode == KeyEvent.KEYCODE_MENU
|
if (keyCode == KeyEvent.KEYCODE_MENU
|
||||||
|| keyCode == KeyEvent.KEYCODE_BACK) {
|
|| keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (!popUp.isShowing()) {
|
if (!popUp.isShowing()) {
|
||||||
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
|
||||||
|
} else {
|
||||||
|
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
|
||||||
|
}
|
||||||
popUp.update(LayoutParams.WRAP_CONTENT,
|
popUp.update(LayoutParams.WRAP_CONTENT,
|
||||||
LayoutParams.WRAP_CONTENT);
|
LayoutParams.WRAP_CONTENT);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.bda.controller.MotionEvent;
|
||||||
import com.bda.controller.StateEvent;
|
import com.bda.controller.StateEvent;
|
||||||
import com.reicast.emulator.MainActivity;
|
import com.reicast.emulator.MainActivity;
|
||||||
import com.reicast.emulator.R;
|
import com.reicast.emulator.R;
|
||||||
import com.reicast.emulator.emu.MOGAInput;
|
import com.reicast.emulator.periph.MOGAInput;
|
||||||
|
|
||||||
import de.ankri.views.Switch;
|
import de.ankri.views.Switch;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -60,7 +61,10 @@ public class InputModFragment extends Fragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
parentActivity = getActivity();
|
parentActivity = getActivity();
|
||||||
|
|
||||||
System.gc();
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
Runtime.getRuntime().freeMemory();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
|
||||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
|
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
|
||||||
|
|
||||||
|
@ -387,7 +391,10 @@ public class InputModFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getButtonImage(int x, int y) {
|
private Drawable getButtonImage(int x, int y) {
|
||||||
System.gc();
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
Runtime.getRuntime().freeMemory();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
InputStream bitmap = parentActivity.getAssets().open("buttons.png");
|
InputStream bitmap = parentActivity.getAssets().open("buttons.png");
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
|
@ -395,7 +402,10 @@ public class InputModFragment extends Fragment {
|
||||||
Bitmap image = BitmapFactory.decodeStream(bitmap, null, options);
|
Bitmap image = BitmapFactory.decodeStream(bitmap, null, options);
|
||||||
bitmap.close();
|
bitmap.close();
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
System.gc();
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
Runtime.getRuntime().freeMemory();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.postScale(32, 32);
|
matrix.postScale(32, 32);
|
||||||
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64 / sS,
|
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64 / sS,
|
||||||
|
@ -412,7 +422,10 @@ public class InputModFragment extends Fragment {
|
||||||
return getButtonImage(x, y);
|
return getButtonImage(x, y);
|
||||||
} else {
|
} else {
|
||||||
E.printStackTrace();
|
E.printStackTrace();
|
||||||
System.gc();
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
Runtime.getRuntime().freeMemory();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parentActivity.getResources().getDrawable(R.drawable.input);
|
return parentActivity.getResources().getDrawable(R.drawable.input);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.reicast.emulator.emu;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import tv.ouya.console.api.OuyaController;
|
import tv.ouya.console.api.OuyaController;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
@ -10,7 +9,6 @@ import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -22,17 +20,23 @@ import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.reicast.emulator.R;
|
import com.reicast.emulator.R;
|
||||||
import com.reicast.emulator.config.ConfigureFragment;
|
import com.reicast.emulator.config.ConfigureFragment;
|
||||||
|
import com.reicast.emulator.emu.OnScreenMenu.MainPopup;
|
||||||
|
import com.reicast.emulator.emu.OnScreenMenu.VmuPopup;
|
||||||
|
import com.reicast.emulator.periph.MOGAInput;
|
||||||
|
import com.reicast.emulator.periph.SipEmulator;
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||||
public class GL2JNIActivity extends Activity {
|
public class GL2JNIActivity extends Activity {
|
||||||
public GL2JNIView mView;
|
public GL2JNIView mView;
|
||||||
OnScreenMenu menu;
|
OnScreenMenu menu;
|
||||||
PopupWindow popUp;
|
MainPopup popUp;
|
||||||
|
VmuPopup vmuPop;
|
||||||
MOGAInput moga = new MOGAInput();
|
MOGAInput moga = new MOGAInput();
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
static String[] portId = { "_A", "_B", "_C", "_D" };
|
static String[] portId = { "_A", "_B", "_C", "_D" };
|
||||||
|
@ -58,7 +62,6 @@ public class GL2JNIActivity extends Activity {
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
ConfigureFragment.getCurrentConfiguration(prefs);
|
ConfigureFragment.getCurrentConfiguration(prefs);
|
||||||
menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
|
menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
|
||||||
popUp = menu.createPopup();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* try { //int rID =
|
* try { //int rID =
|
||||||
|
@ -282,9 +285,20 @@ public class GL2JNIActivity extends Activity {
|
||||||
JNIdc.setupMic(sip);
|
JNIdc.setupMic(sip);
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup vmu screen
|
popUp = menu.new MainPopup(this);
|
||||||
JNIdc.setupVmu(menu.getVmuLcd());
|
vmuPop = menu.new VmuPopup(this);
|
||||||
|
if(prefs.getBoolean("vmu_floating", false)){
|
||||||
|
//kind of a hack - if the user last had the vmu on screen
|
||||||
|
//inverse it and then "toggle"
|
||||||
|
prefs.edit().putBoolean("vmu_floating", false).commit();
|
||||||
|
//can only display a popup after onCreate
|
||||||
|
mView.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
toggleVmu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
JNIdc.setupVmu(menu.getVmu());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runCompatibilityMode() {
|
private void runCompatibilityMode() {
|
||||||
|
@ -499,6 +513,30 @@ public class GL2JNIActivity extends Activity {
|
||||||
LayoutParams.WRAP_CONTENT);
|
LayoutParams.WRAP_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void toggleVmu() {
|
||||||
|
boolean showFloating = !prefs.getBoolean("vmu_floating", false);
|
||||||
|
if(showFloating){
|
||||||
|
if(popUp.isShowing()){
|
||||||
|
popUp.dismiss();
|
||||||
|
}
|
||||||
|
//remove from popup menu
|
||||||
|
LinearLayout parent = (LinearLayout) popUp.getContentView();
|
||||||
|
parent.removeView(menu.getVmu());
|
||||||
|
//add to floating window
|
||||||
|
vmuPop.showVmu();
|
||||||
|
vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 20, 20);
|
||||||
|
vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||||
|
}else{
|
||||||
|
vmuPop.dismiss();
|
||||||
|
//remove from floating window
|
||||||
|
LinearLayout parent = (LinearLayout) vmuPop.getContentView();
|
||||||
|
parent.removeView(menu.getVmu());
|
||||||
|
//add back to popup menu
|
||||||
|
popUp.showVmu();
|
||||||
|
}
|
||||||
|
prefs.edit().putBoolean("vmu_floating", showFloating).commit();
|
||||||
|
}
|
||||||
|
|
||||||
public void displayConfig(PopupWindow popUpConfig) {
|
public void displayConfig(PopupWindow popUpConfig) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
|
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
|
||||||
|
@ -567,11 +605,13 @@ public class GL2JNIActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showMenu() {
|
private boolean showMenu() {
|
||||||
if (!popUp.isShowing()) {
|
if (popUp != null) {
|
||||||
displayPopUp(popUp);
|
|
||||||
} else {
|
|
||||||
if (!menu.dismissPopUps()) {
|
if (!menu.dismissPopUps()) {
|
||||||
popUp.dismiss();
|
if (!popUp.isShowing()) {
|
||||||
|
displayPopUp(popUp);
|
||||||
|
} else {
|
||||||
|
popUp.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.reicast.emulator.MainActivity;
|
import com.reicast.emulator.MainActivity;
|
||||||
|
import com.reicast.emulator.periph.VJoy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +104,10 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
|
|
||||||
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
|
||||||
System.gc();
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
Runtime.getRuntime().freeMemory();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean soundEndabled = prefs.getBoolean("sound_enabled", true);
|
boolean soundEndabled = prefs.getBoolean("sound_enabled", true);
|
||||||
|
@ -182,7 +186,6 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
//configAudio(44100,250);
|
//configAudio(44100,250);
|
||||||
|
|
||||||
ethd.start();
|
ethd.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GLSurfaceView.Renderer getRenderer()
|
public GLSurfaceView.Renderer getRenderer()
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class JNIdc
|
||||||
public static native void cable(int cable);
|
public static native void cable(int cable);
|
||||||
public static native void region(int region);
|
public static native void region(int region);
|
||||||
public static native void broadcast(int broadcast);
|
public static native void broadcast(int broadcast);
|
||||||
public static native void limitfps(int stretch);
|
public static native void limitfps(int limiter);
|
||||||
public static native void nobatch(int nobatch);
|
public static native void nobatch(int nobatch);
|
||||||
public static native void mipmaps(int mipmaps);
|
public static native void mipmaps(int mipmaps);
|
||||||
public static native void widescreen(int stretch);
|
public static native void widescreen(int stretch);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
|
@ -19,16 +20,19 @@ import android.widget.PopupWindow;
|
||||||
import com.reicast.emulator.MainActivity;
|
import com.reicast.emulator.MainActivity;
|
||||||
import com.reicast.emulator.R;
|
import com.reicast.emulator.R;
|
||||||
import com.reicast.emulator.config.ConfigureFragment;
|
import com.reicast.emulator.config.ConfigureFragment;
|
||||||
|
import com.reicast.emulator.periph.VmuLcd;
|
||||||
|
|
||||||
public class OnScreenMenu {
|
public class OnScreenMenu {
|
||||||
|
|
||||||
private GL2JNIActivity mContext;
|
private GL2JNIActivity mContext;
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
LayoutParams params;
|
private LinearLayout hlay;
|
||||||
|
private LayoutParams params;
|
||||||
private int frameskip;
|
private int frameskip;
|
||||||
private boolean widescreen;
|
private boolean widescreen;
|
||||||
private boolean limitframes;
|
private boolean limitframes;
|
||||||
private boolean audiodisabled;
|
private boolean audiodisabled;
|
||||||
|
|
||||||
private VmuLcd vmuLcd;
|
private VmuLcd vmuLcd;
|
||||||
|
|
||||||
private Vector<PopupWindow> popups;
|
private Vector<PopupWindow> popups;
|
||||||
|
@ -47,243 +51,206 @@ public class OnScreenMenu {
|
||||||
widescreen = ConfigureFragment.widescreen;
|
widescreen = ConfigureFragment.widescreen;
|
||||||
frameskip = ConfigureFragment.frameskip;
|
frameskip = ConfigureFragment.frameskip;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public PopupWindow createPopup() {
|
|
||||||
final PopupWindow popUp = new PopupWindow(mContext);
|
|
||||||
|
|
||||||
int p = getPixelsFromDp(60, mContext);
|
|
||||||
params = new LayoutParams(p, p);
|
|
||||||
|
|
||||||
LinearLayout hlay = new LinearLayout(mContext);
|
|
||||||
|
|
||||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
popups.remove(popUp);
|
|
||||||
popUp.dismiss();
|
|
||||||
}
|
|
||||||
}), params);
|
|
||||||
|
|
||||||
vmuLcd = new VmuLcd(mContext);
|
vmuLcd = new VmuLcd(mContext);
|
||||||
hlay.addView(vmuLcd, params);
|
vmuLcd.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.vmu_swap, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
JNIdc.vmuSwap();
|
OnScreenMenu.this.mContext.toggleVmu();
|
||||||
popUp.dismiss();
|
|
||||||
}
|
}
|
||||||
}), params);
|
});
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.config, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
displayConfigPopup(popUp);
|
|
||||||
popups.remove(popUp);
|
|
||||||
popUp.dismiss();
|
|
||||||
}
|
|
||||||
}), params);
|
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.disk_unknown, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
displayDebugPopup(popUp);
|
|
||||||
popups.remove(popUp);
|
|
||||||
popUp.dismiss();
|
|
||||||
}
|
|
||||||
}), params);
|
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent inte = new Intent(mContext, MainActivity.class);
|
|
||||||
mContext.startActivity(inte);
|
|
||||||
((Activity) mContext).finish();
|
|
||||||
}
|
|
||||||
}), params);
|
|
||||||
|
|
||||||
// layout.addView(hlay,params);
|
|
||||||
popUp.setContentView(hlay);
|
|
||||||
return popUp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayDebugPopup(final PopupWindow popUp) {
|
void displayDebugPopup(final PopupWindow popUp) {
|
||||||
final PopupWindow popUpDebug = new PopupWindow(mContext);
|
mContext.displayDebug(new DebugPopup(mContext));
|
||||||
|
}
|
||||||
|
|
||||||
int p = getPixelsFromDp(60, mContext);
|
public class DebugPopup extends PopupWindow {
|
||||||
LayoutParams debugParams = new LayoutParams(p, p);
|
|
||||||
|
|
||||||
LinearLayout hlay = new LinearLayout(mContext);
|
public DebugPopup(Context c) {
|
||||||
|
|
||||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
int p = getPixelsFromDp(60, mContext);
|
||||||
|
LayoutParams debugParams = new LayoutParams(p, p);
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
LinearLayout hlay = new LinearLayout(mContext);
|
||||||
public void onClick(View v) {
|
|
||||||
popups.remove(popUpDebug);
|
|
||||||
popUpDebug.dismiss();
|
|
||||||
mContext.displayPopUp(popUp);
|
|
||||||
}
|
|
||||||
}), debugParams);
|
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.clear_cache, new OnClickListener() {
|
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
public void onClick(View v) {
|
|
||||||
JNIdc.send(0, 0); // Killing texture cache
|
|
||||||
popUpDebug.dismiss();
|
|
||||||
}
|
|
||||||
}), debugParams);
|
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
JNIdc.send(1, 3000); // sample_Start(param);
|
popups.remove(this);
|
||||||
popUpDebug.dismiss();
|
dismiss();
|
||||||
}
|
mContext.displayPopUp(OnScreenMenu.this.mContext.popUp);
|
||||||
}), debugParams);
|
}
|
||||||
|
}), debugParams);
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
hlay.addView(addbut(R.drawable.clear_cache, new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
JNIdc.send(1, 0); // sample_Start(param);
|
JNIdc.send(0, 0); // Killing texture cache
|
||||||
popUpDebug.dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
}), debugParams);
|
}), debugParams);
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.print_stats, new OnClickListener() {
|
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
JNIdc.send(0, 2);
|
JNIdc.send(1, 3000); // sample_Start(param);
|
||||||
popUpDebug.dismiss(); // print_stats=true;
|
dismiss();
|
||||||
}
|
}
|
||||||
}), debugParams);
|
}), debugParams);
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
popups.remove(popUpDebug);
|
JNIdc.send(1, 0); // sample_Start(param);
|
||||||
popUpDebug.dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
}), debugParams);
|
}), debugParams);
|
||||||
|
|
||||||
popUpDebug.setContentView(hlay);
|
hlay.addView(addbut(R.drawable.print_stats, new OnClickListener() {
|
||||||
popups.add(popUpDebug);
|
public void onClick(View v) {
|
||||||
mContext.displayDebug(popUpDebug);
|
JNIdc.send(0, 2);
|
||||||
|
dismiss(); // print_stats=true;
|
||||||
|
}
|
||||||
|
}), debugParams);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
popups.remove(this);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), debugParams);
|
||||||
|
|
||||||
|
setContentView(hlay);
|
||||||
|
popups.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayConfigPopup(final PopupWindow popUp) {
|
void displayConfigPopup(final PopupWindow popUp) {
|
||||||
final PopupWindow popUpConfig = new PopupWindow(mContext);
|
mContext.displayConfig(new ConfigPopup(mContext));
|
||||||
|
}
|
||||||
|
|
||||||
int p = getPixelsFromDp(60, mContext);
|
public class ConfigPopup extends PopupWindow {
|
||||||
LayoutParams configParams = new LayoutParams(p, p);
|
|
||||||
|
|
||||||
LinearLayout hlay = new LinearLayout(mContext);
|
private View fullscreen;
|
||||||
|
private View framelimit;
|
||||||
|
|
||||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
public ConfigPopup(Context c) {
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
int p = getPixelsFromDp(60, mContext);
|
||||||
public void onClick(View v) {
|
LayoutParams configParams = new LayoutParams(p, p);
|
||||||
popups.remove(popUpConfig);
|
|
||||||
popUpConfig.dismiss();
|
|
||||||
mContext.displayPopUp(popUp);
|
|
||||||
}
|
|
||||||
}), configParams);
|
|
||||||
|
|
||||||
View fullscreen;
|
LinearLayout hlay = new LinearLayout(mContext);
|
||||||
if (!widescreen) {
|
|
||||||
fullscreen = addbut(R.drawable.widescreen, new OnClickListener() {
|
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
JNIdc.widescreen(1);
|
popups.remove(this);
|
||||||
popUpConfig.dismiss();
|
dismiss();
|
||||||
widescreen = true;
|
mContext.displayPopUp(OnScreenMenu.this.mContext.popUp);
|
||||||
}
|
}
|
||||||
});
|
}), configParams);
|
||||||
} else {
|
|
||||||
fullscreen = addbut(R.drawable.normal_view, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
JNIdc.widescreen(0);
|
|
||||||
popUpConfig.dismiss();
|
|
||||||
widescreen = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
hlay.addView(fullscreen, params);
|
|
||||||
|
|
||||||
final ImageButton frames_up = new ImageButton(mContext);
|
if (!widescreen) {
|
||||||
final ImageButton frames_down = new ImageButton(mContext);
|
fullscreen = addbut(R.drawable.widescreen,
|
||||||
|
|
||||||
frames_up.setImageResource(R.drawable.frames_up);
|
|
||||||
frames_up.setScaleType(ScaleType.FIT_CENTER);
|
|
||||||
frames_up.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
frameskip++;
|
|
||||||
JNIdc.frameskip(frameskip);
|
|
||||||
enableState(frames_up, frames_down);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frames_down.setImageResource(R.drawable.frames_down);
|
|
||||||
frames_down.setScaleType(ScaleType.FIT_CENTER);
|
|
||||||
frames_down.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
frameskip--;
|
|
||||||
JNIdc.frameskip(frameskip);
|
|
||||||
enableState(frames_up, frames_down);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
hlay.addView(frames_up, params);
|
|
||||||
hlay.addView(frames_down, params);
|
|
||||||
enableState(frames_up, frames_down);
|
|
||||||
|
|
||||||
View framelimit;
|
|
||||||
if (!limitframes) {
|
|
||||||
framelimit = addbut(R.drawable.frames_limit_on,
|
|
||||||
new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
JNIdc.limitfps(1);
|
|
||||||
popUpConfig.dismiss();
|
|
||||||
limitframes = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
framelimit = addbut(R.drawable.frames_limit_off,
|
|
||||||
new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
JNIdc.limitfps(0);
|
|
||||||
popUpConfig.dismiss();
|
|
||||||
limitframes = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
hlay.addView(framelimit, params);
|
|
||||||
|
|
||||||
if (prefs.getBoolean("sound_enabled", true)) {
|
|
||||||
View audiosetting;
|
|
||||||
if (!audiodisabled) {
|
|
||||||
audiosetting = addbut(R.drawable.mute_sound,
|
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mContext.mView.audioDisable(true);
|
JNIdc.widescreen(1);
|
||||||
popUpConfig.dismiss();
|
dismiss();
|
||||||
audiodisabled = true;
|
widescreen = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
audiosetting = addbut(R.drawable.enable_sound,
|
fullscreen = addbut(R.drawable.normal_view,
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mContext.mView.audioDisable(false);
|
JNIdc.widescreen(0);
|
||||||
popUpConfig.dismiss();
|
dismiss();
|
||||||
audiodisabled = false;
|
widescreen = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hlay.addView(audiosetting, params);
|
hlay.addView(fullscreen, params);
|
||||||
|
|
||||||
|
final ImageButton frames_up = new ImageButton(mContext);
|
||||||
|
final ImageButton frames_down = new ImageButton(mContext);
|
||||||
|
|
||||||
|
frames_up.setImageResource(R.drawable.frames_up);
|
||||||
|
frames_up.setScaleType(ScaleType.FIT_CENTER);
|
||||||
|
frames_up.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
frameskip++;
|
||||||
|
JNIdc.frameskip(frameskip);
|
||||||
|
enableState(frames_up, frames_down);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
frames_down.setImageResource(R.drawable.frames_down);
|
||||||
|
frames_down.setScaleType(ScaleType.FIT_CENTER);
|
||||||
|
frames_down.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
frameskip--;
|
||||||
|
JNIdc.frameskip(frameskip);
|
||||||
|
enableState(frames_up, frames_down);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
hlay.addView(frames_up, params);
|
||||||
|
hlay.addView(frames_down, params);
|
||||||
|
enableState(frames_up, frames_down);
|
||||||
|
|
||||||
|
if (!limitframes) {
|
||||||
|
framelimit = addbut(R.drawable.frames_limit_on,
|
||||||
|
new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
JNIdc.limitfps(1);
|
||||||
|
dismiss();
|
||||||
|
limitframes = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
framelimit = addbut(R.drawable.frames_limit_off,
|
||||||
|
new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
JNIdc.limitfps(0);
|
||||||
|
dismiss();
|
||||||
|
limitframes = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hlay.addView(framelimit, params);
|
||||||
|
|
||||||
|
if (prefs.getBoolean("sound_enabled", true)) {
|
||||||
|
View audiosetting;
|
||||||
|
if (!audiodisabled) {
|
||||||
|
audiosetting = addbut(R.drawable.mute_sound,
|
||||||
|
new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mContext.mView.audioDisable(true);
|
||||||
|
dismiss();
|
||||||
|
audiodisabled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
audiosetting = addbut(R.drawable.enable_sound,
|
||||||
|
new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mContext.mView.audioDisable(false);
|
||||||
|
dismiss();
|
||||||
|
audiodisabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hlay.addView(audiosetting, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
popups.remove(this);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), configParams);
|
||||||
|
|
||||||
|
setContentView(hlay);
|
||||||
|
popups.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
popups.remove(popUpConfig);
|
|
||||||
popUpConfig.dismiss();
|
|
||||||
}
|
|
||||||
}), configParams);
|
|
||||||
|
|
||||||
popUpConfig.setContentView(hlay);
|
|
||||||
popups.add(popUpConfig);
|
|
||||||
mContext.displayConfig(popUpConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableState(View frames_up, View frames_down) {
|
private void enableState(View frames_up, View frames_down) {
|
||||||
|
@ -314,6 +281,10 @@ public class OnScreenMenu {
|
||||||
return (int) (dps * context.getResources().getDisplayMetrics().density + 0.5f);
|
return (int) (dps * context.getResources().getDisplayMetrics().density + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VmuLcd getVmu() {
|
||||||
|
return vmuLcd;
|
||||||
|
}
|
||||||
|
|
||||||
View addbut(int x, OnClickListener ocl) {
|
View addbut(int x, OnClickListener ocl) {
|
||||||
ImageButton but = new ImageButton(mContext);
|
ImageButton but = new ImageButton(mContext);
|
||||||
|
|
||||||
|
@ -324,7 +295,87 @@ public class OnScreenMenu {
|
||||||
return but;
|
return but;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VmuLcd getVmuLcd(){
|
public class VmuPopup extends PopupWindow {
|
||||||
return vmuLcd;
|
LayoutParams vparams;
|
||||||
|
LinearLayout vlay;
|
||||||
|
|
||||||
|
public VmuPopup(Context c) {
|
||||||
|
super(c);
|
||||||
|
int pX = OnScreenMenu.getPixelsFromDp(80, mContext);
|
||||||
|
int pY = OnScreenMenu.getPixelsFromDp(56, mContext);
|
||||||
|
vparams = new LayoutParams(pX, pY);
|
||||||
|
vlay = new LinearLayout(mContext);
|
||||||
|
vlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
setContentView(vlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showVmu() {
|
||||||
|
vmuLcd.configureScale(80);
|
||||||
|
vlay.addView(vmuLcd, vparams);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MainPopup extends PopupWindow {
|
||||||
|
public MainPopup(Context c) {
|
||||||
|
int p = getPixelsFromDp(60, mContext);
|
||||||
|
params = new LayoutParams(p, p);
|
||||||
|
hlay = new LinearLayout(mContext);
|
||||||
|
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
int vpX = getPixelsFromDp(60, mContext);
|
||||||
|
int vpY = getPixelsFromDp(42, mContext);
|
||||||
|
LinearLayout.LayoutParams vmuParams = new LinearLayout.LayoutParams(
|
||||||
|
vpX, vpY);
|
||||||
|
vmuParams.weight = 1.0f;
|
||||||
|
vmuParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
vmuParams.rightMargin = 4;
|
||||||
|
hlay.addView(vmuLcd, vmuParams);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
popups.remove(MainPopup.this);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), params);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.vmu_swap, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
JNIdc.vmuSwap();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), params);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.config, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
displayConfigPopup(MainPopup.this);
|
||||||
|
popups.remove(MainPopup.this);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), params);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.disk_unknown, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
displayDebugPopup(MainPopup.this);
|
||||||
|
popups.remove(MainPopup.this);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}), params);
|
||||||
|
|
||||||
|
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent inte = new Intent(mContext, MainActivity.class);
|
||||||
|
mContext.startActivity(inte);
|
||||||
|
((Activity) mContext).finish();
|
||||||
|
}
|
||||||
|
}), params);
|
||||||
|
|
||||||
|
setContentView(hlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showVmu() {
|
||||||
|
vmuLcd.configureScale(60);
|
||||||
|
hlay.addView(vmuLcd, 0, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.reicast.emulator.emu;
|
package com.reicast.emulator.periph;
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -16,6 +16,9 @@ import com.bda.controller.KeyEvent;
|
||||||
import com.bda.controller.MotionEvent;
|
import com.bda.controller.MotionEvent;
|
||||||
import com.bda.controller.StateEvent;
|
import com.bda.controller.StateEvent;
|
||||||
import com.reicast.emulator.R;
|
import com.reicast.emulator.R;
|
||||||
|
import com.reicast.emulator.emu.GL2JNIActivity;
|
||||||
|
import com.reicast.emulator.emu.GL2JNIView;
|
||||||
|
import com.reicast.emulator.emu.JNIdc;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.reicast.emulator.emu;
|
package com.reicast.emulator.periph;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.reicast.emulator.emu;
|
package com.reicast.emulator.periph;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
|
@ -1,12 +1,15 @@
|
||||||
package com.reicast.emulator.emu;
|
package com.reicast.emulator.periph;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.reicast.emulator.emu.OnScreenMenu;
|
||||||
|
|
||||||
public class VmuLcd extends View {
|
public class VmuLcd extends View {
|
||||||
|
|
||||||
public final static int w = 48;
|
public final static int w = 48;
|
||||||
|
@ -15,14 +18,19 @@ public class VmuLcd extends View {
|
||||||
private int[] image = new int[w*h];
|
private int[] image = new int[w*h];
|
||||||
private Bitmap current = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
private Bitmap current = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||||
private float scale;
|
private float scale;
|
||||||
|
private Paint paint;
|
||||||
|
|
||||||
public VmuLcd(Context context) {
|
public VmuLcd(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
paint = new Paint();
|
||||||
scale = (float)OnScreenMenu.getPixelsFromDp(60, getContext()) / w;
|
scale = (float)OnScreenMenu.getPixelsFromDp(60, getContext()) / w;
|
||||||
Log.d("VmuLcd", "scale: "+scale);
|
Log.d("VmuLcd", "scale: "+scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void configureScale(int dp) {
|
||||||
|
scale = (float)OnScreenMenu.getPixelsFromDp(dp, getContext()) / w;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateBytes(byte[] data){
|
public void updateBytes(byte[] data){
|
||||||
for(int i=0; i<h; i++){
|
for(int i=0; i<h; i++){
|
||||||
for(int j=0; j<w; j++){
|
for(int j=0; j<w; j++){
|
||||||
|
@ -33,10 +41,11 @@ public class VmuLcd extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas c){
|
public void onDraw(Canvas c) {
|
||||||
current.setPixels(image, 0, w, 0, 0, w, h);
|
current.setPixels(image, 0, w, 0, 0, w, h);
|
||||||
c.scale(scale, scale);
|
c.scale(scale, scale);
|
||||||
c.drawBitmap(current, 0, 0, null);
|
paint.setFilterBitmap(true);
|
||||||
|
c.drawBitmap(current, 0, 0, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue