From c0b46e30032584ffdfd05a41289850c9a3f809f1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 24 Sep 2015 20:08:11 +0200 Subject: [PATCH] Add more functionality to menu_input_ctl --- menu/drivers/glui.c | 16 ++++++++++------ menu/drivers/rgui.c | 17 ++++++++++++----- menu/drivers/xmb.c | 13 ++++++++----- menu/menu_input.c | 18 ++++++++++++++++++ menu/menu_input.h | 5 ++++- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 06a51eabbe..9f444cbeba 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -351,6 +351,7 @@ static void glui_render_menu_list(glui_handle_t *glui, static void glui_frame(void) { unsigned i; + bool display_kb; GRfloat coord_color[16]; GRfloat coord_color2[16]; GRfloat black_bg[16]; @@ -358,6 +359,7 @@ static void glui_frame(void) GRfloat highlight_bg[16]; GRfloat white_bg[16]; unsigned width, height, ticker_limit; + char msg[PATH_MAX_LENGTH]; char title[PATH_MAX_LENGTH]; char title_buf[PATH_MAX_LENGTH]; char title_msg[PATH_MAX_LENGTH]; @@ -371,7 +373,6 @@ static void glui_frame(void) menu_navigation_t *nav = menu_navigation_get_ptr(); menu_display_t *disp = menu_display_get_ptr(); settings_t *settings = config_get_ptr(); - menu_input_t *menu_input = menu_input_get_ptr(); uint64_t *frame_count = video_driver_get_frame_count(); const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA( settings->menu.entry_normal_color); @@ -390,6 +391,7 @@ static void glui_frame(void) glui = (glui_handle_t*)menu->userdata; + msg[0] = '\0'; title[0] = '\0'; title_buf[0] = '\0'; title_msg[0] = '\0'; @@ -486,16 +488,18 @@ static void glui_frame(void) TEXT_ALIGN_RIGHT); } - if (menu_input->keyboard.display) + menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb); + + if (display_kb) { - char msg[PATH_MAX_LENGTH]; - const char *str = *menu_input->keyboard.buffer; - msg[0] = '\0'; + const char *str = NULL, *label = NULL; + menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str); + menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label); if (!str) str = ""; glui_render_quad(gl, 0, 0, width, height, width, height, &black_bg[0]); - snprintf(msg, sizeof(msg), "%s\n%s", menu_input->keyboard.label, str); + snprintf(msg, sizeof(msg), "%s\n%s", label, str); glui_render_messagebox(msg); } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 1eba5b97ec..236d49b45a 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -382,12 +382,14 @@ static void rgui_blit_cursor(menu_handle_t *menu) static void rgui_render(void) { unsigned x, y; + bool display_kb; uint16_t hover_color, normal_color; size_t i, end; int bottom; char title[256]; char title_buf[256]; char title_msg[64]; + char msg[PATH_MAX_LENGTH]; char timedate[PATH_MAX_LENGTH]; menu_handle_t *menu = menu_driver_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); @@ -400,6 +402,7 @@ static void rgui_render(void) uint64_t *frame_count = video_driver_get_frame_count(); rgui_t *rgui = NULL; + msg[0] = '\0'; title[0] = '\0'; title_buf[0] = '\0'; title_msg[0] = '\0'; @@ -441,7 +444,8 @@ static void rgui_render(void) if (settings->menu.pointer.enable) { - menu_input->pointer.ptr = menu_input->pointer.y / 11 - 2 + menu_entries_get_start(); + unsigned new_val = menu_input->pointer.y / 11 - 2 + menu_entries_get_start(); + menu_input_ctl(MENU_CTL_POINTER_PTR, &new_val); if (menu_input->pointer.dragging) { @@ -580,14 +584,17 @@ static void rgui_render(void) rgui_render_messagebox( message_queue); #endif - if (menu_input->keyboard.display) + menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb); + + if (display_kb) { - char msg[PATH_MAX_LENGTH] = {0}; - const char *str = *menu_input->keyboard.buffer; + const char *str = NULL, *label = NULL; + menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str); + menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label); if (!str) str = ""; - snprintf(msg, sizeof(msg), "%s\n%s", menu_input->keyboard.label, str); + snprintf(msg, sizeof(msg), "%s\n%s", label, str); rgui_render_messagebox(msg); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 86e7a9e560..8285c055d1 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1504,12 +1504,12 @@ static void xmb_frame(void) GRfloat item_color[16]; GRfloat coord_color[16]; GRfloat coord_color2[16]; + bool display_kb; bool render_background = false; xmb_handle_t *xmb = NULL; gl_t *gl = NULL; const struct font_renderer *font_driver = NULL; menu_handle_t *menu = menu_driver_get_ptr(); - menu_input_t *menu_input = menu_input_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); settings_t *settings = config_get_ptr(); @@ -1631,14 +1631,17 @@ static void xmb_frame(void) menu_display_font_flush_block(menu, font_driver); - if (menu_input->keyboard.display) + menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb); + + if (display_kb) { - const char *str = *menu_input->keyboard.buffer; + const char *str = NULL, *label = NULL; + menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str); + menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label); if (!str) str = ""; - snprintf(msg, sizeof(msg), "%s\n%s", - menu_input->keyboard.label, str); + snprintf(msg, sizeof(msg), "%s\n%s", label, str); render_background = true; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 5c9332f5da..745828f0ed 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -93,6 +93,24 @@ bool menu_input_ctl(enum menu_ctl_state state, void *data) menu_input->pointer.ptr = *ptr; } return true; + case MENU_CTL_KEYBOARD_DISPLAY: + { + bool *ptr = (bool*)data; + *ptr = menu_input->keyboard.display; + } + return true; + case MENU_CTL_KEYBOARD_BUFF_PTR: + { + const char *ptr = (const char *)ptr; + ptr = *menu_input->keyboard.buffer; + } + return true; + case MENU_CTL_KEYBOARD_LABEL: + { + const char *ptr = (const char*)ptr; + ptr = menu_input->keyboard.label; + } + return true; } return false; diff --git a/menu/menu_input.h b/menu/menu_input.h index bc627f85a9..9cf02c2602 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -78,7 +78,10 @@ enum menu_ctl_state MENU_CTL_MOUSE_SCROLL_DOWN = 0, MENU_CTL_MOUSE_SCROLL_UP, MENU_CTL_MOUSE_PTR, - MENU_CTL_POINTER_PTR + MENU_CTL_POINTER_PTR, + MENU_CTL_KEYBOARD_DISPLAY, + MENU_CTL_KEYBOARD_BUFF_PTR, + MENU_CTL_KEYBOARD_LABEL }; enum mouse_action