mirror of
https://github.com/libretro/RetroArch
synced 2025-02-08 15:40:14 +00:00
(Menu) Integrate an joypad driven OSK to the menu driver.
This commit is contained in:
parent
486b845eca
commit
df1f4dbc89
@ -49,6 +49,7 @@
|
|||||||
#include "../widgets/menu_input_dialog.h"
|
#include "../widgets/menu_input_dialog.h"
|
||||||
|
|
||||||
#include "../menu_cbs.h"
|
#include "../menu_cbs.h"
|
||||||
|
#include "../menu_event.h"
|
||||||
|
|
||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
#include "../../configuration.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));
|
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(
|
static void xmb_render_messagebox_internal(
|
||||||
xmb_handle_t *xmb, const char *message)
|
xmb_handle_t *xmb, const char *message)
|
||||||
{
|
{
|
||||||
int x, y, longest = 0, longest_width = 0;
|
int x, y, longest = 0, longest_width = 0;
|
||||||
unsigned i;
|
unsigned i, y_position;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
struct string_list *list = NULL;
|
struct string_list *list = NULL;
|
||||||
|
|
||||||
@ -704,8 +780,12 @@ static void xmb_render_messagebox_internal(
|
|||||||
if (list->elems == 0)
|
if (list->elems == 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
y_position = height / 2;
|
||||||
|
if (menu_input_dialog_get_display_kb())
|
||||||
|
y_position = height / 4;
|
||||||
|
|
||||||
x = width / 2;
|
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 */
|
/* find the longest line width */
|
||||||
for (i = 0; i < list->size; i++)
|
for (i = 0; i < list->size; i++)
|
||||||
@ -736,6 +816,9 @@ static void xmb_render_messagebox_internal(
|
|||||||
xmb->font);
|
xmb->font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menu_input_dialog_get_display_kb())
|
||||||
|
xmb_render_keyboard(xmb, kbd_grid, kbd_index);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
}
|
}
|
||||||
|
@ -135,40 +135,49 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
|
|||||||
|
|
||||||
if (menu_input_dialog_get_display_kb())
|
if (menu_input_dialog_get_display_kb())
|
||||||
{
|
{
|
||||||
static unsigned ti_char = 64;
|
if (kbd_upper)
|
||||||
static bool ti_next = false;
|
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 (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
||||||
{
|
{
|
||||||
if (ti_char > 32)
|
if (kbd_index < 30)
|
||||||
ti_char--;
|
kbd_index = kbd_index + 10;
|
||||||
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 (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP))
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP))
|
||||||
{
|
{
|
||||||
if (ti_char < 125)
|
if (kbd_index >= 10)
|
||||||
ti_char++;
|
kbd_index = kbd_index - 10;
|
||||||
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);
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
||||||
ti_next = false;
|
{
|
||||||
|
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))
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A))
|
||||||
{
|
{
|
||||||
ti_char = 64;
|
input_keyboard_event(true, kbd_grid[kbd_index], kbd_grid[kbd_index],
|
||||||
ti_next = true;
|
0, RETRO_DEVICE_KEYBOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B))
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B))
|
||||||
{
|
{
|
||||||
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
|
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
|
||||||
ti_char = 64;
|
|
||||||
ti_next = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send return key to close keyboard input window */
|
/* send return key to close keyboard input window */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define _MENU_EVENT_H
|
#define _MENU_EVENT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <compat/strl.h>
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
@ -32,6 +33,10 @@ RETRO_BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
unsigned menu_event(uint64_t input, uint64_t trigger_state);
|
unsigned menu_event(uint64_t input, uint64_t trigger_state);
|
||||||
|
|
||||||
|
unsigned kbd_index;
|
||||||
|
char kbd_grid[41];
|
||||||
|
bool kbd_upper;
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user