mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-24 11:29:33 +00:00
Android touch menu configurations
This commit is contained in:
parent
25b9f3d3f3
commit
7067d10949
|
@ -20,7 +20,6 @@ import android.widget.AdapterView;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
|
|
@ -43,6 +43,80 @@ public class Apple2InputSettingsMenu implements Apple2MenuView {
|
|||
}
|
||||
|
||||
enum SETTINGS {
|
||||
TOUCH_MENU_ENABLED {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_enable_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
CheckBox cb = _addCheckbox(activity, this, convertView, Apple2Preferences.TOUCH_MENU_ENABLED.booleanValue(activity));
|
||||
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Apple2Preferences.TOUCH_MENU_ENABLED.saveBoolean(activity, isChecked);
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
},
|
||||
TOUCH_MENU_VISIBILITY {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.touch_menu_visibility_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.a2preference_slider, null, false);
|
||||
|
||||
TextView tv = (TextView) convertView.findViewById(R.id.a2preference_slider_summary);
|
||||
tv.setText(getSummary(activity));
|
||||
|
||||
final TextView seekBarValue = (TextView) convertView.findViewById(R.id.a2preference_slider_seekBarValue);
|
||||
|
||||
SeekBar sb = (SeekBar) convertView.findViewById(R.id.a2preference_slider_seekBar);
|
||||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (!fromUser) {
|
||||
return;
|
||||
}
|
||||
float alpha = (float) progress / Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES;
|
||||
seekBarValue.setText("" + alpha);
|
||||
Apple2Preferences.TOUCH_MENU_VISIBILITY.saveInt(activity, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
sb.setMax(0); // http://stackoverflow.com/questions/10278467/seekbar-not-setting-actual-progress-setprogress-not-working-on-early-android
|
||||
sb.setMax(Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES);
|
||||
int progress = Apple2Preferences.TOUCH_MENU_VISIBILITY.intValue(activity);
|
||||
sb.setProgress(progress);
|
||||
seekBarValue.setText("" + ((float) progress / Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES));
|
||||
return convertView;
|
||||
}
|
||||
},
|
||||
FIRST_INPUT {
|
||||
@Override
|
||||
public String getTitle(Apple2Activity activity) {
|
||||
|
|
|
@ -122,6 +122,31 @@ public enum Apple2Preferences {
|
|||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), TouchDevice.KEYBOARD.ordinal());
|
||||
}
|
||||
},
|
||||
TOUCH_MENU_ENABLED {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
boolean enabled = booleanValue(activity);
|
||||
nativeSetTouchMenuEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean booleanValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
|
||||
}
|
||||
},
|
||||
TOUCH_MENU_VISIBILITY {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int setting = intValue(activity);
|
||||
float alpha = (float) setting / AUDIO_LATENCY_NUM_CHOICES;
|
||||
nativeSetTouchMenuVisibility(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), 5);
|
||||
}
|
||||
};
|
||||
|
||||
public enum HiresColor {
|
||||
|
@ -175,6 +200,7 @@ public enum Apple2Preferences {
|
|||
}
|
||||
|
||||
public final static int AUDIO_LATENCY_NUM_CHOICES = 20;
|
||||
public final static int ALPHA_SLIDER_NUM_CHOICES = 20;
|
||||
public final static String TAG = "Apple2Preferences";
|
||||
|
||||
// set and apply
|
||||
|
@ -234,10 +260,6 @@ public enum Apple2Preferences {
|
|||
loadPreferences(activity);
|
||||
}
|
||||
|
||||
private static native void nativeEnableTouchJoystick(boolean enabled);
|
||||
|
||||
private static native void nativeEnableTiltJoystick(boolean enabled);
|
||||
|
||||
private static native void nativeSetColor(int color);
|
||||
|
||||
private static native boolean nativeSetSpeakerEnabled(boolean enabled);
|
||||
|
@ -251,4 +273,8 @@ public enum Apple2Preferences {
|
|||
private static native void nativeSetAudioLatency(float latencySecs);
|
||||
|
||||
private static native void nativeSetDefaultTouchDevice(int device);
|
||||
|
||||
private static native void nativeSetTouchMenuEnabled(boolean enabled);
|
||||
|
||||
private static native void nativeSetTouchMenuVisibility(float alpha);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
<string name="diskB">Drive 2</string>
|
||||
<string name="disk_read_write">Read/write</string>
|
||||
<string name="emulation_continue">Continue…</string>
|
||||
<string name="emulation_welcome">Party like it\'s 1987!</string>
|
||||
<string name="header_disks">Insert disk:</string>
|
||||
<string name="joystick">Joystick</string>
|
||||
<string name="input_configure">Configure input devices…</string>
|
||||
|
@ -65,11 +64,11 @@
|
|||
<string name="spacer"></string>
|
||||
<string name="speaker_disabled_title">Speaker disabled</string>
|
||||
<string name="speaker_disabled_mesg">Speaker could not be enabled</string>
|
||||
<string name="speaker_enable">Enable Speaker</string>
|
||||
<string name="speaker_enable">Enable speaker</string>
|
||||
<string name="speaker_enable_summary">(Speaker cannot be disabled)</string>
|
||||
<string name="speaker_volume">Speaker volume</string>
|
||||
<string name="speaker_volume_summary">Set the speaker volume</string>
|
||||
<string name="speed_alt">Alternate CPU Speed</string>
|
||||
<string name="speed_alt">Alternate CPU speed</string>
|
||||
<string name="speed_cpu">CPU Speed</string>
|
||||
<string name="settings">Apple2ix emulator settings</string>
|
||||
<string name="settings_audio">Apple2ix audio settings</string>
|
||||
|
@ -78,6 +77,10 @@
|
|||
<string name="tab_general">General</string>
|
||||
<string name="tab_joystick">Joystick</string>
|
||||
<string name="title_activity_second">SecondActivity</string>
|
||||
<string name="touch_menu_enable">Enable touch menus</string>
|
||||
<string name="touch_menu_enable_summary">Enables menu buttons in top screen corners</string>
|
||||
<string name="touch_menu_visibility">Touch menu visibility</string>
|
||||
<string name="touch_menu_visibility_summary">Touch menu visibility when inactive</string>
|
||||
<string name="video_configure">Configure video…</string>
|
||||
<string name="video_configure_summary">Color settings</string>
|
||||
|
||||
|
|
|
@ -96,3 +96,13 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetDefaultTouchDevice(JN
|
|||
}
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchMenuEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
|
||||
LOG("native set touch menu enabled : %d", enabled);
|
||||
interface_setTouchMenuEnabled(enabled);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchMenuVisibility(JNIEnv *env, jclass cls, jfloat alpha) {
|
||||
LOG("native set touch menu visibility : %f", alpha);
|
||||
interface_setTouchMenuVisibility(alpha);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
bool (*interface_onTouchEvent)(interface_touch_event_t action, int pointer_count, int pointer_idx, float *x_coords, float *y_coords) = NULL;
|
||||
bool (*interface_isTouchMenuAvailable)(void) = NULL;
|
||||
void (*interface_setTouchMenuEnabled)(bool enabled) = NULL;
|
||||
void (*interface_setTouchMenuVisibility)(float alpha) = NULL;
|
||||
#endif
|
||||
|
||||
// 2015/04/12 : This was legacy code for rendering the menu interfaces on desktop Linux. Portions here are resurrected
|
||||
|
|
|
@ -62,6 +62,9 @@ extern bool (*interface_isTouchMenuAvailable)(void);
|
|||
|
||||
// enable/disable touch menu HUD element
|
||||
extern void (*interface_setTouchMenuEnabled)(bool enabled);
|
||||
|
||||
// set minimum alpha visibility of touch menu HUD element
|
||||
extern void (*interface_setTouchMenuVisibility)(float alpha);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -136,7 +136,6 @@ static float _get_menu_visibility(void) {
|
|||
float alpha = minAlpha;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
alpha = minAlpha;
|
||||
deltat = timespec_diff(timingBegin, now, NULL);
|
||||
if (deltat.tv_sec == 0) {
|
||||
alpha = 1.0;
|
||||
|
@ -576,6 +575,14 @@ static void _animation_hideTouchMenu(void) {
|
|||
timingBegin = (struct timespec){ 0 };
|
||||
}
|
||||
|
||||
static void gltouchmenu_set(void) {
|
||||
timingBegin = (struct timespec){ 0 };
|
||||
}
|
||||
|
||||
static void gltouchmenu_setTouchMenuVisibility(float alpha) {
|
||||
minAlpha = alpha;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
|
||||
|
@ -588,6 +595,7 @@ static void _init_gltouchmenu(void) {
|
|||
|
||||
interface_isTouchMenuAvailable = &gltouchmenu_isTouchMenuAvailable;
|
||||
interface_setTouchMenuEnabled = &gltouchmenu_setTouchMenuEnabled;
|
||||
interface_setTouchMenuVisibility = &gltouchmenu_setTouchMenuVisibility;
|
||||
|
||||
menu.kbdOrJoy = ICONTEXT_UPPERCASE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user