fix(input): B on a controller hides the on-screen keyboard before going back (#2498)

* fix(input): B on a controller hides the on-screen keyboard before going back

* fix(input): B sees the on-screen keyboard on Android 8 to 10 too
This commit is contained in:
DeathKhan authored and GitHub committed 2026-11-11 20:55:56 -05:00
1 parent 3230ccdc73
commit afd2d91662
1 file changed
+12
@@ -454,6 +454,18 @@ internal fun AdbTextField(
}
}
showSoftInputOnFocus = !bottomTyping
// B on a controller puts the keyboard away first; with no keyboard up it goes back as usual.
var hidingKeyboard = false
setOnKeyListener { view, keyCode, event ->
if (keyCode != android.view.KeyEvent.KEYCODE_BUTTON_B) return@setOnKeyListener false
if (event.action == android.view.KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
hidingKeyboard = androidx.core.view.ViewCompat.getRootWindowInsets(view)
?.isVisible(androidx.core.view.WindowInsetsCompat.Type.ime()) == true
if (hidingKeyboard) (view.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
?.hideSoftInputFromWindow(view.windowToken, 0)
}
hidingKeyboard
}
setOnClickListener { if (hasFocus() && !typeOnBottom(this) && bottomTypingLatest.value) showKeyboardHere(this) }
setOnFocusChangeListener { _, hasFocus ->
focused = hasFocus