Rewrite input_state_get_last somewhat

This commit is contained in:
libretroadmin 2023-09-03 17:41:41 +02:00
parent dd3ceb40e9
commit 88437ca5a6
1 changed files with 16 additions and 15 deletions

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; {
int i;
/* find list item */ /* find list item */
for (i = 0; i < runloop_st->input_state_list->size; i++) for (i = 0; i < runloop_st->input_state_list->size; i++)
{ {
input_list_element *element = input_list_element *element =
(input_list_element*)runloop_st->input_state_list->data[i]; (input_list_element*)runloop_st->input_state_list->data[i];
if ( (element->port == port) && if ( (element->port == port)
(element->device == device) && && (element->device == device)
(element->index == index)) && (element->index == index))
{ {
if (id < element->state_size) if (id < element->state_size)
return element->state[id]; return element->state[id];
return 0; break;
} }
} }
}
return 0; return 0;
} }