OSK memory fix and hiragana support

This commit is contained in:
Jean-André Santoni 2016-10-29 23:54:06 +02:00
parent b176aa2396
commit 01985c7460
3 changed files with 57 additions and 15 deletions

View File

@ -168,17 +168,19 @@ static bool input_keyboard_line_event(
bool input_keyboard_line_append(char* word)
{
unsigned len = strlen(word);
char *newbuf = (char*)
realloc(g_keyboard_line->buffer, g_keyboard_line->size + 2);
realloc(g_keyboard_line->buffer, g_keyboard_line->size + len*2);
if (!newbuf)
return false;
memmove(newbuf + g_keyboard_line->ptr + 1,
memmove(newbuf + g_keyboard_line->ptr + len,
newbuf + g_keyboard_line->ptr,
g_keyboard_line->size - g_keyboard_line->ptr + 1);
g_keyboard_line->size - g_keyboard_line->ptr + len);
unsigned i = 0;
for (i = 0; i < strlen(word); i++)
for (i = 0; i < len; i++)
{
newbuf[g_keyboard_line->ptr] = word[i];
g_keyboard_line->ptr++;

View File

@ -161,15 +161,44 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
if (menu_input_dialog_get_display_kb())
{
if (osk_upper)
switch (osk_idx)
{
char* grid[] = {"!","@","#","$","%","^","&","*","(",")","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L",":","Z","X","C","V","B","N","M"," ","<",">","?"};
memcpy(osk_grid, grid, sizeof(grid));
}
else
{
char* grid[] = {"1","2","3","4","5","6","7","8","9","0","q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l",";","z","x","c","v","b","n","m"," ",",",".","/"};
memcpy(osk_grid, grid, sizeof(grid));
case 0:
{
char* grid[] = {"!","@","#","$","%","^","&","*","(",")",
"Q","W","E","R","T","Y","U","I","O","P",
"A","S","D","F","G","H","J","K","L",":",
"Z","X","C","V","B","N","M"," ","<",">"};
memcpy(osk_grid, grid, sizeof(grid));
break;
}
case 1:
{
char* grid[] = {"1","2","3","4","5","6","7","8","9","0",
"q","w","e","r","t","y","u","i","o","p",
"a","s","d","f","g","h","j","k","l",";",
"z","x","c","v","b","n","m"," ",",","."};
memcpy(osk_grid, grid, sizeof(grid));
break;
}
case 2:
{
char* grid[] = {"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
memcpy(osk_grid, grid, sizeof(grid));
break;
}
case 3:
{
char* grid[] = {"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""};
memcpy(osk_grid, grid, sizeof(grid));
break;
}
}
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))
@ -196,9 +225,20 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input)
osk_ptr = osk_ptr - 1;
}
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y))
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L))
{
osk_upper = ! osk_upper;
if (osk_idx > 0)
osk_idx--;
else
osk_idx = 3;
}
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R))
{
if (osk_idx < 3)
osk_idx++;
else
osk_idx = 0;
}
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A))

View File

@ -40,8 +40,8 @@ void menu_event_keyboard_set(bool down, enum retro_key key);
unsigned char menu_event_keyboard_is_set(enum retro_key key);
unsigned osk_ptr;
unsigned osk_idx;
char* osk_grid[41];
bool osk_upper;
RETRO_END_DECLS