Rewrite osk_last_update_codepoint

This commit is contained in:
twinaphex 2021-03-08 23:28:24 +01:00
parent 682a09fbdb
commit c645a9b8bb

View File

@ -25350,7 +25350,8 @@ const hid_driver_t *input_hid_init_first(void)
#endif
static void osk_update_last_codepoint(
struct rarch_state *p_rarch,
unsigned *last_codepoint,
unsigned *last_codepoint_len,
const char *word)
{
const char *letter = word;
@ -25359,15 +25360,12 @@ static void osk_update_last_codepoint(
for (;;)
{
unsigned codepoint = utf8_walk(&letter);
unsigned len = (unsigned)(letter - pos);
if (letter[0] == 0)
{
p_rarch->osk_last_codepoint = codepoint;
p_rarch->osk_last_codepoint_len = len;
*last_codepoint = codepoint;
*last_codepoint_len = (unsigned)(letter - pos);
break;
}
pos = letter;
}
}
@ -25400,8 +25398,8 @@ static bool input_keyboard_line_event(
array[0] = c;
array[1] = 0;
word = array;
ret = true;
word = array;
}
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;
}
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;
@ -25495,7 +25496,10 @@ static void input_keyboard_line_append(
p_rarch->osk_last_codepoint_len = 0;
}
else
osk_update_last_codepoint(p_rarch, word);
osk_update_last_codepoint(
&p_rarch->osk_last_codepoint,
&p_rarch->osk_last_codepoint_len,
word);
}
/**