mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
hangul ime
This commit is contained in:
@@ -10,8 +10,8 @@ data class TerrarumKeyLayout(
|
||||
|
||||
data class TerrarumInputMethod(
|
||||
val name: String,
|
||||
// (keycodes, shiftin, altgrin)
|
||||
val acceptChar: (IntArray, Boolean, Boolean) -> Pair<String, String>, // Pair<Display Char, Output Char if any>
|
||||
// (headkey, shiftin, altgrin)
|
||||
val acceptChar: (Int, Boolean, Boolean) -> Pair<String, String>, // Pair<Display Char, Output Char if any>
|
||||
val endCompose: () -> String,
|
||||
val reset: () -> Unit,
|
||||
val composing: () -> Boolean
|
||||
@@ -106,8 +106,8 @@ object IME {
|
||||
val name = jsval.getMember("n").asString()
|
||||
|
||||
|
||||
return TerrarumInputMethod(name, { it, shifted, alted ->
|
||||
val a = jsval.invokeMember("accept", context.eval("js", "'${it.joinToString(",")}'.split(',')"), shifted, alted)
|
||||
return TerrarumInputMethod(name, { headkey, shifted, alted ->
|
||||
val a = jsval.invokeMember("accept", headkey, shifted, alted)
|
||||
a.getArrayElement(0).asString() to a.getArrayElement(1).asString()
|
||||
}, {
|
||||
jsval.invokeMember("end").asString()
|
||||
|
||||
@@ -276,7 +276,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
companion object {
|
||||
data class TerrarumKeyboardEvent(
|
||||
val type: Int,
|
||||
val character: String?,
|
||||
val character: String?, // representative key symbol
|
||||
val headkey: Int, // representative keycode
|
||||
val repeatCount: Int,
|
||||
val keycodes: IntArray
|
||||
)
|
||||
@@ -318,11 +319,15 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
else if (shiftin && newKeysym0[1]?.isNotBlank() == true) newKeysym0[1]
|
||||
else newKeysym0[0]
|
||||
|
||||
val headKeyCode = if (keyDiff.size < 1) keys[0] else keyDiff[0]
|
||||
|
||||
if (!keyChanged) {
|
||||
callback(TerrarumKeyboardEvent(KEY_DOWN, keysym, repeatCount, keys))
|
||||
// println("KEY_DOWN '$keysym' ($headKeyCode) $repeatCount; ${keys.joinToString()}")
|
||||
callback(TerrarumKeyboardEvent(KEY_DOWN, keysym, headKeyCode, repeatCount, keys))
|
||||
}
|
||||
else if (newKeysym != null) {
|
||||
callback(TerrarumKeyboardEvent(KEY_DOWN, newKeysym, repeatCount, keys))
|
||||
// println("KEY_DOWC '$newKeysym' ($headKeyCode) $repeatCount; ${keys.joinToString()}")
|
||||
callback(TerrarumKeyboardEvent(KEY_DOWN, newKeysym, headKeyCode, repeatCount, keys))
|
||||
}
|
||||
|
||||
oldKeys = keys // don't put this outside of if-cascade
|
||||
@@ -346,7 +351,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
private fun keysToStr(keymap: TerrarumKeyLayout, keys: IntArray): Array<String?>? {
|
||||
if (keys.size == 0) return null
|
||||
val headkey = keys[0]
|
||||
return if (keymap.symbols!![headkey] == null) null else keymap.symbols!![headkey]
|
||||
return keymap.symbols?.get(headkey)
|
||||
}
|
||||
|
||||
private fun strobeKeys(): IntArray {
|
||||
|
||||
Reference in New Issue
Block a user