mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-02-10 10:30:44 +00:00
Allow calibration of portrait mode on Android
This commit is contained in:
parent
5354b0cfd5
commit
bd9b38cd65
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Apple // emulator for *nix
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 3 or later (your choice) as published by the Free Software
|
||||
* Foundation.
|
||||
*/
|
||||
|
||||
package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class VerticalSeekBar extends SeekBar {
|
||||
|
||||
public VerticalSeekBar(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public VerticalSeekBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(h, w, oldh, oldw);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
|
||||
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
|
||||
}
|
||||
|
||||
protected void onDraw(Canvas c) {
|
||||
c.rotate(-90);
|
||||
c.translate(-getHeight(), 0);
|
||||
super.onDraw(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (!isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
case MotionEvent.ACTION_UP:
|
||||
int i = 0;
|
||||
i = getMax() - (int) (getMax() * event.getY() / getHeight());
|
||||
setProgress(i);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setProgress(int progress) {
|
||||
super.setProgress(progress);
|
||||
onSizeChanged(getWidth(), getHeight(), 0, 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Apple // emulator for *nix
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 3 or later (your choice) as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Copyright 2015 Aaron Culliney
|
||||
*
|
||||
*/
|
||||
|
||||
package org.deadc0de.apple2ix;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.VerticalSeekBar;
|
||||
|
||||
import org.deadc0de.apple2ix.basic.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Apple2PortraitCalibration implements Apple2MenuView {
|
||||
|
||||
public enum States {
|
||||
CALIBRATE_KEYBOARD_HEIGHT_SCALE(0),
|
||||
CALIBRATE_FRAMEBUFFER_POSITION_SCALE(1),
|
||||
CALIBRATE_KEYBOARD_POSITION_SCALE(2);
|
||||
private int val;
|
||||
|
||||
public static final int size = States.values().length;
|
||||
|
||||
States(int val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
States next() {
|
||||
int ord = (val + 1) % size;
|
||||
return States.values()[ord];
|
||||
}
|
||||
}
|
||||
|
||||
private final static String TAG = "Apple2PortraitCalibration";
|
||||
|
||||
|
||||
private Apple2Activity mActivity = null;
|
||||
private View mSettingsView = null;
|
||||
private ArrayList<Apple2MenuView> mViewStack = null;
|
||||
private boolean mTouchMenuEnabled = false;
|
||||
private int mSavedTouchDevice = Apple2Preferences.TouchDeviceVariant.NONE.ordinal();
|
||||
private States mStateMachine = States.CALIBRATE_KEYBOARD_HEIGHT_SCALE;
|
||||
|
||||
public Apple2PortraitCalibration(Apple2Activity activity, ArrayList<Apple2MenuView> viewStack) {
|
||||
mActivity = activity;
|
||||
mViewStack = viewStack;
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mSettingsView = inflater.inflate(R.layout.activity_calibrate_portrait, null, false);
|
||||
|
||||
final Button calibrateButton = (Button) mSettingsView.findViewById(R.id.button_calibrate);
|
||||
final VerticalSeekBar vsb = (VerticalSeekBar) mSettingsView.findViewById(R.id.seekbar_vertical);
|
||||
|
||||
vsb.setProgress(Apple2Preferences.PORTRAIT_KEYBOARD_HEIGHT_SCALE.intValue(mActivity));
|
||||
|
||||
calibrateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mStateMachine = mStateMachine.next();
|
||||
switch (mStateMachine) {
|
||||
case CALIBRATE_KEYBOARD_HEIGHT_SCALE:
|
||||
calibrateButton.setText(R.string.portrait_calibrate_keyboard_height);
|
||||
vsb.setProgress(Apple2Preferences.PORTRAIT_KEYBOARD_HEIGHT_SCALE.intValue(mActivity));
|
||||
break;
|
||||
case CALIBRATE_FRAMEBUFFER_POSITION_SCALE:
|
||||
calibrateButton.setText(R.string.portrait_calibrate_framebuffer);
|
||||
vsb.setProgress(Apple2Preferences.PORTRAIT_FRAMEBUFFER_POSITION_SCALE.intValue(mActivity));
|
||||
break;
|
||||
case CALIBRATE_KEYBOARD_POSITION_SCALE:
|
||||
default:
|
||||
calibrateButton.setText(R.string.portrait_calibrate_keyboard_position);
|
||||
vsb.setProgress(Apple2Preferences.PORTRAIT_KEYBOARD_POSITION_SCALE.intValue(mActivity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vsb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
switch (mStateMachine) {
|
||||
case CALIBRATE_KEYBOARD_HEIGHT_SCALE:
|
||||
Apple2Preferences.PORTRAIT_KEYBOARD_HEIGHT_SCALE.saveInt(mActivity, progress);
|
||||
break;
|
||||
case CALIBRATE_FRAMEBUFFER_POSITION_SCALE:
|
||||
Apple2Preferences.PORTRAIT_FRAMEBUFFER_POSITION_SCALE.saveInt(mActivity, progress);
|
||||
break;
|
||||
case CALIBRATE_KEYBOARD_POSITION_SCALE:
|
||||
default:
|
||||
Apple2Preferences.PORTRAIT_KEYBOARD_POSITION_SCALE.saveInt(mActivity, progress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
mTouchMenuEnabled = Apple2Preferences.TOUCH_MENU_ENABLED.booleanValue(mActivity);
|
||||
Apple2Preferences.nativeSetTouchMenuEnabled(false);
|
||||
mSavedTouchDevice = Apple2Preferences.CURRENT_TOUCH_DEVICE.intValue(mActivity);
|
||||
Apple2Preferences.nativeSetCurrentTouchDevice(Apple2Preferences.TouchDeviceVariant.KEYBOARD.ordinal());
|
||||
Apple2Preferences.nativeTouchDeviceBeginCalibrationMode();
|
||||
}
|
||||
|
||||
public final boolean isCalibrating() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onKeyTapCalibrationEvent(char ascii, int scancode) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (isShowing()) {
|
||||
return;
|
||||
}
|
||||
mActivity.pushApple2View(this);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
for (Apple2MenuView apple2MenuView : mViewStack) {
|
||||
if (apple2MenuView != this) {
|
||||
mActivity.pushApple2View(apple2MenuView);
|
||||
}
|
||||
}
|
||||
|
||||
Apple2Preferences.nativeTouchDeviceEndCalibrationMode();
|
||||
Apple2Preferences.nativeSetTouchMenuEnabled(mTouchMenuEnabled);
|
||||
Apple2Preferences.nativeSetCurrentTouchDevice(mSavedTouchDevice);
|
||||
|
||||
mActivity.popApple2View(this);
|
||||
}
|
||||
|
||||
public void dismissAll() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
return mSettingsView.getParent() != null;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mSettingsView;
|
||||
}
|
||||
}
|
@ -14,12 +14,15 @@ package org.deadc0de.apple2ix;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.deadc0de.apple2ix.basic.R;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public enum Apple2Preferences {
|
||||
EMULATOR_VERSION {
|
||||
@ -195,6 +198,21 @@ public enum Apple2Preferences {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), Volume.MEDIUM.ordinal());
|
||||
}
|
||||
},
|
||||
LANDSCAPE_MODE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
if (booleanValue(activity)) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean booleanValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
|
||||
}
|
||||
},
|
||||
MOCKINGBOARD_ENABLED {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
@ -628,6 +646,60 @@ public enum Apple2Preferences {
|
||||
return scale;
|
||||
}
|
||||
},
|
||||
PORTRAIT_KEYBOARD_HEIGHT_SCALE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int tick = intValue(activity);
|
||||
float portraitKeyboardHeightScale = ((float) tick / PORTRAIT_CALIBRATE_NUM_CHOICES);
|
||||
try {
|
||||
JSONObject prefs = new JSONObject().put(PREFNAME_PORTRAIT_HEIGHT_SCALE, portraitKeyboardHeightScale);
|
||||
nativeSetTouchModelPreferences(TouchDeviceVariant.KEYBOARD.ordinal(), prefs.toString());
|
||||
} catch (JSONException e) {
|
||||
Log.v(TAG, "" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), PORTRAIT_CALIBRATE_NUM_CHOICES >> 1);
|
||||
}
|
||||
},
|
||||
PORTRAIT_FRAMEBUFFER_POSITION_SCALE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int tick = intValue(activity);
|
||||
float portraitFramebufferPositionScale = ((float) tick / PORTRAIT_CALIBRATE_NUM_CHOICES);
|
||||
try {
|
||||
JSONObject prefs = new JSONObject().put(PREFNAME_PORTRAIT_POSITION_SCALE, portraitFramebufferPositionScale);
|
||||
nativeSetTouchModelPreferences(TouchDeviceVariant.FRAMEBUFFER.ordinal(), prefs.toString());
|
||||
} catch (JSONException e) {
|
||||
Log.v(TAG, "" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), (PORTRAIT_CALIBRATE_NUM_CHOICES*3/4));
|
||||
}
|
||||
},
|
||||
PORTRAIT_KEYBOARD_POSITION_SCALE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int tick = intValue(activity);
|
||||
float portraitKeyboardPositionScale = ((float) tick / PORTRAIT_CALIBRATE_NUM_CHOICES);
|
||||
try {
|
||||
JSONObject prefs = new JSONObject().put(PREFNAME_PORTRAIT_POSITION_SCALE, portraitKeyboardPositionScale);
|
||||
nativeSetTouchModelPreferences(TouchDeviceVariant.KEYBOARD.ordinal(), prefs.toString());
|
||||
} catch (JSONException e) {
|
||||
Log.v(TAG, "" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), 0);
|
||||
}
|
||||
},
|
||||
CRASH_CHECK {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
@ -673,7 +745,6 @@ public enum Apple2Preferences {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public enum HiresColor {
|
||||
BW,
|
||||
COLOR,
|
||||
@ -705,9 +776,13 @@ public enum Apple2Preferences {
|
||||
NONE(0),
|
||||
JOYSTICK(1),
|
||||
JOYSTICK_KEYPAD(2),
|
||||
KEYBOARD(3);
|
||||
KEYBOARD(3),
|
||||
TOPMENU(4),
|
||||
ALERT(5);
|
||||
private int dev;
|
||||
|
||||
public static final TouchDeviceVariant FRAMEBUFFER = NONE;
|
||||
|
||||
public static final int size = TouchDeviceVariant.values().length;
|
||||
|
||||
TouchDeviceVariant(int dev) {
|
||||
@ -715,10 +790,7 @@ public enum Apple2Preferences {
|
||||
}
|
||||
|
||||
static TouchDeviceVariant next(int ord) {
|
||||
++ord;
|
||||
if (ord >= size) {
|
||||
ord = 1;
|
||||
}
|
||||
ord = (ord + 1) % size;
|
||||
return TouchDeviceVariant.values()[ord];
|
||||
}
|
||||
}
|
||||
@ -886,6 +958,8 @@ public enum Apple2Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
public final static String TAG = "Apple2Preferences";
|
||||
|
||||
public final static int DECENT_AMOUNT_OF_CHOICES = 20;
|
||||
public final static int AUDIO_LATENCY_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
|
||||
public final static int ALPHA_SLIDER_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
|
||||
@ -896,9 +970,8 @@ public enum Apple2Preferences {
|
||||
|
||||
public final static int KEYREPEAT_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
|
||||
|
||||
public final static String TAG = "Apple2Preferences";
|
||||
|
||||
public final static int JOYSTICK_BUTTON_THRESHOLD_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
|
||||
public final static int PORTRAIT_CALIBRATE_NUM_CHOICES = 100;
|
||||
|
||||
public final static float JOYSTICK_AXIS_SENSITIVITY_MIN = 0.25f;
|
||||
public final static float JOYSTICK_AXIS_SENSITIVITY_DEFAULT = 1.f;
|
||||
@ -909,6 +982,9 @@ public enum Apple2Preferences {
|
||||
public final static int JOYSTICK_AXIS_SENSITIVITY_INC_NUMCHOICES = (int) ((JOYSTICK_AXIS_SENSITIVITY_MAX - JOYSTICK_AXIS_SENSITIVITY_DEFAULT) / JOYSTICK_AXIS_SENSITIVITY_INC_STEP); // 12
|
||||
public final static int JOYSTICK_AXIS_SENSITIVITY_NUM_CHOICES = JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES + JOYSTICK_AXIS_SENSITIVITY_INC_NUMCHOICES; // 15 + 12
|
||||
|
||||
public final static String PREFNAME_PORTRAIT_HEIGHT_SCALE = "portraitHeightScale";
|
||||
public final static String PREFNAME_PORTRAIT_POSITION_SCALE = "portraitPositionScale";
|
||||
|
||||
// set and apply
|
||||
|
||||
public void saveBoolean(Apple2Activity activity, boolean value) {
|
||||
@ -1013,10 +1089,10 @@ public enum Apple2Preferences {
|
||||
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
|
||||
int smallScreenAxis = dm.widthPixels < dm.heightPixels ? dm.widthPixels : dm.heightPixels;
|
||||
int oneThirdScreenAxis = smallScreenAxis/3;
|
||||
int oneThirdScreenAxis = smallScreenAxis / 3;
|
||||
|
||||
// largest switch threshold value is 1/3 small dimension of screen
|
||||
return oneThirdScreenAxis/JOYSTICK_BUTTON_THRESHOLD_NUM_CHOICES;
|
||||
return oneThirdScreenAxis / JOYSTICK_BUTTON_THRESHOLD_NUM_CHOICES;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -1148,4 +1224,7 @@ public enum Apple2Preferences {
|
||||
|
||||
private static native void nativeLoadTouchKeyboardJSON(String path);
|
||||
|
||||
private static native void nativeSetTouchModelPreferences(int modelType, String jsonString);
|
||||
|
||||
|
||||
}
|
||||
|
@ -93,6 +93,22 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
});
|
||||
}
|
||||
},
|
||||
VIDEO_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
new Apple2VideoSettingsMenu(activity).show();
|
||||
}
|
||||
},
|
||||
JOYSTICK_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
@ -157,43 +173,6 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
new Apple2AudioSettingsMenu(activity).show();
|
||||
}
|
||||
},
|
||||
VIDEO_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.video_configure_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
_addPopupIcon(activity, this, convertView);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
_alertDialogHandleSelection(activity, R.string.video_configure, new String[]{
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_bw),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_color),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_interpolated),
|
||||
}, new IPreferenceLoadSave() {
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.HIRES_COLOR.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveInt(int value) {
|
||||
Apple2Preferences.HIRES_COLOR.saveHiresColor(settingsMenu.mActivity, Apple2Preferences.HiresColor.values()[value]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
SHOW_DISK_OPERATIONS {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Apple // emulator for *nix
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 3 or later (your choice) as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Copyright 2015 Aaron Culliney
|
||||
*
|
||||
*/
|
||||
|
||||
package org.deadc0de.apple2ix;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.deadc0de.apple2ix.basic.R;
|
||||
|
||||
public class Apple2VideoSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
private final static String TAG = "Apple2VideoSettingsMenu";
|
||||
|
||||
public Apple2VideoSettingsMenu(Apple2Activity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] allTitles() {
|
||||
return SETTINGS.titles(mActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IMenuEnum[] allValues() {
|
||||
return SETTINGS.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean areAllItemsEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isEnabled(int position) {
|
||||
if (position < 0 || position >= SETTINGS.size) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
LANDSCAPE_MODE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mode_landscape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.mode_landscape_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final View getView(final Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
CheckBox cb = _addCheckbox(activity, this, convertView, Apple2Preferences.LANDSCAPE_MODE.booleanValue(activity));
|
||||
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Apple2Preferences.LANDSCAPE_MODE.saveBoolean(activity, isChecked);
|
||||
Apple2Preferences.LANDSCAPE_MODE.load(activity);
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
},
|
||||
PORTRAIT_CALIBRATE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.portrait_calibrate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.portrait_calibrate_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
ArrayList<Apple2MenuView> viewStack = new ArrayList<Apple2MenuView>();
|
||||
{
|
||||
int idx = 0;
|
||||
while (true) {
|
||||
Apple2MenuView apple2MenuView = activity.peekApple2View(idx);
|
||||
if (apple2MenuView == null) {
|
||||
break;
|
||||
}
|
||||
viewStack.add(apple2MenuView);
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
Apple2Preferences.LANDSCAPE_MODE.saveBoolean(activity, false);
|
||||
Apple2PortraitCalibration calibration = new Apple2PortraitCalibration(activity, viewStack);
|
||||
|
||||
// show this new view...
|
||||
calibration.show();
|
||||
|
||||
// ...with nothing else underneath 'cept the emulator OpenGL layer
|
||||
for (Apple2MenuView apple2MenuView : viewStack) {
|
||||
activity.popApple2View(apple2MenuView);
|
||||
}
|
||||
}
|
||||
},
|
||||
COLOR_CONFIGURE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.color_configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.color_configure_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
_addPopupIcon(activity, this, convertView);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
_alertDialogHandleSelection(activity, R.string.video_configure, new String[]{
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_bw),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_color),
|
||||
settingsMenu.mActivity.getResources().getString(R.string.color_interpolated),
|
||||
}, new IPreferenceLoadSave() {
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.HIRES_COLOR.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveInt(int value) {
|
||||
Apple2Preferences.HIRES_COLOR.saveHiresColor(settingsMenu.mActivity, Apple2Preferences.HiresColor.values()[value]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public static final int size = SETTINGS.values().length;
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(Apple2Activity activity, View convertView) {
|
||||
return _basicView(activity, this, convertView);
|
||||
}
|
||||
|
||||
public static String[] titles(Apple2Activity activity) {
|
||||
String[] titles = new String[size];
|
||||
int i = 0;
|
||||
for (SETTINGS setting : values()) {
|
||||
titles[i++] = setting.getTitle(activity);
|
||||
}
|
||||
return titles;
|
||||
}
|
||||
}
|
||||
}
|
@ -67,9 +67,9 @@ class Apple2View extends GLSurfaceView implements InputManagerCompat.InputDevice
|
||||
private float[] mYCoords = new float[MAX_FINGERS];
|
||||
|
||||
|
||||
private static native void nativeGraphicsInitialized(int width, int height);
|
||||
private static native void nativeGraphicsInitialized(int width, int height, boolean landscape);
|
||||
|
||||
private static native void nativeGraphicsChanged(int width, int height);
|
||||
private static native void nativeGraphicsChanged(int width, int height, boolean landscape);
|
||||
|
||||
private static native void nativeRender();
|
||||
|
||||
@ -129,7 +129,7 @@ class Apple2View extends GLSurfaceView implements InputManagerCompat.InputDevice
|
||||
w = h;
|
||||
h = w_;
|
||||
}
|
||||
nativeGraphicsChanged(w, h);
|
||||
nativeGraphicsChanged(w, h, Apple2Preferences.LANDSCAPE_MODE.booleanValue(Apple2View.this.mActivity));
|
||||
}
|
||||
});
|
||||
|
||||
@ -371,7 +371,7 @@ class Apple2View extends GLSurfaceView implements InputManagerCompat.InputDevice
|
||||
height = w_;
|
||||
}
|
||||
|
||||
nativeGraphicsInitialized(width, height);
|
||||
nativeGraphicsInitialized(width, height, Apple2Preferences.LANDSCAPE_MODE.booleanValue(Apple2View.this.mActivity));
|
||||
|
||||
if (Apple2View.this.mGraphicsInitializedRunnable != null) {
|
||||
Apple2View.this.mGraphicsInitializedRunnable.run();
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/calibratePortrait"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/preference_margin_bottom"
|
||||
android:layout_marginEnd="@dimen/preference_margin_right"
|
||||
android:layout_marginLeft="@dimen/preference_margin_left"
|
||||
android:layout_marginRight="@dimen/preference_margin_right"
|
||||
android:layout_marginStart="@dimen/preference_margin_left"
|
||||
android:layout_marginTop="@dimen/preference_margin_top"
|
||||
android:layout_weight="1">
|
||||
|
||||
<android.widget.VerticalSeekBar
|
||||
android:id="@+id/seekbar_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_alignTop="@+id/button_calibrate" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_calibrate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/portrait_calibrate_keyboard_height"
|
||||
android:layout_marginTop="22dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
</RelativeLayout>
|
@ -21,6 +21,8 @@
|
||||
<string name="audio_latency">Audio latency</string>
|
||||
<string name="audio_latency_summary">Audio latency in secs</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="color_configure">Configure color</string>
|
||||
<string name="color_configure_summary">Color mode</string>
|
||||
<string name="color_bw">Black/white</string>
|
||||
<string name="color_color">Color</string>
|
||||
<string name="color_interpolated">Interpolated color</string>
|
||||
@ -133,8 +135,15 @@
|
||||
<string name="mockingboard_enable_summary">Revision C in Slot 4/5 (may require restart)</string>
|
||||
<string name="mockingboard_volume">Mockingboard volume</string>
|
||||
<string name="mockingboard_volume_summary">Set the Mockingboard volume</string>
|
||||
<string name="mode_landscape">Landscape</string>
|
||||
<string name="mode_landscape_summary">Enable landscape or portrait mode</string>
|
||||
<string name="no">No</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="portrait_calibrate">Calibrate portrait mode</string>
|
||||
<string name="portrait_calibrate_framebuffer">Display position</string>
|
||||
<string name="portrait_calibrate_keyboard_height">Keyboard height</string>
|
||||
<string name="portrait_calibrate_keyboard_position">Keyboard position</string>
|
||||
<string name="portrait_calibrate_summary">Adjust keyboard size, framebuffer position, etc</string>
|
||||
<string name="preferences_reset_title">Reset preferences</string>
|
||||
<string name="preferences_reset_summary">Reset preferences to defaults and quit emulator</string>
|
||||
<string name="preferences_reset_really">Really reset and quit?</string>
|
||||
@ -159,6 +168,6 @@
|
||||
<string name="touch_menu_enable">Enable touch menus</string>
|
||||
<string name="touch_menu_enable_summary">Enables soft menu buttons in top screen corners</string>
|
||||
<string name="video_configure">Configure video…</string>
|
||||
<string name="video_configure_summary">Color settings</string>
|
||||
<string name="video_configure_summary">Color landscape/portrait, color, etc</string>
|
||||
|
||||
</resources>
|
||||
|
@ -188,18 +188,21 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jclas
|
||||
#endif
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsChanged(JNIEnv *env, jclass cls, jint width, jint height) {
|
||||
void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsChanged(JNIEnv *env, jclass cls, jint width, jint height, jboolean landscape) {
|
||||
// WARNING : this can happen on non-GL thread
|
||||
LOG("...");
|
||||
video_reshape(width, height);
|
||||
LOG("width:%d height:%d landscape:%d", width, height, landscape);
|
||||
video_reshape(width, height, landscape);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env, jclass cls, jint width, jint height) {
|
||||
void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env, jclass cls, jint width, jint height, jboolean landscape) {
|
||||
// WARNING : this needs to happen on the GL thread only
|
||||
LOG("width:%d height:%d", width, height);
|
||||
LOG("width:%d height:%d landscape:%d", width, height, landscape);
|
||||
_video_setRenderThread(pthread_self()); // Assume Android knows what it's doing ;-P
|
||||
|
||||
assert(cpu_isPaused());
|
||||
|
||||
video_shutdown(false);
|
||||
video_reshape(width, height);
|
||||
video_reshape(width, height, landscape);
|
||||
video_init();
|
||||
}
|
||||
|
||||
@ -255,6 +258,7 @@ void Java_org_deadc0de_apple2ix_Apple2View_nativeRender(JNIEnv *env, jclass cls)
|
||||
return;
|
||||
}
|
||||
|
||||
//#define FPS_LOG 1
|
||||
#if FPS_LOG
|
||||
static uint32_t prevCount = 0;
|
||||
static uint32_t idleCount = 0;
|
||||
|
@ -324,3 +324,13 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeLoadTouchKeyboardJSON(JN
|
||||
(*env)->ReleaseStringUTFChars(env, j_jsonPath, jsonPath);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchModelPreferences(JNIEnv *env, jclass cls, jint modelType, jstring j_jsonString) {
|
||||
const char *jsonString = (*env)->GetStringUTFChars(env, j_jsonString, 0);
|
||||
LOG("model: %d", modelType);
|
||||
|
||||
void (*setData)(const char *) = interface_getModelDataSetter((interface_device_t)modelType);
|
||||
setData(jsonString);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, j_jsonString, jsonString);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user