abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2022-10-23 21:34:05 +0200
committerJules Aguillon2022-10-23 21:37:04 +0200
commit36e10a792ffd034ffb56e48e2e2282f6ae16cc8d (patch)
treeaf8b28705250fd8a1a685d0bc79c759cd5b66059
parent55cece796588ad58646d9ea877912510af06e24e (diff)
downloadunexpected-keyboard-36e10a792ffd034ffb56e48e2e2282f6ae16cc8d.tar.gz
unexpected-keyboard-36e10a792ffd034ffb56e48e2e2282f6ae16cc8d.zip
Add the capslock key
The key enable caps lock immediately. It does nothing if caps lock is already enabled. It is not present on the keyboard by default but a place is defined on every layout, top-right of the shift key. It can be enabled in the settings. The icon is from materialdesignicons.com.
-rw-r--r--res/xml/azerty.xml2
-rw-r--r--res/xml/bangla.xml2
-rw-r--r--res/xml/bone.xml2
-rw-r--r--res/xml/colemak.xml2
-rw-r--r--res/xml/greekmath.xml2
-rw-r--r--res/xml/hindi.xml2
-rw-r--r--res/xml/jcuken_ua.xml2
-rw-r--r--res/xml/local_bgph1.xml2
-rw-r--r--res/xml/local_ru_jcuken.xml2
-rw-r--r--res/xml/neo2.xml2
-rw-r--r--res/xml/qwerty.xml2
-rw-r--r--res/xml/qwerty_el.xml2
-rw-r--r--res/xml/qwerty_es.xml2
-rw-r--r--res/xml/qwerty_hu.xml2
-rw-r--r--res/xml/qwerty_ko.xml2
-rw-r--r--res/xml/qwerty_lv.xml2
-rw-r--r--res/xml/qwerty_no.xml2
-rw-r--r--res/xml/qwerty_pt.xml2
-rw-r--r--res/xml/qwerty_sv_se.xml2
-rw-r--r--res/xml/qwerty_tr.xml2
-rw-r--r--res/xml/qwertz.xml2
-rw-r--r--res/xml/qwertz_cs.xml2
-rw-r--r--res/xml/qwertz_hu.xml2
-rw-r--r--res/xml/settings.xml4
-rw-r--r--srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java1
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java2
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java4
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java9
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java4
-rw-r--r--srcs/juloo.keyboard2/Pointers.java11
-rw-r--r--srcs/special_font/12.svg2
-rw-r--r--srcs/special_font/result.ttfbin7136 -> 7240 bytes
32 files changed, 50 insertions, 33 deletions
diff --git a/res/xml/azerty.xml b/res/xml/azerty.xml
index d025f1b..a91315d 100644
--- a/res/xml/azerty.xml
+++ b/res/xml/azerty.xml
@@ -25,7 +25,7 @@
<key key0="m" key3="*"/>
</row>
<row>
- <key width="2.0" key0="shift"/>
+ <key width="2.0" key0="shift" key2="loc capslock"/>
<key key0="w" key3="&lt;" key4="&gt;"/>
<key key0="x"/>
<key key0="c" key1="accent_cedille" key3="," key4="\?"/>
diff --git a/res/xml/bangla.xml b/res/xml/bangla.xml
index 9926b8c..9d70e37 100644
--- a/res/xml/bangla.xml
+++ b/res/xml/bangla.xml
@@ -24,7 +24,7 @@
<key key0="দ" key1="_" key2="ধ" key3="(" key4=")"/>
</row>
<row>
- <key width="1.4" key0="shift"/>
+ <key width="1.4" key0="shift" key2="loc capslock"/>
<key shift="0.1" key0="্র" key2="্য" key3="\#" key4="*"/>
<key key0="ো" key1="ৌ" key2="ও" key3="ঔ" key4="\@"/>
<key key0="ে" key1="ৈ" key2="এ" key3="ঐ" key4="%"/>
diff --git a/res/xml/bone.xml b/res/xml/bone.xml
index c107e88..d84622a 100644
--- a/res/xml/bone.xml
+++ b/res/xml/bone.xml
@@ -25,7 +25,7 @@
<key key0="g" key1="\@" key3=":"/>
</row>
<row>
- <key width="1.5" key0="shift" key4="\#"/>
+ <key width="1.5" key0="shift" key4="\#" key2="loc capslock"/>
<key key0="f" key4="|"/>
<key key0="v" key4="~"/>
<key key0="ß" key4="`"/>
diff --git a/res/xml/colemak.xml b/res/xml/colemak.xml
index c232dc0..6e968c9 100644
--- a/res/xml/colemak.xml
+++ b/res/xml/colemak.xml
@@ -26,7 +26,7 @@
</row>
<row>
- <key key0="shift" width="1.5" />
+ <key key0="shift" key2="loc capslock" width="1.5" />
<key key0="z" key1="," key2="."/>
<key key0="x" key1="&gt;" key2="&lt;"/>
<key key0="c" key1="{" key2="}" key3="loc accent_cedille"/>
diff --git a/res/xml/greekmath.xml b/res/xml/greekmath.xml
index 8db582d..ff467e8 100644
--- a/res/xml/greekmath.xml
+++ b/res/xml/greekmath.xml
@@ -25,7 +25,7 @@
<key key0="γ" key1="⌀"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="φ" key3="⇌" key4="√"/>
<key key0="η" key3="accent_arrow_right" key4="∪"/>
<key key0="ϡ" key4="∩"/>
diff --git a/res/xml/hindi.xml b/res/xml/hindi.xml
index feb95fb..cf8e038 100644
--- a/res/xml/hindi.xml
+++ b/res/xml/hindi.xml
@@ -24,7 +24,7 @@
<key key0="त" key1="थ" key2="ख़" key3="(" key4=")"/>
</row>
<row>
- <key width="1.4" key0="shift"/>
+ <key width="1.4" key0="shift" key2="loc capslock"/>
<key shift="0.1" key0="ट" key1="ठ" key2="ड़" key3="\#" key4="*"/>
<key key0="ं" key1="ँ" key2="।" key3="ॐ" key4="\@"/>
<key key0="म" key1="ण" key2="य" key3="य़" key4="%"/>
diff --git a/res/xml/jcuken_ua.xml b/res/xml/jcuken_ua.xml
index c223805..5b2027e 100644
--- a/res/xml/jcuken_ua.xml
+++ b/res/xml/jcuken_ua.xml
@@ -27,7 +27,7 @@
<key key0="є" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.1" key0="shift"/>
+ <key width="1.1" key0="shift" key2="loc capslock"/>
<key key0="я"/>
<key key0="ч" />
<key key0="с" />
diff --git a/res/xml/local_bgph1.xml b/res/xml/local_bgph1.xml
index 601c18b..c84d54e 100644
--- a/res/xml/local_bgph1.xml
+++ b/res/xml/local_bgph1.xml
@@ -24,7 +24,7 @@
<key key0="л" key1="щ" key2="|" key3="\\" key4="ю"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="з"/>
<key key0="ь" key3="ѝ"/>
<key key0="ц" key2="&lt;" key3="."/>
diff --git a/res/xml/local_ru_jcuken.xml b/res/xml/local_ru_jcuken.xml
index d153819..8414f27 100644
--- a/res/xml/local_ru_jcuken.xml
+++ b/res/xml/local_ru_jcuken.xml
@@ -28,7 +28,7 @@
<key key0="э" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.18" key0="shift"/>
+ <key width="1.18" key0="shift" key2="loc capslock"/>
<key width="0.96" key0="я"/>
<key width="0.96" key0="ч"/>
<key width="0.96" key0="с"/>
diff --git a/res/xml/neo2.xml b/res/xml/neo2.xml
index 1ed75b8..96265f2 100644
--- a/res/xml/neo2.xml
+++ b/res/xml/neo2.xml
@@ -27,7 +27,7 @@
<key key0="y" key3="\@"/>
</row>
<row>
- <key width="1.5" key0="shift" key1="esc"/>
+ <key width="1.5" key0="shift" key1="esc" key2="loc capslock"/>
<key key0="ü" key4="\#"/>
<key key0="ö" key4="$"/>
<key key0="ä" key4="|"/>
diff --git a/res/xml/qwerty.xml b/res/xml/qwerty.xml
index 2e2a4a5..31429c1 100644
--- a/res/xml/qwerty.xml
+++ b/res/xml/qwerty.xml
@@ -24,7 +24,7 @@
<key key0="l" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c" key1="loc accent_cedille" key2="&lt;" key3="."/>
diff --git a/res/xml/qwerty_el.xml b/res/xml/qwerty_el.xml
index 7a05bda..9aff8b9 100644
--- a/res/xml/qwerty_el.xml
+++ b/res/xml/qwerty_el.xml
@@ -24,7 +24,7 @@
<key key0="λ" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="ζ"/>
<key key0="χ"/>
<key key0="ψ" key2="&lt;" key3="."/>
diff --git a/res/xml/qwerty_es.xml b/res/xml/qwerty_es.xml
index 4aee20d..7b2ead2 100644
--- a/res/xml/qwerty_es.xml
+++ b/res/xml/qwerty_es.xml
@@ -25,7 +25,7 @@
<key key0="ñ" key1="·" key3="ç" />
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c" key1="loc accent_cedille" key2="&lt;" key3="."/>
diff --git a/res/xml/qwerty_hu.xml b/res/xml/qwerty_hu.xml
index f97f2f9..95e1fee 100644
--- a/res/xml/qwerty_hu.xml
+++ b/res/xml/qwerty_hu.xml
@@ -24,7 +24,7 @@
<key key0="l" key1="$" key3="/"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z" key3="&lt;" key4="&gt;"/>
<key key0="x" key4="\#"/>
<key key0="c" key4="&amp;"/>
diff --git a/res/xml/qwerty_ko.xml b/res/xml/qwerty_ko.xml
index 76fefa1..62f7fb7 100644
--- a/res/xml/qwerty_ko.xml
+++ b/res/xml/qwerty_ko.xml
@@ -24,7 +24,7 @@
<key key0="ㅣ" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="ㅋ"/>
<key key0="ㅌ"/>
<key key0="ㅊ" key2="&lt;" key3="."/>
diff --git a/res/xml/qwerty_lv.xml b/res/xml/qwerty_lv.xml
index 6c0c7b5..6cf8d5a 100644
--- a/res/xml/qwerty_lv.xml
+++ b/res/xml/qwerty_lv.xml
@@ -24,7 +24,7 @@
<key key0="l" key1="ļ" key2="|" key3="/" key4="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z" key1="ž"/>
<key key0="x"/>
<key key0="c" key1="č"/>
diff --git a/res/xml/qwerty_no.xml b/res/xml/qwerty_no.xml
index 35a3709..c6ed74f 100644
--- a/res/xml/qwerty_no.xml
+++ b/res/xml/qwerty_no.xml
@@ -24,7 +24,7 @@
<key key0="l" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c" key1="loc accent_cedille" key2="&lt;" key3="."/>
diff --git a/res/xml/qwerty_pt.xml b/res/xml/qwerty_pt.xml
index 9fef348..8eb34da 100644
--- a/res/xml/qwerty_pt.xml
+++ b/res/xml/qwerty_pt.xml
@@ -25,7 +25,7 @@
<key key0="ç" key1="|"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c"/>
diff --git a/res/xml/qwerty_sv_se.xml b/res/xml/qwerty_sv_se.xml
index 80ce617..63d16c2 100644
--- a/res/xml/qwerty_sv_se.xml
+++ b/res/xml/qwerty_sv_se.xml
@@ -27,7 +27,7 @@
<key key0="ä" key1="'" key3="&quot;"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c"/>
diff --git a/res/xml/qwerty_tr.xml b/res/xml/qwerty_tr.xml
index 8d83f9a..e0c60e5 100644
--- a/res/xml/qwerty_tr.xml
+++ b/res/xml/qwerty_tr.xml
@@ -24,7 +24,7 @@
<key key0="l" key2="|" key3="\\"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="z"/>
<key key0="x"/>
<key key0="c" key1="ç" key2="&lt;" key3="."/>
diff --git a/res/xml/qwertz.xml b/res/xml/qwertz.xml
index f54f698..9b01a23 100644
--- a/res/xml/qwertz.xml
+++ b/res/xml/qwertz.xml
@@ -24,7 +24,7 @@
<key key0="l" key1="'" key3="\#"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="y" key1="&gt;" key2="|" key3="&lt;"/>
<key key0="x"/>
<key key0="c"/>
diff --git a/res/xml/qwertz_cs.xml b/res/xml/qwertz_cs.xml
index 7a14e84..5a4d4fd 100644
--- a/res/xml/qwertz_cs.xml
+++ b/res/xml/qwertz_cs.xml
@@ -24,7 +24,7 @@
<key key0="l" key2="ľ" key3="\\" key4="ĺ"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="y" key1="÷" key2="ý"/>
<key key0="x" key1="∙" key3="×"/>
<key key0="c" key1="\#" key2="γ" key3="&amp;" key4="č"/>
diff --git a/res/xml/qwertz_hu.xml b/res/xml/qwertz_hu.xml
index c995299..7e4f6c3 100644
--- a/res/xml/qwertz_hu.xml
+++ b/res/xml/qwertz_hu.xml
@@ -24,7 +24,7 @@
<key key0="l" key1="$" key3="/"/>
</row>
<row>
- <key width="1.5" key0="shift"/>
+ <key width="1.5" key0="shift" key2="loc capslock"/>
<key key0="y" key3="&lt;" key4="&gt;"/>
<key key0="x" key4="\#"/>
<key key0="c" key4="&amp;"/>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index f74dc90..e91c460 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -21,6 +21,10 @@
<juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="13"/>
<juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="14"/>
<juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="15"/>
+ <juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="16"/>
+ <juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="17"/>
+ <juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="18"/>
+ <juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="19"/>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_typing">
diff --git a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
index d0734b9..e66c2cc 100644
--- a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
+++ b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
@@ -33,6 +33,7 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference
"ß",
"£",
"switch_greekmath",
+ "capslock",
};
public static boolean default_checked(String name)
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 57f15f6..4623dec 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -35,6 +35,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
case ACTION: _recv.performAction(); break;
case SWITCH_PROGRAMMING: _recv.switchProgramming(); break;
case SWITCH_GREEKMATH: _recv.switchGreekmath(); break;
+ case CAPS_LOCK: _recv.enableCapsLock(); break;
}
break;
case Keyevent:
@@ -102,6 +103,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
public void setPane_normal();
public void showKeyboardConfig();
public void performAction();
+ public void enableCapsLock();
public void switchMain();
public void switchNumeric();
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 9b89101..9c88b4a 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -16,7 +16,8 @@ final class KeyValue
CHANGE_METHOD,
ACTION,
SWITCH_PROGRAMMING,
- SWITCH_GREEKMATH
+ SWITCH_GREEKMATH,
+ CAPS_LOCK,
}
// Must be evaluated in the reverse order of their values.
@@ -287,6 +288,7 @@ final class KeyValue
addEventKey("switch_greekmath", "πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT);
addEventKey("change_method", "\u0009", Event.CHANGE_METHOD, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addEventKey("action", "Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced
+ addEventKey("capslock", "\u0012", Event.CAPS_LOCK, FLAG_KEY_FONT);
addKeyeventKey("esc", "Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
addKeyeventKey("enter", "\u000E", KeyEvent.KEYCODE_ENTER, FLAG_KEY_FONT);
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 12ee196..35d5b26 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -63,9 +63,9 @@ public class Keyboard2 extends InputMethodService
public void update_shift_state(boolean should_enable, boolean should_disable)
{
if (should_enable)
- _keyboardView.set_shift_state(true);
+ _keyboardView.set_shift_state(true, false);
else if (should_disable)
- _keyboardView.set_shift_state(false);
+ _keyboardView.set_shift_state(false, false);
}
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
@@ -314,6 +314,11 @@ public class Keyboard2 extends InputMethodService
conn.performEditorAction(_config.actionId);
}
+ public void enableCapsLock()
+ {
+ _keyboardView.set_shift_state(true, true);
+ }
+
public void switchMain()
{
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index e613925..4742235 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -100,12 +100,12 @@ public class Keyboard2View extends View
}
/** Called by auto-capitalisation. */
- public void set_shift_state(boolean state)
+ public void set_shift_state(boolean state, boolean lock)
{
if (_keyboard == null || _shift_key == null)
return;
if (state)
- _pointers.add_fake_pointer(_shift_kv, _shift_key);
+ _pointers.add_fake_pointer(_shift_kv, _shift_key, lock);
else
_pointers.remove_fake_pointer(_shift_kv, _shift_key);
invalidate();
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java
index 2ac55bb..35299ab 100644
--- a/srcs/juloo.keyboard2/Pointers.java
+++ b/srcs/juloo.keyboard2/Pointers.java
@@ -75,13 +75,14 @@ public final class Pointers implements Handler.Callback
}
/** Fake pointers are latched and not lockable. */
- public void add_fake_pointer(KeyValue kv, KeyboardData.Key key)
+ public void add_fake_pointer(KeyValue kv, KeyboardData.Key key, boolean locked)
{
- // Avoid adding a fake pointer to a key that is already down.
- if (isKeyDown(key))
- return;
+ remove_fake_pointer(kv, key);
Pointer ptr = new Pointer(-1, key, kv, 0.f, 0.f, Modifiers.EMPTY);
- ptr.flags = ptr.flags & ~(KeyValue.FLAG_LATCH | KeyValue.FLAG_LOCK | KeyValue.FLAG_FAKE_PTR);
+ ptr.flags &= ~KeyValue.FLAG_LATCH;
+ ptr.flags |= KeyValue.FLAG_LOCK | KeyValue.FLAG_FAKE_PTR;
+ if (locked)
+ ptr.flags = (ptr.flags & ~KeyValue.FLAG_LOCK) | KeyValue.FLAG_LOCKED;
_ptrs.add(ptr);
}
diff --git a/srcs/special_font/12.svg b/srcs/special_font/12.svg
new file mode 100644
index 0000000..80b0480
--- /dev/null
+++ b/srcs/special_font/12.svg
@@ -0,0 +1,2 @@
+<!-- materialdesignicons.com arrow-up-bold-box-outline by Austin Andrews @Templarian -->
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,7L17,12H14V16H10V12H7L12,7M19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21M19,19V5H5V19H19Z" /></svg>
diff --git a/srcs/special_font/result.ttf b/srcs/special_font/result.ttf
index defef36..1227f27 100644
--- a/srcs/special_font/result.ttf
+++ b/srcs/special_font/result.ttf
Binary files differ