mirror of
https://github.com/citron-neo/emulator.git
synced 2026-07-05 15:21:57 -07:00
feat: update SoftwareKeyboard visibility handling and improve keyboard dismiss polling
This commit is contained in:
+26
-9
@@ -37,21 +37,36 @@ object SoftwareKeyboard {
|
||||
private fun executeInlineImpl(config: KeyboardConfig) {
|
||||
val activity = NativeLibrary.sEmulationActivity.get() ?: return
|
||||
val overlayView = activity.findViewById<View>(R.id.surface_input_overlay) ?: return
|
||||
val previousVisibility = overlayView.visibility
|
||||
val previousAlpha = overlayView.alpha
|
||||
|
||||
// Make sure the overlay can receive input
|
||||
overlayView.requestFocus()
|
||||
overlayView.visibility = View.VISIBLE
|
||||
if (previousVisibility != View.VISIBLE) {
|
||||
overlayView.alpha = 0f
|
||||
}
|
||||
overlayView.isFocusableInTouchMode = true
|
||||
|
||||
val imm = overlayView.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
overlayView.post {
|
||||
overlayView.requestFocus()
|
||||
|
||||
// Restart input to ensure clean state
|
||||
imm.restartInput(overlayView)
|
||||
imm.showSoftInput(overlayView, InputMethodManager.SHOW_FORCED)
|
||||
val imm =
|
||||
overlayView.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
||||
// Poll every 500ms to detect when the keyboard is closed
|
||||
startKeyboardDismissPolling(overlayView)
|
||||
// Restart input to ensure clean state
|
||||
imm.restartInput(overlayView)
|
||||
imm.showSoftInput(overlayView, InputMethodManager.SHOW_FORCED)
|
||||
|
||||
// Poll every 500ms to detect when the keyboard is closed
|
||||
startKeyboardDismissPolling(overlayView, previousVisibility, previousAlpha)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startKeyboardDismissPolling(overlayView: View) {
|
||||
private fun startKeyboardDismissPolling(
|
||||
overlayView: View,
|
||||
previousVisibility: Int,
|
||||
previousAlpha: Float
|
||||
) {
|
||||
val handler = Handler(Looper.myLooper()!!)
|
||||
val delayMs = 500L
|
||||
|
||||
@@ -66,6 +81,8 @@ object SoftwareKeyboard {
|
||||
}
|
||||
|
||||
// Keyboard was dismissed → submit result
|
||||
overlayView.visibility = previousVisibility
|
||||
overlayView.alpha = previousAlpha
|
||||
NativeLibrary.submitInlineKeyboardInput(KeyEvent.KEYCODE_ENTER)
|
||||
}
|
||||
}, delayMs)
|
||||
@@ -138,4 +155,4 @@ object SoftwareKeyboard {
|
||||
|
||||
@Keep
|
||||
data class KeyboardData(var result: Int, var text: String)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,6 +311,7 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string
|
||||
jauto android_keyboard = std::make_unique<Common::Android::SoftwareKeyboard::AndroidKeyboard>();
|
||||
m_software_keyboard = android_keyboard.get();
|
||||
m_system.SetShuttingDown(false);
|
||||
Settings::values.swkbd_applet_mode.SetValue(Settings::AppletMode::HLE);
|
||||
m_system.ApplySettings();
|
||||
Settings::LogSettings();
|
||||
m_system.HIDCore().ReloadInputDevices();
|
||||
|
||||
Reference in New Issue
Block a user