abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2022-03-19 16:27:57 +0100
committerJules Aguillon2022-03-19 16:27:57 +0100
commitba6d62dee2a1c0dae63eb758551b089a7cd9ffc1 (patch)
tree85a271c17ed1f8ab4eb7f14091ebcaada43ad099
parente872c5878874bdd035b9ca870853068a53cfc002 (diff)
downloadunexpected-keyboard-ba6d62dee2a1c0dae63eb758551b089a7cd9ffc1.tar.gz
unexpected-keyboard-ba6d62dee2a1c0dae63eb758551b089a7cd9ffc1.zip
Add F11 and F12
These keys are shown only when Fn is activated, "placeholder" keys are placed in the layouts.
-rw-r--r--res/xml/azerty.xml4
-rw-r--r--res/xml/dvorak.xml4
-rw-r--r--res/xml/local_bgph1.xml4
-rw-r--r--res/xml/local_ru_jcuken.xml4
-rw-r--r--res/xml/numeric.xml4
-rw-r--r--res/xml/qwerty.xml2
-rw-r--r--res/xml/qwerty_es.xml2
-rw-r--r--res/xml/qwerty_lv.xml4
-rw-r--r--res/xml/qwerty_pt.xml4
-rw-r--r--res/xml/qwerty_sv_se.xml35
-rw-r--r--res/xml/qwertz.xml4
-rw-r--r--srcs/juloo.keyboard2/KeyModifier.java40
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java2
13 files changed, 63 insertions, 50 deletions
diff --git a/res/xml/azerty.xml b/res/xml/azerty.xml
index 2369539..6e59882 100644
--- a/res/xml/azerty.xml
+++ b/res/xml/azerty.xml
@@ -9,8 +9,8 @@
<key key0="y" key2="6" key3="-" key4="|"/>
<key key0="u" key2="7" key4="`"/>
<key key0="i" key2="8" key3="_" key4="\\"/>
- <key key0="o" key2="9"/>
- <key key0="p" key2="0" key4="\@"/>
+ <key key0="o" key2="9" key3="f11_placeholder"/>
+ <key key0="p" key2="0" key3="f12_placeholder" key4="\@"/>
</row>
<row>
<key key0="q" key1="tab"/>
diff --git a/res/xml/dvorak.xml b/res/xml/dvorak.xml
index 6c12bd1..5fe2741 100644
--- a/res/xml/dvorak.xml
+++ b/res/xml/dvorak.xml
@@ -2,8 +2,8 @@
<keyboard>
<row>
<key key0="shift" width="1.5" key1="esc" key2="tab"/>
- <key key0="p" key1="accent_ring" key2="." key3="&lt;"/>
- <key key0="y" key1="accent_grave" key2="," key3="&gt;"/>
+ <key key0="p" key1="accent_ring" key2="." key3="&lt;" key4="f11_placeholder"/>
+ <key key0="y" key1="accent_grave" key2="," key3="&gt;" key4="f12_placeholder"/>
<key key0="f" key4="€"/>
<key key0="g" key2="\\" key3="|"/>
<key key0="c" key1="accent_trema" key2="accent_circonflexe" key3="{" key4="}"/>
diff --git a/res/xml/local_bgph1.xml b/res/xml/local_bgph1.xml
index 7b31586..00dfbe7 100644
--- a/res/xml/local_bgph1.xml
+++ b/res/xml/local_bgph1.xml
@@ -4,8 +4,8 @@
<key key0="я" key1="esc" key2="1" key3="ч" key4="!"/>
<key key0="в" key2="2" key3="\@"/>
<key key0="е" key2="3" key3="\#" key4="№"/>
- <key key0="р" key2="4" key3="$"/>
- <key key0="т" key2="5" key3="%"/>
+ <key key0="р" key2="4" key3="$" key4="f11_placeholder"/>
+ <key key0="т" key2="5" key3="%" key4="f12_placeholder"/>
<key key0="ъ" key2="6" key3="^" key4="€"/>
<key key0="у" key2="7" key3="&amp;" key4="§"/>
<key key0="и" key2="8" key3="*"/>
diff --git a/res/xml/local_ru_jcuken.xml b/res/xml/local_ru_jcuken.xml
index 6e8535f..3869eb2 100644
--- a/res/xml/local_ru_jcuken.xml
+++ b/res/xml/local_ru_jcuken.xml
@@ -11,8 +11,8 @@
<key key0="ш" key2="8" key3="*"/>
<key key0="щ" key2="9" key3="(" key4=")"/>
<key key0="з" key2="0"/>
- <key key0="х" key1="{" key2="}"/>
- <key key0="ъ" key1="[" key2="]" />
+ <key key0="х" key1="{" key2="}" key4="f11_placeholder"/>
+ <key key0="ъ" key1="[" key2="]" key4="f12_placeholder"/>
</row>
<row>
<key shift="0.5" key0="ф" key1="tab" key2="`"/>
diff --git a/res/xml/numeric.xml b/res/xml/numeric.xml
index b8161db..ec5b773 100644
--- a/res/xml/numeric.xml
+++ b/res/xml/numeric.xml
@@ -28,8 +28,8 @@
<row height="0.95">
<key width="1.5" key0="ctrl" key3="switch_text"/>
<key width="1.5" key0="0"/>
- <key width="0.75" key0="." key1=":" key2=","/>
- <key width="0.75" key0="space" key1="&quot;" key2="'" key4="_"/>
+ <key width="0.75" key0="." key1=":" key2="," key3="f11_placeholder"/>
+ <key width="0.75" key0="space" key1="&quot;" key2="'" key3="f12_placeholder" key4="_"/>
<key width="1.5" key0="enter" key1="±" key2="action" key3="="/>
</row>
</keyboard>
diff --git a/res/xml/qwerty.xml b/res/xml/qwerty.xml
index ffd7ed7..70640c0 100644
--- a/res/xml/qwerty.xml
+++ b/res/xml/qwerty.xml
@@ -10,7 +10,7 @@
<key key0="u" key2="7" key3="&amp;"/>
<key key0="i" key2="8" key3="*"/>
<key key0="o" key1="accent_macron" key2="9" key3="(" key4=")"/>
- <key key0="p" key2="0"/>
+ <key key0="p" key2="0" key3="f11_placeholder" key4="f12_placeholder"/>
</row>
<row>
<key shift="0.5" key0="a" key1="tab" key2="`"/>
diff --git a/res/xml/qwerty_es.xml b/res/xml/qwerty_es.xml
index 69642db..2db0cfb 100644
--- a/res/xml/qwerty_es.xml
+++ b/res/xml/qwerty_es.xml
@@ -10,7 +10,7 @@
<key key0="u" key2="7" key3="&amp;"/>
<key key0="i" key2="8" key3="*"/>
<key key0="o" key2="9" key3="(" key4=")"/>
- <key key0="p" key2="0"/>
+ <key key0="p" key2="0" key3="f11_placeholder" key4="f12_placeholder"/>
</row>
<row>
<key key0="a" key2="`" key3="tab" key4="¡"/>
diff --git a/res/xml/qwerty_lv.xml b/res/xml/qwerty_lv.xml
index 665cd60..e828851 100644
--- a/res/xml/qwerty_lv.xml
+++ b/res/xml/qwerty_lv.xml
@@ -4,8 +4,8 @@
<key key0="q" key1="esc" key2="1" key3="~" key4="!"/>
<key key0="w" key2="2" key3="\@"/>
<key key0="e" key1="ē" key2="3" key3="\#" key4="€"/>
- <key key0="r" key1="ŗ" key2="4" key3="$"/>
- <key key0="t" key2="5" key3="%"/>
+ <key key0="r" key1="ŗ" key2="4" key3="$" key4="f11_placeholder"/>
+ <key key0="t" key2="5" key3="%" key4="f12_placeholder"/>
<key key0="y" key2="6" key3="^"/>
<key key0="u" key1="ū" key2="7" key3="&amp;"/>
<key key0="i" key1="ī" key2="8" key3="*"/>
diff --git a/res/xml/qwerty_pt.xml b/res/xml/qwerty_pt.xml
index 139cbde..3b02cec 100644
--- a/res/xml/qwerty_pt.xml
+++ b/res/xml/qwerty_pt.xml
@@ -4,8 +4,8 @@
<key key0="q" key1="esc" key2="1" key3="~" key4="!"/>
<key key0="w" key2="2" key3="\@"/>
<key key0="e" key1="£" key2="3" key3="\#" key4="€"/>
- <key key0="r" key2="4" key3="$"/>
- <key key0="t" key2="5" key3="%"/>
+ <key key0="r" key2="4" key3="$" key4="f11_placeholder"/>
+ <key key0="t" key2="5" key3="%" key4="f12_placeholder"/>
<key key0="y" key1="accent_caron" key2="6" key3="^" key4="accent_trema"/>
<key key0="u" key2="7" key3="&amp;"/>
<key key0="i" key2="8" key3="*"/>
diff --git a/res/xml/qwerty_sv_se.xml b/res/xml/qwerty_sv_se.xml
index 26a8fe5..3ecea43 100644
--- a/res/xml/qwerty_sv_se.xml
+++ b/res/xml/qwerty_sv_se.xml
@@ -5,38 +5,37 @@
<key key0="w" key2="2" key4="\@"/>
<key key0="e" key2="3" key4="\#" key3="€"/>
<key key0="r" key2="4" key4="$"/>
- <key key0="t" key2="5" key3="&amp;" key4="|" />
+ <key key0="t" key2="5" key3="&amp;" key4="|"/>
<key key0="y" key2="6" key3="^" key4="%"/>
- <key key0="u" key2="7" key3="~" key4="\\" />
- <key key0="i" key2="8" key3="*" key4="/" />
+ <key key0="u" key2="7" key3="~" key4="\\"/>
+ <key key0="i" key2="8" key3="*" key4="/"/>
<key key0="o" key2="9" key3="+" key4="-"/>
- <key key0="p" key2="0" key3="=" />
- <key key0="å" key1="\?" key3="!" key2="`" />
+ <key key0="p" key2="0" key3="=" key4="f11_placeholder"/>
+ <key key0="å" key1="\?" key3="!" key2="`" key4="f12_placeholder"/>
</row>
<row>
- <key key0="a" key1="tab" />
+ <key key0="a" key1="tab"/>
<key key0="s" key1="accent_ring" key2="accent_cedille" key3="ß" key4="accent_tilde"/>
<key key0="d" key1="accent_grave" key2="accent_caron" key3="accent_aigu"/>
<key key0="f" key1="accent_trema" key2="accent_circonflexe"/>
- <key key0="g" />
- <key key0="h" />
- <key key0="j" key1="{" key4="}" />
- <key key0="k" key1="[" key4="]" />
- <key key0="l" key1="(" key4=")" />
- <key key0="ö" key1="&lt;" key4="&gt;" />
+ <key key0="g"/>
+ <key key0="h"/>
+ <key key0="j" key1="{" key4="}"/>
+ <key key0="k" key1="[" key4="]"/>
+ <key key0="l" key1="(" key4=")"/>
+ <key key0="ö" key1="&lt;" key4="&gt;"/>
<key key0="ä" key1="'" key3="&quot;"/>
-
</row>
<row>
<key width="1.5" key0="shift"/>
- <key key0="z" />
- <key key0="x" />
- <key key0="c" />
- <key key0="v" />
+ <key key0="z"/>
+ <key key0="x"/>
+ <key key0="c"/>
+ <key key0="v"/>
<key key0="b" key2=";" key4=","/>
<key key0="n" key2=":" key4="."/>
<key key0="m" key2="-" key4="_"/>
- <key width="1.0" key0="." key1="!" key2="\?" key3="'" key4="," />
+ <key width="1.0" key0="." key1="!" key2="\?" key3="'" key4=","/>
<key width="1.5" key0="backspace" key2="delete"/>
</row>
</keyboard>
diff --git a/res/xml/qwertz.xml b/res/xml/qwertz.xml
index a0cb1ec..6c9597b 100644
--- a/res/xml/qwertz.xml
+++ b/res/xml/qwertz.xml
@@ -4,8 +4,8 @@
<key key0="q" key1="esc" key2="1" key3="\@" key4="!"/>
<key key0="w" key1="^" key2="2" key3="&quot;"/>
<key key0="e" key1="§" key2="3" key4="€"/>
- <key key0="r" key2="4" key3="$"/>
- <key key0="t" key2="5" key3="%"/>
+ <key key0="r" key2="4" key3="$" key4="f11_placeholder"/>
+ <key key0="t" key2="5" key3="%" key4="f12_placeholder"/>
<key key0="z" key2="6" key3="&amp;" key4="{"/>
<key key0="u" key2="7" key3="ü" key4="}"/>
<key key0="i" key1="(" key2="8" key4="["/>
diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java
index a44794e..713b4db 100644
--- a/srcs/juloo.keyboard2/KeyModifier.java
+++ b/srcs/juloo.keyboard2/KeyModifier.java
@@ -7,27 +7,29 @@ import java.util.HashMap;
class KeyModifier
{
- /* Cache key is KeyValue's name */
+ /** Cache key is KeyValue's name */
private static HashMap<String, SparseArray<KeyValue>> _cache =
new HashMap<String, SparseArray<KeyValue>>();
- /* Modify a key according to modifiers. */
+ /** Represents a removed key, because a cache entry can't be [null]. */
+ private static final KeyValue removed_key = KeyValue.getKeyByName("removed");
+
+ /** Modify a key according to modifiers. */
public static KeyValue handleFlags(KeyValue k, int flags)
{
- if (k == null || flags == 0) // No modifier
- return k;
+ if (k == null)
+ return null;
SparseArray<KeyValue> ks = cacheEntry(k);
KeyValue r = ks.get(flags);
- if (r != null) // Found in cache
- return r;
- r = k;
- r = handleFn(r, flags);
- if (r != null)
+ if (r == null) // Cold cache
+ {
+ r = k;
+ r = handleFn(r, flags);
r = handleShift(r, flags);
- if (r != null)
r = handleAccents(r, flags);
- ks.put(flags, r);
- return r;
+ ks.put(flags, r);
+ }
+ return (r == removed_key) ? null : r;
}
private static KeyValue handleAccents(KeyValue k, int flags)
@@ -185,7 +187,15 @@ class KeyModifier
private static KeyValue handleFn(KeyValue k, int flags)
{
if ((flags & KeyValue.FLAG_FN) == 0)
- return k;
+ {
+ switch (k.name)
+ {
+ // Remove some keys when Fn is *not* activated
+ case "f11_placeholder":
+ case "f12_placeholder": return removed_key;
+ default: return k;
+ }
+ }
String name;
switch (k.name)
{
@@ -199,6 +209,8 @@ class KeyModifier
case "8": name = "f8"; break;
case "9": name = "f9"; break;
case "0": name = "f10"; break;
+ case "f11_placeholder": name = "f11"; break;
+ case "f12_placeholder": name = "f12"; break;
case "up": name = "page_up"; break;
case "down": name = "page_down"; break;
case "left": name = "home"; break;
@@ -213,7 +225,7 @@ class KeyModifier
case "#": name = "£"; break;
case "*": name = "°"; break;
case "tab": name = "\\t"; break;
- case "€": case "£": return null; // Avoid showing these twice
+ case "€": case "£": return removed_key; // Avoid showing these twice
default: return k;
}
return KeyValue.getKeyByName(name);
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 450f585..f290709 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -259,6 +259,8 @@ class KeyValue
addEventKey("f8", "F8", KeyEvent.KEYCODE_F8);
addEventKey("f9", "F9", KeyEvent.KEYCODE_F9);
addEventKey("f10", "F10", KeyEvent.KEYCODE_F10);
+ addEventKey("f11", "F11", KeyEvent.KEYCODE_F11, FLAG_SMALLER_FONT);
+ addEventKey("f12", "F12", KeyEvent.KEYCODE_F12, FLAG_SMALLER_FONT);
addEventKey("tab", "↹", KeyEvent.KEYCODE_TAB);
addKey("\\t", "\\t", '\t', EVENT_NONE, 0); // Send the tab character