From 49c99d5ab79760de33091d6d8a1595388bda0b16 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sun, 23 Aug 2015 15:03:30 -0700 Subject: [PATCH] Beginnings of customized alt touch keyboard layout --- .../apple2ix/Apple2KeyboardSettingsMenu.java | 43 ++++++++++++++++ .../deadc0de/apple2ix/Apple2Preferences.java | 51 +++++++++++++++++++ Android/app/src/main/res/values/strings.xml | 6 +++ src/video/gltouchkbd.c | 6 +-- 4 files changed, 103 insertions(+), 3 deletions(-) diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2KeyboardSettingsMenu.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2KeyboardSettingsMenu.java index b4256eb4..e34f0beb 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2KeyboardSettingsMenu.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2KeyboardSettingsMenu.java @@ -173,6 +173,49 @@ public class Apple2KeyboardSettingsMenu extends Apple2AbstractMenu { }); return convertView; } + }, + KEYBOARD_CHOOSE_ALT { + @Override + public final String getTitle(Apple2Activity activity) { + return activity.getResources().getString(R.string.keyboard_choose_alt); + } + + @Override + public final String getSummary(Apple2Activity activity) { + return activity.getResources().getString(R.string.keyboard_choose_alt_summary); + } + + @Override + public final View getView(final 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) { + String[] titles = new String[Apple2Preferences.KeyboardAltPreset.size + 1]; + titles[0] = activity.getResources().getString(R.string.keyboard_preset_custom); + System.arraycopy(Apple2Preferences.KeyboardAltPreset.titles(activity), 0, titles, 1, Apple2Preferences.KeyboardAltPreset.size); + + _alertDialogHandleSelection(activity, R.string.keyboard_choose_alt_title, titles, new IPreferenceLoadSave() { + @Override + public int intValue() { + return Apple2Preferences.KEYBOARD_ALT.intValue(activity); + } + + @Override + public void saveInt(int value) { + Apple2Preferences.KEYBOARD_ALT.saveInt(activity, value); + if (value == 0) { + Apple2KeyboardSettingsMenu keyboardSettingsMenu = (Apple2KeyboardSettingsMenu) settingsMenu; + ////TODO FIXME ... keyboardSettingsMenu.chooseAltKeyboard(activity); + } else { + Apple2Preferences.KeyboardAltPreset.values()[value - 1].apply(activity); + } + } + }); + } }; public static final int size = SETTINGS.values().length; diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java index 8e0d8fe0..62f2f9d2 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java @@ -512,6 +512,17 @@ public enum Apple2Preferences { return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), defaultLatency); } }, + KEYBOARD_ALT { + @Override + public void load(Apple2Activity activity) { + /* ... */ + } + + @Override + public int intValue(Apple2Activity activity) { + return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), 1); + } + }, KEYBOARD_VISIBILITY_ACTIVE { @Override public void load(Apple2Activity activity) { @@ -763,6 +774,46 @@ public enum Apple2Preferences { } } + public enum KeyboardAltPreset { + DEFAULT { + @Override + public String getTitle(Apple2Activity activity) { + return activity.getResources().getString(R.string.keyboard_preset_default); + } + + @Override + public void apply(Apple2Activity activity) { + // TODO FIXME ... + } + }, + U4 { + @Override + public String getTitle(Apple2Activity activity) { + return activity.getResources().getString(R.string.keyboard_preset_u4); + } + + @Override + public void apply(Apple2Activity activity) { + // TODO FIXME ... + } + }; + + public abstract String getTitle(Apple2Activity activity); + + public abstract void apply(Apple2Activity activity); + + public static final int size = KeyboardAltPreset.values().length; + + public static String[] titles(Apple2Activity activity) { + String[] titles = new String[size]; + int i = 0; + for (KeyboardAltPreset preset : values()) { + titles[i++] = preset.getTitle(activity); + } + return titles; + } + } + 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; diff --git a/Android/app/src/main/res/values/strings.xml b/Android/app/src/main/res/values/strings.xml index 0a7c5c73..db372374 100644 --- a/Android/app/src/main/res/values/strings.xml +++ b/Android/app/src/main/res/values/strings.xml @@ -71,10 +71,16 @@ [Space] Keyboard + Choose alt keyboard… + Choose alternative customized layout + Alt keyboard layout Configure keyboard… Transparency, lowercase, custom keys Enable lowercase Enable lowercase keys + Load custom… + Default + U4 optimized Visibility when active Keyboard visibility when active Visibility when inactive diff --git a/src/video/gltouchkbd.c b/src/video/gltouchkbd.c index bb1fb863..32eb7313 100644 --- a/src/video/gltouchkbd.c +++ b/src/video/gltouchkbd.c @@ -84,9 +84,9 @@ static char kbdTemplateAlt[KBD_TEMPLATE_ROWS][KBD_TEMPLATE_COLS+1] = { static char kbdTemplateArrow[KBD_TEMPLATE_ROWS][KBD_TEMPLATE_COLS+1] = { "@ @ @ @ @ ", " ", - " T@ ", - "A @@@ ", - " C@ ", + " @ ", + " @@@ ", + " @ ", " ", };