Allow setting keyboard and HUD menu glyph scale

This commit is contained in:
Aaron Culliney 2016-01-02 00:14:21 -08:00
parent 904d89aff8
commit b59672815f
14 changed files with 138 additions and 16 deletions

View File

@ -313,6 +313,31 @@ public class Apple2KeyboardSettingsMenu extends Apple2AbstractMenu {
}
});
}
},
KEYBOARD_GLYPH_SCALE {
@Override
public final String getTitle(Apple2Activity activity) {
return activity.getResources().getString(R.string.keyboard_glyph_scale);
}
@Override
public final String getSummary(Apple2Activity activity) {
return activity.getResources().getString(R.string.keyboard_glyph_scale_summary);
}
@Override
public View getView(final Apple2Activity activity, View convertView) {
convertView = _basicView(activity, this, convertView);
int glyphScale = Apple2Preferences.KEYBOARD_GLYPH_SCALE.intValue(activity);
CheckBox cb = _addCheckbox(activity, this, convertView, glyphScale > 1);
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Apple2Preferences.KEYBOARD_GLYPH_SCALE.saveInt(activity, isChecked ? 2 : 1);
}
});
return convertView;
}
};
public static final int size = SETTINGS.values().length;

View File

@ -14,11 +14,11 @@ package org.deadc0de.apple2ix;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.DisplayMetrics;
import android.util.Log;
import java.io.File;
import org.deadc0de.apple2ix.basic.BuildConfig;
import org.deadc0de.apple2ix.basic.R;
public enum Apple2Preferences {
@ -576,6 +576,41 @@ public enum Apple2Preferences {
return activity.getPreferences(Context.MODE_PRIVATE).getBoolean(toString(), true);
}
},
KEYBOARD_GLYPH_SCALE {
@Override
public void load(Apple2Activity activity) {
int scale = intValue(activity);
if (scale == 0) {
scale = 1;
}
nativeSetTouchKeyboardGlyphScale(scale);
}
@Override
public int intValue(Apple2Activity activity) {
int scale = activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), 0);
if (scale == 0) {
scale = 2;
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
/* calculating actual physical diagonal size appears to be problematic -- Samsung Galaxy Y reports 15" with this method
double x = Math.pow(dm.widthPixels / dm.xdpi, 2);
double y = Math.pow(dm.heightPixels / dm.ydpi, 2);
double screenInches = Math.sqrt(x + y);
Log.d(TAG, "Screen inches:" + screenInches + " w:" + dm.widthPixels + " h:" + dm.heightPixels);
*/
if (dm.widthPixels < 1280 || dm.heightPixels < 1280) {
scale = 1;
}
saveInt(activity, scale);
}
return scale;
}
},
CRASH_CHECK {
@Override
public void load(Apple2Activity activity) {
@ -1061,6 +1096,8 @@ public enum Apple2Preferences {
private static native void nativeSetTouchKeyboardLowercaseEnabled(boolean enabled);
private static native void nativeSetTouchKeyboardGlyphScale(int scale);
public static native int nativeGetCurrentTouchDevice();
public static native int nativeGetCPUSpeed();

View File

@ -84,6 +84,8 @@
<string name="keyboard_click_enabled_summary">Enables key click sound if available</string>
<string name="keyboard_configure">Configure keyboard…</string>
<string name="keyboard_configure_summary">Transparency, lowercase, custom keys</string>
<string name="keyboard_glyph_scale">Keyboard glyphs scaled 2x</string>
<string name="keyboard_glyph_scale_summary">(Makes keyboard appear less pixelated on large screens)</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>

View File

@ -84,6 +84,8 @@
<string name="keyboard_click_enabled_summary">Haga clic en sonido de clave permite si está disponible</string>
<string name="keyboard_configure">Configurar el teclado…</string>
<string name="keyboard_configure_summary">Transparencia, minúsculas, teclado personalizado</string>
<string name="keyboard_glyph_scale">Keyboard glyphs scaled 2x</string>
<string name="keyboard_glyph_scale_summary">(Makes keyboard appear less pixelated on large screens)</string>
<string name="keyboard_lowercase_enabled">Habilitar minúsculas</string>
<string name="keyboard_lowercase_enabled_summary">Utilice las teclas minúsculas</string>
<string name="keyboard_visibility_active">Visibilidad cuando está activo</string>

View File

@ -84,6 +84,8 @@
<string name="keyboard_click_enabled_summary">Si disponible, son du click sur une touche</string>
<string name="keyboard_configure">Configuration clavier…</string>
<string name="keyboard_configure_summary">Transparence, minuscules, touches customisées</string>
<string name="keyboard_glyph_scale">Keyboard glyphs scaled 2x</string>
<string name="keyboard_glyph_scale_summary">(Makes keyboard appear less pixelated on large screens)</string>
<string name="keyboard_lowercase_enabled">Permettre les minuscules</string>
<string name="keyboard_lowercase_enabled_summary">Permettre les touches en minuscules</string>
<string name="keyboard_visibility_active">Visibilité quand actif</string>

View File

@ -84,6 +84,8 @@
<string name="keyboard_click_enabled_summary">Enables key click sound if available</string>
<string name="keyboard_configure">Configure keyboard…</string>
<string name="keyboard_configure_summary">Transparency, lowercase, custom keys</string>
<string name="keyboard_glyph_scale">Keyboard glyphs scaled 2x</string>
<string name="keyboard_glyph_scale_summary">(Makes keyboard appear less pixelated on large screens)</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>

View File

@ -148,6 +148,12 @@ void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchKeyboardVisibili
interface_setTouchMenuVisibility(inactiveAlpha, activeAlpha);
}
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchKeyboardGlyphScale(JNIEnv *env, jclass cls, jint glyphScale) {
LOG("glyphScale:%d", glyphScale);
keydriver_setGlyphScale(glyphScale);
interface_setGlyphScale(glyphScale);
}
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetTouchJoystickButtonTypes(JNIEnv *env, jclass cls, jint touchDownButton, jint northButton, jint southButton) {
LOG(": %d,%d,%d", touchDownButton, northButton, southButton);

View File

@ -21,6 +21,7 @@ int64_t (*interface_onTouchEvent)(interface_touch_event_t action, int pointer_co
bool (*interface_isTouchMenuAvailable)(void) = NULL;
void (*interface_setTouchMenuEnabled)(bool enabled) = NULL;
void (*interface_setTouchMenuVisibility)(float inactiveAlpha, float activeAlpha) = NULL;
void (*interface_setGlyphScale)(int glyphScale) = NULL;
#endif
// 2015/04/12 : This was legacy code for rendering the menu interfaces on desktop Linux. Portions here are resurrected

View File

@ -87,6 +87,9 @@ extern void (*interface_setTouchMenuEnabled)(bool enabled);
// set min/max alpha visibility of touch menu HUD element
extern void (*interface_setTouchMenuVisibility)(float inactiveAlpha, float activeAlpha);
// set a finer-grained font size (if glyphScale > 1)
extern void (*interface_setGlyphScale)(int glyphScale);
#endif
#define EXT_GZ ".gz"

View File

@ -489,6 +489,7 @@ bool (*keydriver_isTouchKeyboardAvailable)(void) = NULL;
void (*keydriver_setTouchKeyboardEnabled)(bool enabled) = NULL;
void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd) = NULL;
bool (*keydriver_ownsScreen)(void) = NULL;
void (*keydriver_setGlyphScale)(int glyphScale) = NULL;
void (*keydriver_setVisibilityWhenOwnsScreen)(float inactiveAlpha, float activeAlpha) = NULL;
void (*keydriver_setLowercaseEnabled)(bool enabled) = NULL;
void (*keydriver_keyboardReadCallback)(void) = NULL;

View File

@ -160,10 +160,13 @@ extern void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd);
// query touch screen ownership
extern bool (*keydriver_ownsScreen)(void);
// set a finer-grained font size (if glyphScale > 1)
extern void (*keydriver_setGlyphScale)(int glyphScale);
// set visibility
extern void (*keydriver_setVisibilityWhenOwnsScreen)(float inactiveAlpha, float activeAlpha);
// set visibility
// set lowercase enabled
extern void (*keydriver_setLowercaseEnabled)(bool enabled);
// keyboard read callback

View File

@ -148,8 +148,6 @@ void glhud_setupDefault(GLModel *parent) {
const unsigned int dstRowStride = fb_w * dstPointStride;
const unsigned int texSubRowStride = dstRowStride * (glyphScale-1);
LOG("fb_h:%u, fb_w:%u -- texH:%u texW:%u", fb_h, fb_w, parent->texHeight, parent->texWidth);
do {
unsigned int srcIdx = 0;
unsigned int texIdx = 0;

View File

@ -132,6 +132,9 @@ static struct {
unsigned int glyphMultiplier;
struct timespec timingBegin;
// pending changes requiring reinitialization
unsigned int nextGlyphMultiplier;
} kbd = { 0 };
// ----------------------------------------------------------------------------
@ -502,6 +505,8 @@ static void gltouchkbd_shutdown(void) {
kbd.selectedCol = -1;
kbd.selectedRow = -1;
kbd.ctrlPressed = false;
kbd.nextGlyphMultiplier = 0;
}
static void gltouchkbd_setup(void) {
@ -541,6 +546,12 @@ static void gltouchkbd_render(void) {
return;
}
if (kbd.nextGlyphMultiplier) {
kbd.glyphMultiplier = kbd.nextGlyphMultiplier;
kbd.nextGlyphMultiplier = 0;
gltouchkbd_setup();
}
float alpha = _get_keyboard_visibility();
if (alpha > 0.0) {
@ -671,6 +682,13 @@ static bool gltouchkbd_ownsScreen(void) {
return ownsScreen;
}
static void gltouchkbd_setGlyphScale(int glyphScale) {
if (glyphScale == 0) {
glyphScale = 1;
}
kbd.nextGlyphMultiplier = glyphScale;
}
static void gltouchkbd_setVisibilityWhenOwnsScreen(float inactiveAlpha, float activeAlpha) {
minAlphaWhenOwnsScreen = inactiveAlpha;
maxAlpha = activeAlpha;
@ -980,6 +998,7 @@ static void _init_gltouchkbd(void) {
keydriver_beginCalibration = &gltouchkbd_beginCalibration;
keydriver_endCalibration = &gltouchkbd_endCalibration;
keydriver_loadAltKbd = &gltouchkbd_loadAltKbd;
keydriver_setGlyphScale = &gltouchkbd_setGlyphScale;
kbd.selectedCol = -1;
kbd.selectedRow = -1;

View File

@ -75,6 +75,9 @@ static struct {
unsigned int glyphMultiplier;
bool topLeftShowing;
bool topRightShowing;
// pending changes requiring reinitialization
unsigned int nextGlyphMultiplier;
} menu = { 0 };
static struct timespec timingBegin = { 0 };
@ -375,10 +378,25 @@ static void _destroy_touchmenu(GLModel *parent) {
// ----------------------------------------------------------------------------
// GLNode functions
static void gltouchmenu_shutdown(void) {
LOG("gltouchmenu_shutdown ...");
if (!isAvailable) {
return;
}
isAvailable = false;
menu.topLeftShowing = false;
menu.topRightShowing = false;
menu.nextGlyphMultiplier = 0;
mdlDestroyModel(&menu.model);
}
static void gltouchmenu_setup(void) {
LOG("gltouchmenu_setup ...");
mdlDestroyModel(&menu.model);
gltouchmenu_shutdown();
GLsizei texW = MENU_FB_WIDTH * menu.glyphMultiplier;
GLsizei texH = MENU_FB_HEIGHT * menu.glyphMultiplier;
@ -403,17 +421,6 @@ static void gltouchmenu_setup(void) {
GL_ERRLOG("gltouchmenu_setup");
}
static void gltouchmenu_shutdown(void) {
LOG("gltouchmenu_shutdown ...");
if (!isAvailable) {
return;
}
isAvailable = false;
mdlDestroyModel(&menu.model);
}
static void gltouchmenu_render(void) {
if (!isAvailable) {
return;
@ -422,6 +429,12 @@ static void gltouchmenu_render(void) {
return;
}
if (menu.nextGlyphMultiplier) {
menu.glyphMultiplier = menu.nextGlyphMultiplier;
menu.nextGlyphMultiplier = 0;
gltouchmenu_setup();
}
float alpha = _get_menu_visibility();
if (alpha <= 0.0) {
return;
@ -545,6 +558,13 @@ static void gltouchmenu_setTouchMenuVisibility(float inactiveAlpha, float active
maxAlpha = activeAlpha;
}
static void gltouchmenu_setGlyphScale(int glyphScale) {
if (glyphScale == 0) {
glyphScale = 1;
}
menu.nextGlyphMultiplier = glyphScale;
}
// ----------------------------------------------------------------------------
// Constructor
@ -558,6 +578,7 @@ static void _init_gltouchmenu(void) {
interface_isTouchMenuAvailable = &gltouchmenu_isTouchMenuAvailable;
interface_setTouchMenuEnabled = &gltouchmenu_setTouchMenuEnabled;
interface_setTouchMenuVisibility = &gltouchmenu_setTouchMenuVisibility;
interface_setGlyphScale = &gltouchmenu_setGlyphScale;
menu.glyphMultiplier = 1;