mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 03:40:24 +00:00
Rewrite osk_last_update_codepoint
This commit is contained in:
parent
682a09fbdb
commit
c645a9b8bb
42
retroarch.c
42
retroarch.c
@ -25350,25 +25350,23 @@ const hid_driver_t *input_hid_init_first(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void osk_update_last_codepoint(
|
static void osk_update_last_codepoint(
|
||||||
struct rarch_state *p_rarch,
|
unsigned *last_codepoint,
|
||||||
|
unsigned *last_codepoint_len,
|
||||||
const char *word)
|
const char *word)
|
||||||
{
|
{
|
||||||
const char *letter = word;
|
const char *letter = word;
|
||||||
const char *pos = letter;
|
const char *pos = letter;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
unsigned codepoint = utf8_walk(&letter);
|
unsigned codepoint = utf8_walk(&letter);
|
||||||
unsigned len = (unsigned)(letter - pos);
|
|
||||||
|
|
||||||
if (letter[0] == 0)
|
if (letter[0] == 0)
|
||||||
{
|
{
|
||||||
p_rarch->osk_last_codepoint = codepoint;
|
*last_codepoint = codepoint;
|
||||||
p_rarch->osk_last_codepoint_len = len;
|
*last_codepoint_len = (unsigned)(letter - pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pos = letter;
|
||||||
pos = letter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25400,8 +25398,8 @@ static bool input_keyboard_line_event(
|
|||||||
array[0] = c;
|
array[0] = c;
|
||||||
array[1] = 0;
|
array[1] = 0;
|
||||||
|
|
||||||
word = array;
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
word = array;
|
||||||
}
|
}
|
||||||
else if (c == '\b' || c == '\x7f') /* 0x7f is ASCII for del */
|
else if (c == '\b' || c == '\x7f') /* 0x7f is ASCII for del */
|
||||||
{
|
{
|
||||||
@ -25454,7 +25452,10 @@ static bool input_keyboard_line_event(
|
|||||||
p_rarch->osk_last_codepoint_len = 0;
|
p_rarch->osk_last_codepoint_len = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
osk_update_last_codepoint(p_rarch, word);
|
osk_update_last_codepoint(
|
||||||
|
&p_rarch->osk_last_codepoint,
|
||||||
|
&p_rarch->osk_last_codepoint_len,
|
||||||
|
word);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -25469,7 +25470,7 @@ static void input_keyboard_line_append(
|
|||||||
unsigned len = (unsigned)strlen(word);
|
unsigned len = (unsigned)strlen(word);
|
||||||
char *newbuf = (char*)realloc(
|
char *newbuf = (char*)realloc(
|
||||||
p_rarch->keyboard_line.buffer,
|
p_rarch->keyboard_line.buffer,
|
||||||
p_rarch->keyboard_line.size + len*2);
|
p_rarch->keyboard_line.size + len * 2);
|
||||||
|
|
||||||
if (!newbuf)
|
if (!newbuf)
|
||||||
return;
|
return;
|
||||||
@ -25480,22 +25481,25 @@ static void input_keyboard_line_append(
|
|||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
newbuf[p_rarch->keyboard_line.ptr] = word[i];
|
newbuf[p_rarch->keyboard_line.ptr]= word[i];
|
||||||
p_rarch->keyboard_line.ptr++;
|
p_rarch->keyboard_line.ptr++;
|
||||||
p_rarch->keyboard_line.size++;
|
p_rarch->keyboard_line.size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
newbuf[p_rarch->keyboard_line.size] = '\0';
|
newbuf[p_rarch->keyboard_line.size] = '\0';
|
||||||
|
|
||||||
p_rarch->keyboard_line.buffer = newbuf;
|
p_rarch->keyboard_line.buffer = newbuf;
|
||||||
|
|
||||||
if (word[0] == 0)
|
if (word[0] == 0)
|
||||||
{
|
{
|
||||||
p_rarch->osk_last_codepoint = 0;
|
p_rarch->osk_last_codepoint = 0;
|
||||||
p_rarch->osk_last_codepoint_len = 0;
|
p_rarch->osk_last_codepoint_len = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
osk_update_last_codepoint(p_rarch, word);
|
osk_update_last_codepoint(
|
||||||
|
&p_rarch->osk_last_codepoint,
|
||||||
|
&p_rarch->osk_last_codepoint_len,
|
||||||
|
word);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user