diff --git a/doc/Custom-layouts.md b/doc/Custom-layouts.md index e771df7..5b18968 100644 --- a/doc/Custom-layouts.md +++ b/doc/Custom-layouts.md @@ -85,7 +85,7 @@ The following optional properties define the effects of swipes: You can define a swipe only once with either compass-point or numeric notation. Unexpected Keyboard automatically puts a small legend in that direction from the center of the key. * `slider`: If `slider="true"`, and the key also has `w` and `e` properties, then the key tracks horizontal finger motion precisely and sends the `w` and `e` keystrokes repeatedly. In built-in layouts, this makes the space bar send left and right characters as the user slides on the space bar. -* `anticircle`: The key value to send when doing an anti-clockwise gesture on the key. (The clockwise gesture applies a Shift modifier and the round-trip gesture applies a Fn modifier. These results can be redefined using a modmap, as explained below.) +* `anticircle`: The key value to send when doing an anti-clockwise gesture on the key. ### Layout A key may have the following properties to control the row's layout: @@ -97,26 +97,26 @@ Normally, a key's width is 1.0 unit. Unexpected Keyboard occupies the full width ### Extra legend * `indication`: An optional extra legend to show under the main label. For example, `` displays ABC at the bottom of the 2 key, as on a pinpad or some telephones. If the key also defines a downward swipe with `s` or `key8`, the legends overlap. -## Possible key values -The properties that define the effects of tapping or swiping a key may be one of the built-in strings documented on [this page](Possible-key-values). For example, `se="cut"` says that a southeast swipe produces the "cut" key (Ctrl-C). +### Possible key values -Some of those strings begin with `loc `. These are place-holders; the tap or swipe does nothing unless enabled through the "Add keys to keyboard" option in the Settings menu, or implicitly enabled by the language the device is set to use. For example, `ne="loc accent_aigu"` says that a northeast swipe produces the acute accent combinatorial key—if enabled. +The possible key values are described in [this page](Possible-key-values.md). -If the string defining a tap or a swipe is anything other than one of the built-in strings, the defined string is output *verbatim.* This is what most of the taps and swipes on a typical keyboard do. So `key0="a"` simply outputs the letter a. - -The string can output multiple characters, but cannot combine the built-in strings to specify a sequence of keystrokes. +In a layout, a key value can also start with the `loc` prefix. These are place-holders, the tap or swipe does nothing unless enabled through the "Add keys to keyboard" option in the Settings menu, or implicitly enabled by the language the device is set to use. +For example, `ne="loc accent_aigu"` says that a northeast swipe produces the acute accent combinatorial key—if enabled. ## Modmap The ``...`` pair encloses custom mappings for modifier keys. The modmap is placed inside the ``...`` pair, but outside any row. A layout can have at most one modmap. A modmap can contain the following tags, each of which must have an `a` and a `b` property: -* `` —This says that, if the Shift modifier is on (or the user made a clockwise gesture on a key), and if the key would normally generate the value after "a", it must instead generate the value after "b". -* `` —This says that, if the Fn modifier is on (or the user made a round-trip gesture on a key), and if the key would normally generate the value after "a", it must instead generate the value after "b". +* `` If the Shift modifier is on, the key `before` is changed into `after`. +* `` If the Fn modifier is on, the key `before` is changed into `after`. -The "a" and "b" values are as specified above in **Possible key values**. A `` tag modifies a gesture only if no `` tag did. +Valid values for `before` and `after` are listed in [Possible key values](Possible-key-values.md). There can be as many of these tags inside `` as needed. +The clockwise circle and the round-trip gestures are affected by both Shift and Fn modmaps. The Shift mappings are used first and if that did not modify the key, the Fn mappings are used instead. + ### Examples ① Turkish keyboards use the Latin alphabet, but when "i" is shifted, it should produce "İ". This is achieved with the following modmap: diff --git a/doc/Possible-key-values.md b/doc/Possible-key-values.md index caf9380..b189971 100644 --- a/doc/Possible-key-values.md +++ b/doc/Possible-key-values.md @@ -1,6 +1,9 @@ # Key values -This is an exhaustive list of special values accepted for the `key0` through `key8` or `nw` through `se` attributes on a key. Any string that does not exactly match these will be printed verbatim. +This is an exhaustive list of special values accepted for the `key0` through `key8` or `nw` through `se` attributes on a key. + +Any string that does not exactly match these will be printed verbatim. +A key can output multiple characters, but cannot combine multiple built-in key values. ## Escape codes Value | Escape code for diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 5358679..4e7c785 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -38,8 +38,9 @@ Tato aplikace neobsahuje žádné reklamy, nevyužívá připojení k síti a je Psaní Vzdálenost posunutí prstem Jak daleko je třeba posunout prst pro zadání znaku/znaménka v rohu klávey (%s) - Časová prodleva opakování znaků + Interval opakování znaků + Dvojklik pro aktivaci Capslock(u) Umožňuje zamknout Shift dvojklikem, namísto podržení Chování diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 2832e79..890d8af 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -38,8 +38,9 @@ Diese App enthält keine Werbung, benötigt keinen Netzwerkzugriff und ist quell Tippen Länge der Wischgeste Abstand der Zeichen in den Ecken der Tasten (%s) - Zeitüberschreitung bei Tastenwiederholung + Intervall der Tastenwiederholung + Umschalttaste mit Doppeltippen einrasten Anstatt Taste längere Zeit gedrückt zu halten Verhalten diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 8e14408..dc8578f 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -38,8 +38,9 @@ La misma no contiene ningún anuncio/publicidad, no realiza peticiones de red y Escritura Distancia de deslizamiento Distancia de caracteres en las esquinas de las teclas (%s) - Tiempo de espera para repetir tecla + Intervalo de repetición de tecla + Doble toque en Mayús para bloquear las mayúsculas Se puede bloquear cualquier modificador manteniéndolo presionado Comportamiento diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index ac1a48a..46e9310 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -38,8 +38,9 @@ This application contains no ads, doesn't make any network requests and is Open درحال نوشتن فاصله کشیدن فاصله حروف از گوشه‌های کلیدها )(%s) - درنگ تکرار کلید + فاصله تکرار کلید + دوبار ضربه روی دگرساز برای فعال شدن کپس لاک شما میتوانید قفل کنید هر میانبری را با نگه داشتن آن ٰرفتار diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 08928db..93d7ff0 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -38,8 +38,9 @@ Cette application ne contient pas de publicité, n'accède pas au réseau et est Saisie Distance de swipe La distance des caractères dans les coins (%s) - Délai avant répétition + Écart entre les répétitions + Appuyer deux fois pour bloquer la majuscule Un appui long bloque la majuscule Comportement diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index a69f3a2..0d58124 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -38,8 +38,9 @@ This application contains no ads, doesn't make any network requests and is Open Digitando Distanza swipe Distanza dei caratteri negli angoli dei tasti (%s) - Timeout ripetizione tasto + Intervallo ripetizione tasto + Doppio tocco su Shift per attivare CapsLock Invece di premere i modificatori a lungo diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index fe59853..c2036f2 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -38,8 +38,9 @@ This application contains no ads, doesn't make any network requests and is Open 타자 스와이프 범위 키 모서리 문자의 입력 범위 (%s) - 키 길게 누르기 지연 + 키 반복 간격 + diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index d0fc0ef..db6eded 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -38,8 +38,9 @@ Tagad lieliski piemērota izmantošanai ikdienā. Rakstīšana Pavilkšanas attālums Taustiņu stūros esošo rakstzīmju attālums (%s) - Taustiņa atkārtošanās ātrums + Taustiņa atkārtošanās aizture + Divkāršs piesitiens burtslēgam Tā vietā, lai ilstoši piespiestu pārveidotāju Uzvedība diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index a7af853..dff1b05 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -38,8 +38,9 @@ Aplikacja nie zawiera reklam, nie żąda dostępu do internetu, a jej kod źród Pisanie Odległość przesuwania Odległość znaków od rogów klawiszy (%s) - Opóźnienie powtarzania naciśnięć klawisza + Czas pomiędzy powtórzeniami + Naciśnij Shift podwójnie, aby włączyć caps lock Możesz zablokować modyfikator poprzez jego długie naciśnięcie Zachowanie diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 232ef92..651eb0b 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -38,8 +38,9 @@ Este aplicativo não contém anúncios, não faz nenhuma solicitação de rede e Digitação Distância a deslizar Distância até acionar os cantos das teclas (%s) - Tempo até repetir tecla + Intervalo de repetição de tecla + Tecle duas vezes no shift para travá-lo acionado Ao invés de apertar e segurar por um tempo Comportamento diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 9486342..13086c5 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -38,8 +38,9 @@ Această aplicație nu conține publicitate, nu folosește rețeaua deloc și e Tipărire Distanța de glisare Distanța dintre caracterele din colțurile tastelor (%s) - Timeout pentru repetarea tastelor + Intervalul de repetare a tastelor + Apăsare dublă pe Shift activează Caps Lock Puteți activa orice modificator, ținându-l apăsat Comportament diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 37f9bb7..982dcb3 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -38,8 +38,9 @@ Набор текста Длина жеста Расстояние между символами в углах клавиш (%s) - Задержка повтора клавиш + Задержка долгого нажатия Интервал повтора клавиш + Повтор клавиши при долгом нажатии CapsLock двойным нажатием Shift Также можно активировать модификатор долгим нажатием Поведение diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 31ef697..ce8c205 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -38,8 +38,9 @@ Bu uygulama açık kaynaklıdır. Reklam içermez ve internete bağlanmaz."Yazma Kaydırma mesafesi Tuşların köşelerinden kaydırma mesafesi (%s) - Tuşların tekrarlaması için geçmesi gereken süre + Tuşların tekrarlama sıklığı + CapsLock için Shift tuşuna çift bas Uzun basarak CapsLock açılabilir Klavye davranışı diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 061cb97..0f7e81f 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -38,8 +38,9 @@ Введення Відстань проведення Відстань між символами в кутах клавіш (%s) - Час очікування повтору клавіші + Час очікування тривалого натискання Інтервал повторення клавіш + Повторення клавіші при тривалому натисканні Двічі торкніться Shift для Caps Lock Ви можете заблокувати будь-який модифікатор, утримуючи його Поведінка diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index d2fc69b..a97068a 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -38,8 +38,9 @@ Bây giờ đã hoàn hảo cho việc sử dụng hàng ngày. Khoảng cách vuốt Khoảng cách giữa các ký tự ở góc phím (%s) - Thời hạn lặp phím + Khoảng thời gian lặp phím + Nhấn hai lần Shift để bật Caps Lock Bạn có thể khóa phím hỗ trợ bằng cách giữ vào nó diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 3ed9767..8809ff2 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -38,8 +38,9 @@ 输入 滑动触发距离 输入按键四角的符号需要滑动的距离 (%s) - 长按到开始重复输入的时间 + 长按后每次重复输入的时间间隔 + 双击 Shift 键锁定大写 任何时候长按修饰键均可将其锁定 行为 diff --git a/res/values/strings.xml b/res/values/strings.xml index ec84031..75df689 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -38,8 +38,9 @@ This application contains no ads, doesn't make any network requests and is Open Typing Swiping distance Distance of characters in the corners of the keys (%s) - Key repeat timeout + Long press timeout Key repeat interval + Key repeat on long press Double tap on shift for caps lock You can lock any modifier by holding it Behavior diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 270dfcd..c6c553a 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -16,7 +16,8 @@ - + + diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 980bac2..061183c 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -47,6 +47,7 @@ public final class Config public long vibrate_duration; public long longPressTimeout; public long longPressInterval; + public boolean keyrepeat_enabled; public float margin_bottom; public float keyHeight; public float horizontal_margin; @@ -153,6 +154,7 @@ public final class Config vibrate_duration = _prefs.getInt("vibrate_duration", 20); longPressTimeout = _prefs.getInt("longpress_timeout", 600); longPressInterval = _prefs.getInt("longpress_interval", 65); + keyrepeat_enabled = _prefs.getBoolean("keyrepeat_enabled", true); margin_bottom = get_dip_pref_oriented(dm, "margin_bottom", 7, 3); key_vertical_margin = get_dip_pref(dm, "key_vertical_margin", 1.5f) / 100; key_horizontal_margin = get_dip_pref(dm, "key_horizontal_margin", 2) / 100; diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 8119f21..68ebd10 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -96,7 +96,7 @@ public final class KeyboardData { Row row = rows.get(i_row); int i_col = p.col; - int i_col_end = p.col; + int i_col_end = Math.min(p.col, row.keys.size() - 1); if (p.col == -1) { i_col = 0; i_col_end = row.keys.size() - 1; } for (; i_col <= i_col_end; i_col++) { diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index 55ca9c5..0b24b8f 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -24,14 +24,14 @@ public final class Pointers implements Handler.Callback /** Can't be locked, even when long pressing. */ public static final int FLAG_P_CANT_LOCK = (1 << 7); - private Handler _keyrepeat_handler; + private Handler _longpress_handler; private ArrayList _ptrs = new ArrayList(); private IPointerEventHandler _handler; private Config _config; public Pointers(IPointerEventHandler h, Config c) { - _keyrepeat_handler = new Handler(this); + _longpress_handler = new Handler(this); _handler = h; _config = c; } @@ -62,7 +62,7 @@ public final class Pointers implements Handler.Callback public void clear() { for (Pointer p : _ptrs) - stopKeyRepeat(p); + stopLongPress(p); _ptrs.clear(); } @@ -142,7 +142,7 @@ public final class Pointers implements Handler.Callback ptr.sliding.onTouchUp(ptr); return; } - stopKeyRepeat(ptr); + stopLongPress(ptr); KeyValue ptr_value = ptr.value; if (ptr.gesture != null && ptr.gesture.is_in_progress()) { @@ -206,7 +206,7 @@ public final class Pointers implements Handler.Callback KeyValue value = _handler.modifyKey(key.keys[0], mods); Pointer ptr = new Pointer(pointerId, key, value, x, y, mods); _ptrs.add(ptr); - startKeyRepeat(ptr); + startLongPress(ptr); _handler.onPointerDown(value, false); } @@ -313,7 +313,7 @@ public final class Pointers implements Handler.Callback else { ptr.value = apply_gesture(ptr, ptr.gesture.get_gesture()); - restartKeyRepeat(ptr); + restartLongPress(ptr); ptr.flags = 0; // Special behaviors are ignored during a gesture. } } @@ -382,7 +382,7 @@ public final class Pointers implements Handler.Callback // Key repeat - /** Message from [_keyrepeat_handler]. */ + /** Message from [_longpress_handler]. */ @Override public boolean handleMessage(Message msg) { @@ -390,11 +390,7 @@ public final class Pointers implements Handler.Callback { if (ptr.timeoutWhat == msg.what) { - if (handleKeyRepeat(ptr)) - _keyrepeat_handler.sendEmptyMessageDelayed(msg.what, - _config.longPressInterval); - else - ptr.timeoutWhat = -1; + handleLongPress(ptr); return true; } } @@ -403,60 +399,62 @@ public final class Pointers implements Handler.Callback private static int uniqueTimeoutWhat = 0; - private void startKeyRepeat(Pointer ptr) + private void startLongPress(Pointer ptr) { int what = (uniqueTimeoutWhat++); ptr.timeoutWhat = what; - _keyrepeat_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout); + _longpress_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout); } - private void stopKeyRepeat(Pointer ptr) + private void stopLongPress(Pointer ptr) { - if (ptr.timeoutWhat != -1) - { - _keyrepeat_handler.removeMessages(ptr.timeoutWhat); - ptr.timeoutWhat = -1; - } + _longpress_handler.removeMessages(ptr.timeoutWhat); } - private void restartKeyRepeat(Pointer ptr) + private void restartLongPress(Pointer ptr) { - stopKeyRepeat(ptr); - startKeyRepeat(ptr); + stopLongPress(ptr); + startLongPress(ptr); } - /** A pointer is repeating. Returns [true] if repeat should continue. */ - private boolean handleKeyRepeat(Pointer ptr) + /** A pointer is long pressing. */ + private void handleLongPress(Pointer ptr) { // Long press toggle lock on modifiers if ((ptr.flags & FLAG_P_LATCHABLE) != 0) { if (!ptr.hasFlagsAny(FLAG_P_CANT_LOCK)) lockPointer(ptr, true); - return false; + return; } - // Stop repeating: Latched key, no key + // Latched key, no key if (ptr.hasFlagsAny(FLAG_P_LATCHED) || ptr.value == null) - return false; + return; + // Key is long-pressable KeyValue kv = KeyModifier.modify_long_press(ptr.value); if (!kv.equals(ptr.value)) { ptr.value = kv; _handler.onPointerDown(kv, true); - return true; + return; } - // Stop repeating: Special keys + // Special keys if (kv.hasFlagsAny(KeyValue.FLAG_SPECIAL)) - return false; - _handler.onPointerHold(kv, ptr.modifiers); - return true; + return; + // For every other keys, key-repeat + if (_config.keyrepeat_enabled) + { + _handler.onPointerHold(kv, ptr.modifiers); + _longpress_handler.sendEmptyMessageDelayed(ptr.timeoutWhat, + _config.longPressInterval); + } } // Sliding void startSliding(Pointer ptr, float x) { - stopKeyRepeat(ptr); + stopLongPress(ptr); ptr.flags |= FLAG_P_SLIDING; ptr.sliding = new Sliding(x); }