diff --git a/src/VirtualKeyboard.h b/src/VirtualKeyboard.h index f329bad23..6a02ad927 100644 --- a/src/VirtualKeyboard.h +++ b/src/VirtualKeyboard.h @@ -229,6 +229,7 @@ static void VirtualKeyboard_Open(struct OpenKeyboardArgs* args, cc_bool launcher } static void VirtualKeyboard_SetText(const cc_string* text) { + if (!kb_showing) return; String_Copy(&kb_str, text); } diff --git a/src/Window_Dreamcast.c b/src/Window_Dreamcast.c index 076c163ea..226170ccc 100644 --- a/src/Window_Dreamcast.c +++ b/src/Window_Dreamcast.c @@ -260,11 +260,11 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) { } void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { + if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); // TODO: double buffering ?? // https://dcemulation.org/phpBB/viewtopic.php?t=99999 // https://dcemulation.org/phpBB/viewtopic.php?t=43214 vid_waitvbl(); - if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); for (int y = r.y; y < r.y + r.height; y++) { @@ -294,12 +294,10 @@ void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { } void Window_SetKeyboardText(const cc_string* text) { - if (!kb_showing) return; VirtualKeyboard_SetText(text); } void Window_CloseKeyboard(void) { - if (Input.Sources & INPUT_SOURCE_NORMAL) return; VirtualKeyboard_Close(); } diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index bd68fff4f..249b1c967 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -10,6 +10,7 @@ #include "Errors.h" #include "ExtMath.h" #include "Graphics.h" +#include "VirtualKeyboard.h" #include #if defined HW_RVL #include @@ -446,6 +447,7 @@ void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { VIDEO_Flush(); needsFBUpdate = false; } + if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); VIDEO_WaitVSync(); r.x &= ~0x01; // round down to nearest even horizontal index @@ -471,6 +473,23 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) { } +/*########################################################################################################################* +*------------------------------------------------------Soft keyboard------------------------------------------------------* +*#########################################################################################################################*/ +void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { + if (Input.Sources & INPUT_SOURCE_NORMAL) return; + VirtualKeyboard_Open(args, launcherMode); +} + +void Window_SetKeyboardText(const cc_string* text) { + VirtualKeyboard_SetText(text); +} + +void Window_CloseKeyboard(void) { + VirtualKeyboard_Close(); +} + + /*########################################################################################################################* *-------------------------------------------------------Misc/Other--------------------------------------------------------* *#########################################################################################################################*/ @@ -487,10 +506,6 @@ void Window_Show(void) { } void Window_SetSize(int width, int height) { } -void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { /* TODO implement */ } -void Window_SetKeyboardText(const cc_string* text) { } -void Window_CloseKeyboard(void) { /* TODO implement */ } - void Window_ShowDialog(const char* title, const char* msg) { /* TODO implement */ Platform_LogConst(title); diff --git a/src/Window_PS3.c b/src/Window_PS3.c index 1b63a27de..c406f9f2c 100644 --- a/src/Window_PS3.c +++ b/src/Window_PS3.c @@ -11,6 +11,7 @@ #include "Errors.h" #include "ExtMath.h" #include "Logger.h" +#include "VirtualKeyboard.h" #include #include #include @@ -236,6 +237,17 @@ static void ProcessKBTextInput(void) { } } +static void ProcessKBInput(void) { + int res = ioKbRead(0, &kb_data); + Input.Sources |= INPUT_SOURCE_NORMAL; + + if (res == 0 && kb_data.nb_keycode > 0) { + ProcessKBButtons(); + ProcessKBModifiers(&kb_data.mkey); + ProcessKBTextInput(); + } +} + /*########################################################################################################################* *----------------------------------------------------Input processing-----------------------------------------------------* @@ -284,16 +296,8 @@ void Window_ProcessEvents(double delta) { ProcessPadInput(delta, &pad_data); } - // TODO set InputSource keyboard ioKbGetInfo(&kb_info); - if (kb_info.status[0]) { - int res = ioKbRead(0, &kb_data); - if (res == 0 && kb_data.nb_keycode > 0) { - ProcessKBButtons(); - ProcessKBModifiers(&kb_data.mkey); - ProcessKBTextInput(); - } - } + if (kb_info.status[0]) ProcessKBInput(); } void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita @@ -319,6 +323,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) { } void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { + if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); // TODO test Gfx_BeginFrame(); Gfx_ClearBuffers(GFX_BUFFER_COLOR | GFX_BUFFER_DEPTH); @@ -336,9 +341,18 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) { /*########################################################################################################################* *------------------------------------------------------Soft keyboard------------------------------------------------------* *#########################################################################################################################*/ -void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { /* TODO implement */ } -void Window_SetKeyboardText(const cc_string* text) { } -void Window_CloseKeyboard(void) { /* TODO implement */ } +void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { + if (Input.Sources & INPUT_SOURCE_NORMAL) return; + VirtualKeyboard_Open(args, launcherMode); +} + +void Window_SetKeyboardText(const cc_string* text) { + VirtualKeyboard_SetText(text); +} + +void Window_CloseKeyboard(void) { + VirtualKeyboard_Close(); +} /*########################################################################################################################* diff --git a/src/Window_PSP.c b/src/Window_PSP.c index 2fee8a03b..8e0c65924 100644 --- a/src/Window_PSP.c +++ b/src/Window_PSP.c @@ -10,6 +10,7 @@ #include "Bitmap.h" #include "Errors.h" #include "ExtMath.h" +#include "VirtualKeyboard.h" #include #include #include @@ -120,6 +121,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) { } void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { + if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); void* fb = sceGeEdramGetAddr(); sceDisplayWaitVblankStart(); @@ -143,9 +145,18 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) { /*########################################################################################################################* *------------------------------------------------------Soft keyboard------------------------------------------------------* *#########################################################################################################################*/ -void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { /* TODO implement */ } -void Window_SetKeyboardText(const cc_string* text) { } -void Window_CloseKeyboard(void) { /* TODO implement */ } +void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { + if (Input.Sources & INPUT_SOURCE_NORMAL) return; + VirtualKeyboard_Open(args, launcherMode); +} + +void Window_SetKeyboardText(const cc_string* text) { + VirtualKeyboard_SetText(text); +} + +void Window_CloseKeyboard(void) { + VirtualKeyboard_Close(); +} /*########################################################################################################################* diff --git a/src/Window_Xbox.c b/src/Window_Xbox.c index 80a06bcb1..22d0599c1 100644 --- a/src/Window_Xbox.c +++ b/src/Window_Xbox.c @@ -10,6 +10,7 @@ #include "Bitmap.h" #include "Errors.h" #include "ExtMath.h" +#include "VirtualKeyboard.h" #include #include #include @@ -174,6 +175,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) { void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { void* fb = XVideoGetFB(); + if (kb_showing) VirtualKeyboard_Display2D(&r, bmp); //XVideoWaitForVBlank(); // XVideoWaitForVBlank installs an interrupt handler for VBlank - // however this will cause pbkit's attempt to install an interrupt @@ -196,9 +198,18 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) { /*########################################################################################################################* *------------------------------------------------------Soft keyboard------------------------------------------------------* *#########################################################################################################################*/ -void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { } -void Window_SetKeyboardText(const cc_string* text) { } -void Window_CloseKeyboard(void) { /* TODO implement */ } +void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { + if (Input.Sources & INPUT_SOURCE_NORMAL) return; + VirtualKeyboard_Open(args, launcherMode); +} + +void Window_SetKeyboardText(const cc_string* text) { + VirtualKeyboard_SetText(text); +} + +void Window_CloseKeyboard(void) { + VirtualKeyboard_Close(); +} /*########################################################################################################################*