From bb0840956f83ee38b080c69f82b5af2bb56dba43 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 16:45:50 +0100 Subject: [PATCH] (menu_osk) Cleanup - take out configuration.h dependencies --- menu/widgets/menu_osk.c | 27 +++++++++------------------ menu/widgets/menu_osk.h | 2 +- retroarch.c | 30 ++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/menu/widgets/menu_osk.c b/menu/widgets/menu_osk.c index 3a32e0955f..de61d2247a 100644 --- a/menu/widgets/menu_osk.c +++ b/menu/widgets/menu_osk.c @@ -31,7 +31,6 @@ #include "menu_osk.h" #include "../../input/input_driver.h" -#include "../../configuration.h" static char *osk_grid[45] = {NULL}; @@ -82,16 +81,8 @@ void menu_event_set_osk_ptr(int i) osk_ptr = i; } -void menu_event_osk_append(int ptr) +void menu_event_osk_append(int ptr, bool is_rgui) { - settings_t *settings = config_get_ptr(); - bool is_rgui; - - if (ptr < 0 || !settings) - return; - - is_rgui = string_is_equal(settings->arrays.menu_driver, "rgui"); - #ifdef HAVE_LANGEXTRA if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa6")) /* backspace character */ input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); @@ -99,9 +90,9 @@ void menu_event_osk_append(int ptr) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); else if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa7")) /* up arrow */ - menu_event_set_osk_idx(OSK_UPPERCASE_LATIN); + osk_idx = OSK_UPPERCASE_LATIN; else if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa9")) /* down arrow */ - menu_event_set_osk_idx(OSK_LOWERCASE_LATIN); + osk_idx = OSK_LOWERCASE_LATIN; else if (string_is_equal(osk_grid[ptr],"\xe2\x8a\x95")) /* plus sign (next button) */ #else if (string_is_equal(osk_grid[ptr], "Bksp")) @@ -110,22 +101,22 @@ void menu_event_osk_append(int ptr) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); else if (string_is_equal(osk_grid[ptr], "Upper")) - menu_event_set_osk_idx(OSK_UPPERCASE_LATIN); + osk_idx = OSK_UPPERCASE_LATIN; else if (string_is_equal(osk_grid[ptr], "Lower")) - menu_event_set_osk_idx(OSK_LOWERCASE_LATIN); + osk_idx = OSK_LOWERCASE_LATIN; else if (string_is_equal(osk_grid[ptr], "Next")) #endif - if (menu_event_get_osk_idx() < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) - menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() + 1)); + if (osk_idx < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) + osk_idx = (enum osk_type)(osk_idx + 1); else - menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); + osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); else input_keyboard_line_append(osk_grid[ptr]); } void menu_event_osk_iterate(void) { - switch (menu_event_get_osk_idx()) + switch (osk_idx) { #ifdef HAVE_LANGEXTRA case OSK_HIRAGANA_PAGE1: diff --git a/menu/widgets/menu_osk.h b/menu/widgets/menu_osk.h index 2c460a7efb..b0614e9cde 100644 --- a/menu/widgets/menu_osk.h +++ b/menu/widgets/menu_osk.h @@ -55,7 +55,7 @@ int menu_event_get_osk_ptr(void); void menu_event_set_osk_ptr(int a); -void menu_event_osk_append(int a); +void menu_event_osk_append(int a, bool is_rgui); void menu_event_osk_iterate(void); diff --git a/retroarch.c b/retroarch.c index 0ee85febd2..b4969e5631 100644 --- a/retroarch.c +++ b/retroarch.c @@ -14746,7 +14746,16 @@ static unsigned menu_event( RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B; unsigned ok_current = BIT256_GET_PTR(p_input, menu_ok_btn); unsigned ok_trigger = ok_current & ~ok_old; - bool is_rgui = string_is_equal(settings->arrays.menu_driver, "rgui"); +#ifdef HAVE_RGUI + /* TODO/FIXME - instead of looking explicitly for the name rgui, instead + * perhaps check if set_texture is set - I assume we want to check if + * a menu driver is framebuffer-based instead of specifically looking if + * it's RGUI */ + bool is_rgui = string_is_equal( + settings->arrays.menu_driver, "rgui"); +#else + bool is_rgui = false; +#endif ok_old = ok_current; @@ -14829,26 +14838,29 @@ static unsigned menu_event( if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) { - if (menu_event_get_osk_idx() > OSK_TYPE_UNKNOWN + 1) + enum osk_type osk_type_idx = menu_event_get_osk_idx(); + if (osk_type_idx > OSK_TYPE_UNKNOWN + 1) menu_event_set_osk_idx((enum osk_type)( - menu_event_get_osk_idx() - 1)); + osk_type_idx - 1)); else menu_event_set_osk_idx((enum osk_type)(is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)); } if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) { - if (menu_event_get_osk_idx() < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) + enum osk_type osk_type_idx = menu_event_get_osk_idx(); + if (osk_type_idx < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) menu_event_set_osk_idx((enum osk_type)( - menu_event_get_osk_idx() + 1)); + osk_type_idx + 1)); else menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); } if (BIT256_GET_PTR(p_trigger_input, menu_ok_btn)) { - if (menu_event_get_osk_ptr() >= 0) - menu_event_osk_append(menu_event_get_osk_ptr()); + int ptr = menu_event_get_osk_ptr(); + if (ptr >= 0) + menu_event_osk_append(ptr, is_rgui); } if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn)) @@ -15510,7 +15522,9 @@ static int menu_input_pointer_post_iterate( if (point.retcode > -1) { menu_event_set_osk_ptr(point.retcode); - menu_event_osk_append(point.retcode); + menu_event_osk_append(point.retcode, + string_is_equal( + configuration_settings->arrays.menu_driver, "rgui")); } } }