From 8d5d9cc87490ec0b3c4fcaec1cd266664aefe65e Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 26 Aug 2022 17:27:06 +0900 Subject: [PATCH] Add API: IsImeOn This is for GLFW3: glfwGetInputMode (mode: GLFW_IME) --- src/platforms/rcore_android.c | 7 +++++++ src/platforms/rcore_desktop_glfw.c | 7 +++++++ src/platforms/rcore_desktop_sdl.c | 7 +++++++ src/platforms/rcore_drm.c | 7 +++++++ src/platforms/rcore_template.c | 7 +++++++ src/platforms/rcore_web.c | 7 +++++++ src/raylib.h | 1 + 7 files changed, 43 insertions(+) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 4b1b68a4a..707160f48 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -619,6 +619,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) TRACELOG(LOG_WARNING, "GetPreeditCursorRectangle() not implemented on target platform"); } +// Check if IME is ON +bool IsImeOn(void) +{ + TRACELOG(LOG_WARNING, "IsImeOn() not implemented on target platform"); + return false; +} + // 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 9579d854b..2f8bd87af 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1055,6 +1055,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) glfwGetPreeditCursorRectangle(platform.handle, x, y, w, h); } +// Check if IME is ON +bool IsImeOn(void) +{ + if (glfwGetInputMode(platform.handle, GLFW_IME) == GLFW_TRUE) return true; + return 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 63bc29004..d3514471a 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -940,6 +940,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) TRACELOG(LOG_WARNING, "GetPreeditCursorRectangle() not implemented on target platform"); } +// Check if IME is ON +bool IsImeOn(void) +{ + TRACELOG(LOG_WARNING, "IsImeOn() not implemented on target platform"); + return false; +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 883b31d41..4cac4d015 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -615,6 +615,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) TRACELOG(LOG_WARNING, "GetPreeditCursorRectangle() not implemented on target platform"); } +// Check if IME is ON +bool IsImeOn(void) +{ + TRACELOG(LOG_WARNING, "IsImeOn() not implemented on target platform"); + return false; +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 25e7db5a5..a4958a04d 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -377,6 +377,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) TRACELOG(LOG_WARNING, "GetPreeditCursorRectangle() not implemented on target platform"); } +// Check if IME is ON +bool IsImeOn(void) +{ + TRACELOG(LOG_WARNING, "IsImeOn() not implemented on target platform"); + return false; +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 8510b8261..96a7150e3 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -861,6 +861,13 @@ void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h) glfwGetPreeditCursorRectangle(platform.handle, x, y, w, h); } +// Check if IME is ON +bool IsImeOn(void) +{ + if (glfwGetInputMode(platform.handle, GLFW_IME) == GLFW_TRUE) return true; + return false; +} + // Set internal gamepad mappings int SetGamepadMappings(const char *mappings) { diff --git a/src/raylib.h b/src/raylib.h index 48f3cf6d7..d27f86747 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1173,6 +1173,7 @@ RLAPI void SetExitKey(int key); // Set a custom ke RLAPI void SetPreeditCallback(PreeditCallback callback); // Set a callback for preedit 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 // Input-related functions: gamepads RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available