mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 02:33:43 +01:00
MacOS: Fix text input (got broken in #19441, would no longer send CHAR events)
See #19441
This commit is contained in:
1 parent
f11675bcba
commit
cb06ac4af2
3 files changed
+47
-12
No files matched your search
+37
-1
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user