fix: IME filters out KEYCODE_BACK

This commit is contained in:
Miuzarte
2026-05-06 20:00:32 +08:00
parent 414becc592
commit 502c249b34
3 changed files with 6 additions and 3 deletions

View File

@@ -56,8 +56,8 @@ android {
applicationId = "io.github.miuzarte.scrcpyforandroid" applicationId = "io.github.miuzarte.scrcpyforandroid"
minSdk = 26 minSdk = 26
targetSdk = 37 targetSdk = 37
versionCode = 27 versionCode = 28
versionName = "0.3.1" versionName = "0.3.2"
externalNativeBuild { externalNativeBuild {
cmake { cmake {

View File

@@ -85,6 +85,7 @@ import io.github.miuzarte.scrcpyforandroid.scrcpy.Scrcpy
import io.github.miuzarte.scrcpyforandroid.scrcpy.Shared.Codec import io.github.miuzarte.scrcpyforandroid.scrcpy.Shared.Codec
import io.github.miuzarte.scrcpyforandroid.scrcpy.TouchEventHandler import io.github.miuzarte.scrcpyforandroid.scrcpy.TouchEventHandler
import io.github.miuzarte.scrcpyforandroid.services.AppRuntime import io.github.miuzarte.scrcpyforandroid.services.AppRuntime
import io.github.miuzarte.scrcpyforandroid.services.LocalInputService
import io.github.miuzarte.scrcpyforandroid.storage.ScrcpyOptions import io.github.miuzarte.scrcpyforandroid.storage.ScrcpyOptions
import io.github.miuzarte.scrcpyforandroid.storage.Settings import io.github.miuzarte.scrcpyforandroid.storage.Settings
import io.github.miuzarte.scrcpyforandroid.storage.Storage import io.github.miuzarte.scrcpyforandroid.storage.Storage
@@ -1006,7 +1007,7 @@ fun ScrcpyVideoSurface(
if (imeRequestToken == 0) return@LaunchedEffect if (imeRequestToken == 0) return@LaunchedEffect
val surfaceView = currentSurfaceView ?: return@LaunchedEffect val surfaceView = currentSurfaceView ?: return@LaunchedEffect
surfaceView.setCommitTextEnabled(true) surfaceView.setCommitTextEnabled(true)
io.github.miuzarte.scrcpyforandroid.services.LocalInputService.showSoftKeyboard(surfaceView) LocalInputService.showSoftKeyboard(surfaceView)
} }
DisposableEffect(lifecycleOwner, session, currentSurface) { DisposableEffect(lifecycleOwner, session, currentSurface) {

View File

@@ -36,6 +36,7 @@ class ScrcpyInputSurfaceView @JvmOverloads constructor(
} }
override fun onKeyPreIme(keyCode: Int, event: KeyEvent): Boolean { override fun onKeyPreIme(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK) return super.onKeyPreIme(keyCode, event)
if (inputCallbacks?.handleKeyEvent(event) == true) return true if (inputCallbacks?.handleKeyEvent(event) == true) return true
return super.onKeyPreIme(keyCode, event) return super.onKeyPreIme(keyCode, event)
} }
@@ -58,6 +59,7 @@ class ScrcpyInputSurfaceView @JvmOverloads constructor(
} }
override fun sendKeyEvent(event: KeyEvent): Boolean { override fun sendKeyEvent(event: KeyEvent): Boolean {
if (event.keyCode == KeyEvent.KEYCODE_BACK) return super.sendKeyEvent(event)
if (inputCallbacks?.handleKeyEvent(event) == true) return true if (inputCallbacks?.handleKeyEvent(event) == true) return true
return super.sendKeyEvent(event) return super.sendKeyEvent(event)
} }