This commit is contained in:
Nehemiah of Zebulun 2023-08-27 09:27:18 +02:00
parent 877daf15eb
commit bf94132c1c
5 changed files with 33 additions and 3 deletions

View File

@ -19,7 +19,12 @@ class WordInputMode: InputMode {
override fun onKeyDown(key: Key): KeyEventResult {
keyStats(key)
val command = keyCommandResolver.getCommand(key)
Log.d(tag, "Command: $command")
return when(keyCommandResolver.getCommand(key)) {
Command.BACK -> KeyEventResult(false)
Command.CHARACTER -> buildCodeWord(key)
// Command.SELECT -> true
Command.DELETE -> deleteCharacter()
@ -34,6 +39,12 @@ class WordInputMode: InputMode {
override fun onKeyLongDown(key: Key): KeyEventResult {
// Log.d(tag, "onKeyLongDown")
val command = keyCommandResolver.getCommand(key = key, longPress = true)
Log.d(tag, "Command: $command")
return KeyEventResult()
}
@ -47,7 +58,18 @@ class WordInputMode: InputMode {
override fun afterKeyDown(key: Key): KeyEventResult {
// Log.d(tag, "afterKeyDown")
return KeyEventResult()
// return when(keyCommandResolver.getCommand(key, after = true)) {
// Command.DELETE -> deleteCharacter(repeat)
// else -> KeyEventResult()
// }
val command = keyCommandResolver.getCommand(key, after = true)
Log.d(tag, "Command: $command")
return KeyEventResult(false)
}
override fun afterKeyLongDown(key: Key, keyDownMS: Long): KeyEventResult {

View File

@ -14,5 +14,7 @@ enum class Command {
RIGHT,
LEFT,
RECORD,
TRANSCRIBE
TRANSCRIBE,
BACK,
HOME
}

View File

@ -18,5 +18,6 @@ enum class Key(val code: Char) {
LEFT('c'),
RIGHT('d'),
SELECT('e'),
DELETE('f')
DELETE('f'),
BACK('g'),
}

View File

@ -12,6 +12,7 @@ class KeyCodeMapping(
companion object {
val basic = mapOf(
4 to Key.BACK,
7 to Key.N0,
8 to Key.N1,
9 to Key.N2,

View File

@ -27,6 +27,7 @@ class KeyCommandResolver (
fun getBasic(): KeyCommandResolver {
return KeyCommandResolver(
onShort = HashMap(mapOf(
Key.BACK to Command.BACK,
Key.N0 to Command.SPACE,
Key.N1 to Command.CHARACTER,
@ -50,6 +51,8 @@ class KeyCommandResolver (
)),
onLong = HashMap(mapOf(
Key.BACK to Command.HOME,
Key.N0 to Command.NUMBER,
Key.N1 to Command.NUMBER,
Key.N2 to Command.NUMBER,
@ -66,6 +69,7 @@ class KeyCommandResolver (
)),
afterShort = HashMap(mapOf(
Key.BACK to Command.BACK,
Key.POUND to Command.SHIFT_MODE,
)),