move more code out of retroarch.c

This commit is contained in:
twinaphex 2021-09-18 21:14:15 +02:00
parent 1c546cb7fd
commit eb895f9947
4 changed files with 37 additions and 33 deletions

View File

@ -24,6 +24,7 @@
#include "input_driver.h"
#include "input_keymaps.h"
#include "input_remapping.h"
#include "input_osk.h"
#ifdef HAVE_NETWORKING
@ -2143,3 +2144,25 @@ bool input_driver_find_driver(
return true;
}
void input_mapper_reset(void *data)
{
unsigned i;
input_mapper_t *handle = (input_mapper_t*)data;
for (i = 0; i < MAX_USERS; i++)
{
unsigned j;
for (j = 0; j < 8; j++)
{
handle->analog_value[i][j] = 0;
handle->buttons[i].data[j] = 0;
handle->buttons[i].analogs[j] = 0;
handle->buttons[i].analog_buttons[j] = 0;
}
}
for (i = 0; i < RETROK_LAST; i++)
handle->key_button[i] = 0;
for (i = 0; i < (RETROK_LAST / 32 + 1); i++)
handle->keys[i] = 0;
}

View File

@ -23,6 +23,18 @@
#include <boolean.h>
#include <retro_common_api.h>
typedef struct input_mapper
{
/* Left X, Left Y, Right X, Right Y */
int16_t analog_value[MAX_USERS][8];
/* The whole keyboard state */
uint32_t keys[RETROK_LAST / 32 + 1];
/* RetroPad button state of remapped keyboard keys */
unsigned key_button[RETROK_LAST];
/* This is a bitmask of (1 << key_bind_id). */
input_bits_t buttons[MAX_USERS];
} input_mapper_t;
RETRO_BEGIN_DECLS
/**
@ -183,6 +195,8 @@ void config_read_keybinds_conf(void *data);
*/
void input_config_set_autoconfig_binds(unsigned port, void *data);
void input_mapper_reset(void *data);
RETRO_END_DECLS
#endif

View File

@ -28911,27 +28911,6 @@ static const menu_ctx_driver_t *menu_driver_find_driver(
}
#endif
static void input_mapper_reset(input_mapper_t *handle)
{
unsigned i;
for (i = 0; i < MAX_USERS; i++)
{
unsigned j;
for (j = 0; j < 8; j++)
{
handle->analog_value[i][j] = 0;
handle->buttons[i].data[j] = 0;
handle->buttons[i].analogs[j] = 0;
handle->buttons[i].analog_buttons[j] = 0;
}
}
for (i = 0; i < RETROK_LAST; i++)
handle->key_button[i] = 0;
for (i = 0; i < (RETROK_LAST / 32 + 1); i++)
handle->keys[i] = 0;
}
/**
* retroarch_main_init:
* @argc : Count of (commandline) arguments.

View File

@ -1075,18 +1075,6 @@ typedef struct input_game_focus_state
typedef bool(*runahead_load_state_function)(const void*, size_t);
#endif
typedef struct input_mapper
{
/* Left X, Left Y, Right X, Right Y */
int16_t analog_value[MAX_USERS][8];
/* The whole keyboard state */
uint32_t keys[RETROK_LAST / 32 + 1];
/* RetroPad button state of remapped keyboard keys */
unsigned key_button[RETROK_LAST];
/* This is a bitmask of (1 << key_bind_id). */
input_bits_t buttons[MAX_USERS];
} input_mapper_t;
#ifdef HAVE_DISCORD
/* The Discord API specifies these variables:
- userId --------- char[24] - the userId of the player asking to join