mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
MacOS: Fix text input (got broken in #19441, would no longer send CHAR events)
See #19441
This commit is contained in:
parent
f11675bcba
commit
cb06ac4af2
@ -1329,7 +1329,7 @@ bool TextEdit::Key(const KeyInput &input) {
|
||||
|
||||
// Process chars.
|
||||
if (input.flags & KEY_CHAR) {
|
||||
int unichar = input.keyCode;
|
||||
const int unichar = input.keyCode;
|
||||
if (unichar >= 0x20 && !ctrlDown_) { // Ignore control characters.
|
||||
// Insert it! (todo: do it with a string insert)
|
||||
char buf[8];
|
||||
|
@ -100,6 +100,10 @@ static bool g_rebootEmuThread = false;
|
||||
|
||||
static SDL_AudioSpec g_retFmt;
|
||||
|
||||
static bool g_textFocusChanged;
|
||||
static bool g_textFocus;
|
||||
|
||||
|
||||
// Window state to be transferred to the main SDL thread.
|
||||
static std::mutex g_mutexWindow;
|
||||
struct WindowState {
|
||||
@ -347,6 +351,23 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
#endif /* PPSSPP_PLATFORM(WINDOWS) */
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::NOTIFY_UI_EVENT:
|
||||
{
|
||||
switch ((UIEventNotification)param3) {
|
||||
case UIEventNotification::TEXT_GOTFOCUS:
|
||||
g_textFocus = true;
|
||||
g_textFocusChanged = true;
|
||||
break;
|
||||
case UIEventNotification::POPUP_CLOSED:
|
||||
case UIEventNotification::TEXT_LOSTFOCUS:
|
||||
g_textFocus = false;
|
||||
g_textFocusChanged = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -1087,6 +1108,18 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTextFocus() {
|
||||
if (g_textFocusChanged) {
|
||||
INFO_LOG(Log::System, "Updating text focus: %d", g_textFocus);
|
||||
if (g_textFocus) {
|
||||
SDL_StartTextInput();
|
||||
} else {
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
g_textFocusChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSDLCursor() {
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (lastUIState != GetUIState()) {
|
||||
@ -1428,7 +1461,8 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// Avoid the IME popup when holding keys. This doesn't affect all versions of SDL.
|
||||
// TODO: Enable it in text input fields
|
||||
// Note: We re-enable it in text input fields! This is necessary otherwise we don't receive
|
||||
// KEY_CHAR events.
|
||||
SDL_StopTextInput();
|
||||
|
||||
InitSDLAudioDevice();
|
||||
@ -1465,6 +1499,7 @@ int main(int argc, char *argv[]) {
|
||||
if (g_QuitRequested || g_RestartRequested)
|
||||
break;
|
||||
|
||||
UpdateTextFocus();
|
||||
UpdateSDLCursor();
|
||||
|
||||
inputTracker.MouseCaptureControl();
|
||||
@ -1491,6 +1526,7 @@ int main(int argc, char *argv[]) {
|
||||
if (g_QuitRequested || g_RestartRequested)
|
||||
break;
|
||||
|
||||
UpdateTextFocus();
|
||||
UpdateSDLCursor();
|
||||
|
||||
inputTracker.MouseCaptureControl();
|
||||
|
@ -589,19 +589,19 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
|
||||
if (!chatButton_)
|
||||
RecreateViews();
|
||||
|
||||
#if defined(USING_WIN_UI)
|
||||
// temporary workaround for hotkey its freeze the ui when open chat screen using hotkey and native keyboard is enable
|
||||
if (g_Config.bBypassOSKWithKeyboard) {
|
||||
// TODO: Make translatable.
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, "Disable \"Use system native keyboard\" to use ctrl + c hotkey", 2.0f);
|
||||
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_DESKTOP) {
|
||||
// temporary workaround for hotkey its freeze the ui when open chat screen using hotkey and native keyboard is enable
|
||||
if (g_Config.bBypassOSKWithKeyboard) {
|
||||
// TODO: Make translatable.
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, "Disable \"Use system native keyboard\" to use ctrl + c hotkey", 2.0f);
|
||||
} else {
|
||||
UI::EventParams e{};
|
||||
OnChatMenu.Trigger(e);
|
||||
}
|
||||
} else {
|
||||
UI::EventParams e{};
|
||||
OnChatMenu.Trigger(e);
|
||||
}
|
||||
#else
|
||||
UI::EventParams e{};
|
||||
OnChatMenu.Trigger(e);
|
||||
#endif
|
||||
}
|
||||
} else if (message == UIMessage::APP_RESUMED && screenManager()->topScreen() == this) {
|
||||
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
|
||||
@ -935,7 +935,6 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
if (UI::IsFocusMovementEnabled()) {
|
||||
return UIScreen::UnsyncKey(key);
|
||||
}
|
||||
|
||||
return controlMapper_.Key(key, &pauseTrigger_);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user