mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 23:26:07 +09:00
all US layout is changed into Intl. equivalents with AltGr support; left Ctrl+Alt can substitute AltGr; added Russian keyboard layout
This commit is contained in:
@@ -56,8 +56,8 @@ object InputStrober {
|
||||
stroboTime = System.nanoTime()
|
||||
repeatCount += 1
|
||||
|
||||
val shiftin = keys.contains(Input.Keys.SHIFT_LEFT) || keys.contains(Input.Keys.SHIFT_RIGHT)
|
||||
val altgrin = keys.contains(Input.Keys.ALT_RIGHT)
|
||||
val shiftin = keys.containsSome(Input.Keys.SHIFT_LEFT, Input.Keys.SHIFT_RIGHT)
|
||||
val altgrin = keys.contains(Input.Keys.ALT_RIGHT) || keys.containsAll(Input.Keys.ALT_LEFT, Input.Keys.CONTROL_LEFT)
|
||||
val keysym0 = keysToStr(keymap, keys)
|
||||
val newKeysym0 = keysToStr(keymap, keyDiff)
|
||||
val keysym =
|
||||
@@ -143,4 +143,19 @@ data class TerrarumKeyboardEvent(
|
||||
val headkey: Int, // representative keycode
|
||||
val repeatCount: Int,
|
||||
val keycodes: IntArray
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
fun IntArray.containsAll(vararg keys: Int): Boolean {
|
||||
keys.forEach {
|
||||
if (!this.contains(it)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun IntArray.containsSome(vararg keys: Int): Boolean {
|
||||
keys.forEach {
|
||||
if (this.contains(it)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -175,11 +175,11 @@ class UIItemTextLineInput(
|
||||
if (keycodes.contains(App.getConfigInt("control_key_toggleime")) && repeatCount == 1) {
|
||||
toggleIME()
|
||||
}
|
||||
else if (keycodes.contains(Input.Keys.V) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
||||
else if (keycodes.contains(Input.Keys.V) && keycodes.containsSome(Input.Keys.CONTROL_LEFT, Input.Keys.CONTROL_RIGHT)) {
|
||||
endComposing()
|
||||
paste(Clipboard.fetch().substringBefore('\n').substringBefore('\t').toCodePoints())
|
||||
}
|
||||
else if (keycodes.contains(Input.Keys.C) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
||||
else if (keycodes.contains(Input.Keys.C) && (keycodes.containsSome(Input.Keys.CONTROL_LEFT, Input.Keys.CONTROL_RIGHT))) {
|
||||
endComposing()
|
||||
copyToClipboard()
|
||||
}
|
||||
@@ -234,8 +234,8 @@ class UIItemTextLineInput(
|
||||
// - literal "<"
|
||||
// - keysymbol that does not start with "<" (not always has length of 1 because UTF-16)
|
||||
else if (char != null && char.length > 0 && char[0].code >= 32 && (char == "<" || !char.startsWith("<"))) {
|
||||
val shiftin = keycodes.contains(Input.Keys.SHIFT_LEFT) || keycodes.contains(Input.Keys.SHIFT_RIGHT)
|
||||
val altgrin = keycodes.contains(Input.Keys.ALT_RIGHT)
|
||||
val shiftin = keycodes.containsSome(Input.Keys.SHIFT_LEFT, Input.Keys.SHIFT_RIGHT)
|
||||
val altgrin = keycodes.contains(Input.Keys.ALT_RIGHT) || keycodes.containsAll(Input.Keys.ALT_LEFT, Input.Keys.CONTROL_LEFT)
|
||||
|
||||
val codepoints = if (ime != null) {
|
||||
val newStatus = ime.acceptChar(headkey, shiftin, altgrin, char)
|
||||
@@ -256,7 +256,7 @@ class UIItemTextLineInput(
|
||||
tryCursorBack()
|
||||
}
|
||||
}
|
||||
else if (keycodes.contains(Input.Keys.ENTER) || keycodes.contains(Input.Keys.NUMPAD_ENTER)) {
|
||||
else if (keycodes.containsSome(Input.Keys.ENTER, Input.Keys.NUMPAD_ENTER)) {
|
||||
endComposing()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user