Skip to content

Commit 5bd78a7

Browse files
committed
Port to the new keyboard input API with KeyDescriptor
1 parent 99f7bcc commit 5bd78a7

File tree

5 files changed

+469
-200
lines changed

5 files changed

+469
-200
lines changed

app/src/main/java/rs/ruffle/PlayerActivity.kt

+4-7
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ class PlayerActivity : GameActivity() {
9494
private val surfaceHeight: Int
9595
get() = mSurfaceView.height
9696

97-
private external fun keydown(keyCode: Byte, keyChar: Char)
98-
private external fun keyup(keyCode: Byte, keyChar: Char)
97+
private external fun keydown(keyTag: String)
98+
private external fun keyup(keyTag: String)
9999
private external fun requestContextMenu()
100100
private external fun runContextMenuCallback(index: Int)
101101
private external fun clearContextMenu()
@@ -178,11 +178,8 @@ class PlayerActivity : GameActivity() {
178178
for (b in keys) {
179179
b.setOnTouchListener { view: View, motionEvent: MotionEvent ->
180180
val tag = view.tag as String
181-
val spl = tag.split(" ".toRegex(), limit = 2).toTypedArray()
182-
val by = spl[0].toByte()
183-
val c: Char = if (spl.size > 1) spl[1][0] else Char.MIN_VALUE
184-
if (motionEvent.action == MotionEvent.ACTION_DOWN) keydown(by, c)
185-
if (motionEvent.action == MotionEvent.ACTION_UP) keyup(by, c)
181+
if (motionEvent.action == MotionEvent.ACTION_DOWN) keydown(tag)
182+
if (motionEvent.action == MotionEvent.ACTION_UP) keyup(tag)
186183
view.performClick()
187184
false
188185
}

0 commit comments

Comments
 (0)