From d004c665d05e56cc57aed0fd81ecd1a226cc2e5c Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 26 Aug 2022 17:36:41 +0900 Subject: [PATCH] Add API: SetImeStatus This is for GLFW3: glfwSetInputMode (mode: GLFW_IME) --- src/platforms/rcore_android.c | 6 ++++++ src/platforms/rcore_desktop_glfw.c | 7 +++++++ src/platforms/rcore_desktop_sdl.c | 6 ++++++ src/platforms/rcore_drm.c | 6 ++++++ src/platforms/rcore_template.c | 6 ++++++ src/platforms/rcore_web.c | 7 +++++++ src/raylib.h | 1 + 7 files changed, 39 insertions(+) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 707160f48..8ca1738f7 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -626,6 +626,12 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + TRACELOG(LOG_WARNING, "SetImeStatus() not implemented on target platform"); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 2f8bd87af..e0a7da1c9 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1062,6 +1062,13 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + if (on) glfwSetInputMode(platform.handle, GLFW_IME, GLFW_TRUE); + else glfwSetInputMode(platform.handle, GLFW_IME, GLFW_FALSE); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index d3514471a..af27e1bb4 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -947,6 +947,12 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + TRACELOG(LOG_WARNING, "SetImeStatus() not implemented on target platform"); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 4cac4d015..8788927b9 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -622,6 +622,12 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + TRACELOG(LOG_WARNING, "SetImeStatus() not implemented on target platform"); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index a4958a04d..ab3720b1b 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -384,6 +384,12 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + TRACELOG(LOG_WARNING, "SetImeStatus() not implemented on target platform"); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 96a7150e3..ae7bff656 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -868,6 +868,13 @@ bool IsImeOn(void) return false; } +// Set IME status +void SetImeStatus(bool on) +{ + if (on) glfwSetInputMode(platform.handle, GLFW_IME, GLFW_TRUE); + else glfwSetInputMode(platform.handle, GLFW_IME, GLFW_FALSE); +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/raylib.h b/src/raylib.h index d27f86747..19329ff58 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1174,6 +1174,7 @@ RLAPI void SetPreeditCallback(PreeditCallback callback); // Set a callback RLAPI void SetPreeditCursorRectangle(int x, int y, int w, int h); // Set the preedit cursor area that is used to decide the position of the candidate window RLAPI void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h); // Get the preedit cursor area RLAPI bool IsImeOn(void); // Check if IME is ON +RLAPI void SetImeStatus(bool on); // Set IME status // Input-related functions: gamepads RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available