Rewrite input_state_get_last somewhat

This commit is contained in:
libretroadmin 2023-09-03 17:41:41 +02:00
parent dd3ceb40e9
commit 88437ca5a6

View File

@ -40,27 +40,28 @@
static int16_t input_state_get_last(unsigned port, static int16_t input_state_get_last(unsigned port,
unsigned device, unsigned index, unsigned id) unsigned device, unsigned index, unsigned id)
{ {
int i;
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
if (!runloop_st->input_state_list) if (runloop_st->input_state_list)
return 0;
/* find list item */
for (i = 0; i < runloop_st->input_state_list->size; i++)
{ {
input_list_element *element = int i;
(input_list_element*)runloop_st->input_state_list->data[i]; /* find list item */
for (i = 0; i < runloop_st->input_state_list->size; i++)
if ( (element->port == port) &&
(element->device == device) &&
(element->index == index))
{ {
if (id < element->state_size) input_list_element *element =
return element->state[id]; (input_list_element*)runloop_st->input_state_list->data[i];
return 0;
if ( (element->port == port)
&& (element->device == device)
&& (element->index == index))
{
if (id < element->state_size)
return element->state[id];
break;
}
} }
} }
return 0; return 0;
} }