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.
This commit is contained in:
Jules Aguillon 2022-10-23 21:34:05 +02:00
parent 55cece7965
commit 36e10a792f
32 changed files with 50 additions and 33 deletions

View File

@ -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="\?"/>

View File

@ -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="%"/>

View File

@ -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="`"/>

View File

@ -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"/>

View File

@ -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="∩"/>

View File

@ -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="%"/>

View File

@ -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="с" />

View File

@ -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="."/>

View File

@ -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="с"/>

View File

@ -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="|"/>

View File

@ -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="."/>

View File

@ -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="."/>

View File

@ -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="."/>

View File

@ -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;"/>

View File

@ -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="."/>

View File

@ -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="č"/>

View File

@ -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="."/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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="."/>

View File

@ -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"/>

View File

@ -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="č"/>

View File

@ -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;"/>

View File

@ -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">

View File

@ -33,6 +33,7 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference
"ß",
"£",
"switch_greekmath",
"capslock",
};
public static boolean default_checked(String name)

View File

@ -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();

View File

@ -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);

View File

@ -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));

View File

@ -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();

View File

@ -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);
}

2
srcs/special_font/12.svg Normal file
View File

@ -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>

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.