mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-14 03:30:53 +00:00
Enable various GL Touch Keyboard settings
This commit is contained in:
parent
ebe7f82f22
commit
59cb3e49f9
@ -12,6 +12,9 @@
|
||||
package org.deadc0de.apple2ix;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Apple2KeyboardSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@ -85,19 +88,90 @@ public class Apple2KeyboardSettingsMenu extends Apple2AbstractMenu {
|
||||
}
|
||||
|
||||
protected enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
KEYBOARD_VISIBILITY {
|
||||
KEYBOARD_VISIBILITY_INACTIVE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_visibility);
|
||||
return activity.getResources().getString(R.string.keyboard_visibility_inactive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_visibility_summary);
|
||||
return activity.getResources().getString(R.string.keyboard_visibility_inactive_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
Apple2Preferences.KEYBOARD_VISIBILITY_INACTIVE.saveInt(activity, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.KEYBOARD_VISIBILITY_INACTIVE.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + ((float) progress / Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
KEYBOARD_VISIBILITY_ACTIVE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_visibility_active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_visibility_active_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
return _sliderView(activity, this, Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
Apple2Preferences.KEYBOARD_VISIBILITY_ACTIVE.saveInt(activity, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return Apple2Preferences.KEYBOARD_VISIBILITY_ACTIVE.intValue(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
seekBarValue.setText("" + ((float) progress / Apple2Preferences.ALPHA_SLIDER_NUM_CHOICES));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
KEYBOARD_ENABLE_LOWERCASE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_lowercase_enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.keyboard_lowercase_enabled_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
convertView = _basicView(activity, this, convertView);
|
||||
CheckBox cb = _addCheckbox(activity, this, convertView, Apple2Preferences.KEYBOARD_LOWERCASE_ENABLED.booleanValue(activity));
|
||||
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Apple2Preferences.KEYBOARD_LOWERCASE_ENABLED.saveBoolean(activity, isChecked);
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -511,6 +511,44 @@ public enum Apple2Preferences {
|
||||
int defaultLatency = KEYREPEAT_NUM_CHOICES / 4;
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), defaultLatency);
|
||||
}
|
||||
},
|
||||
KEYBOARD_VISIBILITY_ACTIVE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int inactiveTick = KEYBOARD_VISIBILITY_INACTIVE.intValue(activity);
|
||||
int activeTick = intValue(activity);
|
||||
nativeSetTouchKeyboardVisibility((float) inactiveTick / ALPHA_SLIDER_NUM_CHOICES, (float) activeTick / ALPHA_SLIDER_NUM_CHOICES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), ALPHA_SLIDER_NUM_CHOICES);
|
||||
}
|
||||
},
|
||||
KEYBOARD_VISIBILITY_INACTIVE {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
int inactiveTick = intValue(activity);
|
||||
int activeTick = KEYBOARD_VISIBILITY_ACTIVE.intValue(activity);
|
||||
nativeSetTouchKeyboardVisibility((float) inactiveTick / ALPHA_SLIDER_NUM_CHOICES, (float) activeTick / ALPHA_SLIDER_NUM_CHOICES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), 5);
|
||||
}
|
||||
},
|
||||
KEYBOARD_LOWERCASE_ENABLED {
|
||||
@Override
|
||||
public void load(Apple2Activity activity) {
|
||||
boolean enabled = booleanValue(activity);
|
||||
nativeSetTouchKeyboardLowercaseEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean booleanValue(Apple2Activity activity) {
|
||||
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
|
||||
}
|
||||
};
|
||||
|
||||
public enum HiresColor {
|
||||
@ -944,6 +982,10 @@ public enum Apple2Preferences {
|
||||
|
||||
private static native void nativeSetTouchMenuVisibility(float alpha);
|
||||
|
||||
private static native void nativeSetTouchKeyboardVisibility(float inactiveAlpha, float activeAlpha);
|
||||
|
||||
private static native void nativeSetTouchKeyboardLowercaseEnabled(boolean enabled);
|
||||
|
||||
public static native int nativeGetCurrentTouchDevice();
|
||||
|
||||
public static native int nativeGetCPUSpeed();
|
||||
|
@ -134,7 +134,7 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
//new Apple2KeyboardSettingsMenu().show();
|
||||
new Apple2KeyboardSettingsMenu(activity).show();
|
||||
}
|
||||
},
|
||||
AUDIO_CONFIGURE {
|
||||
|
@ -72,9 +72,13 @@
|
||||
<string name="key_up">↑</string>
|
||||
<string name="keyboard">Keyboard</string>
|
||||
<string name="keyboard_configure">Configure keyboard…</string>
|
||||
<string name="keyboard_configure_summary">Transparency, fading, custom keys</string>
|
||||
<string name="keyboard_visibility">Keyboard visibility</string>
|
||||
<string name="keyboard_visibility_summary">Keyboard visibility when inactive</string>
|
||||
<string name="keyboard_configure_summary">Transparency, lowercase, custom keys</string>
|
||||
<string name="keyboard_lowercase_enabled">Enable lowercase</string>
|
||||
<string name="keyboard_lowercase_enabled_summary">Enable lowercase keys</string>
|
||||
<string name="keyboard_visibility_active">Visibility when active</string>
|
||||
<string name="keyboard_visibility_active_summary">Keyboard visibility when active</string>
|
||||
<string name="keyboard_visibility_inactive">Visibility when inactive</string>
|
||||
<string name="keyboard_visibility_inactive_summary">Keyboard visibility when inactive</string>
|
||||
<string name="keypad">Keypad Joystick</string>
|
||||
<string name="keypadA">Touch Keypad Joystick</string>
|
||||
<string name="keypad_button_tap_button">Tap key:</string>
|
||||
|
@ -118,15 +118,25 @@ jint Java_org_deadc0de_apple2ix_Apple2Preferences_nativeGetCurrentTouchDevice(JN
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchMenuEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
|
||||
LOG("touch menu enabled : %d", enabled);
|
||||
LOG("enabled : %d", enabled);
|
||||
interface_setTouchMenuEnabled(enabled);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchKeyboardLowercaseEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
|
||||
LOG("enabled : %d", enabled);
|
||||
keydriver_setLowercaseEnabled(enabled);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchMenuVisibility(JNIEnv *env, jclass cls, jfloat alpha) {
|
||||
LOG("touch menu visibility : %f", alpha);
|
||||
LOG("visibility : %f", alpha);
|
||||
interface_setTouchMenuVisibility(alpha);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchKeyboardVisibility(JNIEnv *env, jclass cls, jfloat inactiveAlpha, jfloat activeAlpha) {
|
||||
LOG("inactive:%f active:%f", inactiveAlpha, activeAlpha);
|
||||
keydriver_setVisibilityWhenOwnsScreen(inactiveAlpha, activeAlpha);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchJoystickButtonTypes(JNIEnv *env, jclass cls, jint touchDownButton, jint northButton, jint southButton) {
|
||||
LOG(": %d,%d,%d", touchDownButton, northButton, southButton);
|
||||
|
||||
|
@ -494,6 +494,8 @@ bool (*keydriver_isTouchKeyboardAvailable)(void) = NULL;
|
||||
void (*keydriver_setTouchKeyboardEnabled)(bool enabled) = NULL;
|
||||
void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd) = NULL;
|
||||
bool (*keydriver_ownsScreen)(void) = NULL;
|
||||
void (*keydriver_setVisibilityWhenOwnsScreen)(float inactiveAlpha, float activeAlpha) = NULL;
|
||||
void (*keydriver_setLowercaseEnabled)(bool enabled) = NULL;
|
||||
void (*keydriver_keyboardReadCallback)(void) = NULL;
|
||||
void (*keydriver_beginCalibration)(void) = NULL;
|
||||
void (*keydriver_endCalibration)(void) = NULL;
|
||||
|
@ -161,6 +161,12 @@ extern void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd);
|
||||
// query touch screen ownership
|
||||
extern bool (*keydriver_ownsScreen)(void);
|
||||
|
||||
// set visibility
|
||||
extern void (*keydriver_setVisibilityWhenOwnsScreen)(float inactiveAlpha, float activeAlpha);
|
||||
|
||||
// set visibility
|
||||
extern void (*keydriver_setLowercaseEnabled)(bool enabled);
|
||||
|
||||
// keyboard read callback
|
||||
extern void (*keydriver_keyboardReadCallback)(void);
|
||||
|
||||
|
@ -52,6 +52,7 @@ static bool isCalibrating = false; // Are we in calibration mode?
|
||||
static bool allowLowercase = false; // show lowercase keyboard
|
||||
static float minAlphaWhenOwnsScreen = 1/4.f;
|
||||
static float minAlpha = 0.f;
|
||||
static float maxAlpha = 1.f;
|
||||
|
||||
static char kbdTemplateUCase[KBD_TEMPLATE_ROWS][KBD_TEMPLATE_COLS+1] = {
|
||||
"@ @ @ @ @ ",
|
||||
@ -172,7 +173,7 @@ static inline float _get_keyboard_visibility(void) {
|
||||
float alpha = minAlpha;
|
||||
deltat = timespec_diff(kbd.timingBegin, now, NULL);
|
||||
if (deltat.tv_sec == 0) {
|
||||
alpha = 1.0;
|
||||
alpha = maxAlpha;
|
||||
if (deltat.tv_nsec >= NANOSECONDS_PER_SECOND/2) {
|
||||
alpha -= ((float)deltat.tv_nsec-(NANOSECONDS_PER_SECOND/2)) / (float)(NANOSECONDS_PER_SECOND/2);
|
||||
if (alpha < minAlpha) {
|
||||
@ -732,6 +733,23 @@ static bool gltouchkbd_ownsScreen(void) {
|
||||
return ownsScreen;
|
||||
}
|
||||
|
||||
static void gltouchkbd_setVisibilityWhenOwnsScreen(float inactiveAlpha, float activeAlpha) {
|
||||
minAlphaWhenOwnsScreen = inactiveAlpha;
|
||||
maxAlpha = activeAlpha;
|
||||
if (ownsScreen) {
|
||||
minAlpha = minAlphaWhenOwnsScreen;
|
||||
}
|
||||
}
|
||||
|
||||
static void gltouchkbd_setLowercaseEnabled(bool enabled) {
|
||||
allowLowercase = enabled;
|
||||
if (allowLowercase) {
|
||||
caps_lock = false;
|
||||
} else {
|
||||
caps_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void gltouchkbd_beginCalibration(void) {
|
||||
video_clear();
|
||||
isCalibrating = true;
|
||||
@ -770,6 +788,8 @@ static void _init_gltouchkbd(void) {
|
||||
keydriver_setTouchKeyboardEnabled = &gltouchkbd_setTouchKeyboardEnabled;
|
||||
keydriver_setTouchKeyboardOwnsScreen = &gltouchkbd_setTouchKeyboardOwnsScreen;
|
||||
keydriver_ownsScreen = &gltouchkbd_ownsScreen;
|
||||
keydriver_setVisibilityWhenOwnsScreen = &gltouchkbd_setVisibilityWhenOwnsScreen;
|
||||
keydriver_setLowercaseEnabled = &gltouchkbd_setLowercaseEnabled;
|
||||
keydriver_beginCalibration = &gltouchkbd_beginCalibration;
|
||||
keydriver_endCalibration = &gltouchkbd_endCalibration;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user