diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1af72bcf8e..78fe704319 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -49,6 +49,7 @@ #include "../widgets/menu_input_dialog.h" #include "../menu_cbs.h" +#include "../menu_event.h" #include "../../verbosity.h" #include "../../configuration.h" @@ -684,11 +685,86 @@ static void xmb_messagebox(void *data, const char *message) strlcpy(xmb->box_message, message, sizeof(xmb->box_message)); } +static void xmb_render_quad(xmb_handle_t *xmb, + int x, int y, unsigned w, unsigned h, + unsigned width, unsigned height, + float *coord_color) +{ + menu_display_ctx_draw_t draw; + struct video_coords coords; + + coords.vertices = 4; + coords.vertex = NULL; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + coords.color = coord_color; + + menu_display_blend_begin(); + + draw.x = x; + draw.y = (int)height - y - (int)h; + draw.width = w; + draw.height = h; + draw.coords = &coords; + draw.matrix_data = NULL; + draw.texture = menu_display_white_texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + + menu_display_draw(&draw); + menu_display_blend_end(); +} + +static void xmb_render_keyboard(xmb_handle_t *xmb, char* grid, unsigned id) +{ + unsigned i, width, height; + video_driver_get_size(&width, &height); + + float dark[16]= { + 0.00, 0.00, 0.00, 0.5, + 0.00, 0.00, 0.00, 0.5, + 0.00, 0.00, 0.00, 0.5, + 0.00, 0.00, 0.00, 0.5, + }; + + float light[16]= { + 1.00, 1.00, 1.00, 0.5, + 1.00, 1.00, 1.00, 0.5, + 1.00, 1.00, 1.00, 0.5, + 1.00, 1.00, 1.00, 0.5, + }; + + xmb_render_quad(xmb, 0, height/2.0, width, height/2.0, + width, height, + &dark[0]); + + for (i = 0; i <= 40; i++) + { + char letter[2]; + letter[0] = grid[i]; + letter[1] = '\0'; + int foo = (i / 10)*height/10.0; + + if (i == id) + xmb_render_quad(xmb, + width/11.0 + (i % 10) * width/11.0 - 30, + height*2.5/4.0 + foo - 30 - xmb->font->size / 4, + 60, 60, + width, height, + &light[0]); + + xmb_draw_text(xmb, letter, + width/11.0 + (i % 10) * width/11.0, + height*2.5/4.0 + foo, + 1, 1, TEXT_ALIGN_CENTER, width, height, xmb->font); + } +} + static void xmb_render_messagebox_internal( xmb_handle_t *xmb, const char *message) { int x, y, longest = 0, longest_width = 0; - unsigned i; + unsigned i, y_position; unsigned width, height; struct string_list *list = NULL; @@ -704,8 +780,12 @@ static void xmb_render_messagebox_internal( if (list->elems == 0) goto end; + y_position = height / 2; + if (menu_input_dialog_get_display_kb()) + y_position = height / 4; + x = width / 2; - y = height / 2 - (list->size-1) * xmb->font->size / 2; + y = y_position - (list->size-1) * xmb->font->size / 2; /* find the longest line width */ for (i = 0; i < list->size; i++) @@ -736,6 +816,9 @@ static void xmb_render_messagebox_internal( xmb->font); } + if (menu_input_dialog_get_display_kb()) + xmb_render_keyboard(xmb, kbd_grid, kbd_index); + end: string_list_free(list); } diff --git a/menu/menu_event.c b/menu/menu_event.c index a47e5c6fb2..e467e8dd9a 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -135,40 +135,49 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input) if (menu_input_dialog_get_display_kb()) { - static unsigned ti_char = 64; - static bool ti_next = false; + if (kbd_upper) + strlcpy(kbd_grid, "!@#$%^&*()QWERTYUIOPASDFGHJKL:ZXCVBNM <>?", sizeof(kbd_grid)); + else + strlcpy(kbd_grid, "1234567890qwertyuiopasdfghjkl:zxcvbnm ,./", sizeof(kbd_grid)); if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN)) { - if (ti_char > 32) - ti_char--; - if (! ti_next) - input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); - input_keyboard_event(true, ti_char, ti_char, 0, RETRO_DEVICE_KEYBOARD); - ti_next = false; + if (kbd_index < 30) + kbd_index = kbd_index + 10; } if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP)) { - if (ti_char < 125) - ti_char++; - if (! ti_next) - input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); - input_keyboard_event(true, ti_char, ti_char, 0, RETRO_DEVICE_KEYBOARD); - ti_next = false; + if (kbd_index >= 10) + kbd_index = kbd_index - 10; + } + + if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT)) + { + if (kbd_index < 39) + kbd_index = kbd_index + 1; + } + + if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT)) + { + if (kbd_index >= 1) + kbd_index = kbd_index - 1; + } + + if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y)) + { + kbd_upper = ! kbd_upper; } if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A)) { - ti_char = 64; - ti_next = true; + input_keyboard_event(true, kbd_grid[kbd_index], kbd_grid[kbd_index], + 0, RETRO_DEVICE_KEYBOARD); } if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B)) { input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); - ti_char = 64; - ti_next = false; } /* send return key to close keyboard input window */ diff --git a/menu/menu_event.h b/menu/menu_event.h index fb1da0d6c7..3795ae4d0f 100644 --- a/menu/menu_event.h +++ b/menu/menu_event.h @@ -18,6 +18,7 @@ #define _MENU_EVENT_H #include +#include #include @@ -32,6 +33,10 @@ RETRO_BEGIN_DECLS */ unsigned menu_event(uint64_t input, uint64_t trigger_state); +unsigned kbd_index; +char kbd_grid[41]; +bool kbd_upper; + RETRO_END_DECLS #endif