fix device indexing
This commit is contained in:
parent
0d189ae067
commit
609bcb4dc2
|
@ -2713,14 +2713,19 @@ const char *input_config_get_device_name(unsigned port)
|
||||||
void input_config_set_device_name(unsigned port, const char *name)
|
void input_config_set_device_name(unsigned port, const char *name)
|
||||||
{
|
{
|
||||||
if (!string_is_empty(name))
|
if (!string_is_empty(name))
|
||||||
|
{
|
||||||
strlcpy(input_device_names[port],
|
strlcpy(input_device_names[port],
|
||||||
name,
|
name,
|
||||||
sizeof(input_device_names[port]));
|
sizeof(input_device_names[port]));
|
||||||
|
|
||||||
|
input_autoconfigure_joypad_reindex_devices();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_config_clear_device_name(unsigned port)
|
void input_config_clear_device_name(unsigned port)
|
||||||
{
|
{
|
||||||
input_device_names[port][0] = '\0';
|
input_device_names[port][0] = '\0';
|
||||||
|
input_autoconfigure_joypad_reindex_devices();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned *input_config_get_device_ptr(unsigned port)
|
unsigned *input_config_get_device_ptr(unsigned port)
|
||||||
|
|
|
@ -96,7 +96,7 @@ struct autoconfig_params
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool input_autoconfigured[MAX_USERS];
|
static bool input_autoconfigured[MAX_USERS];
|
||||||
static unsigned input_device_name_index[MAX_USERS];
|
static unsigned input_device_name_index[MAX_INPUT_DEVICES];
|
||||||
static bool input_autoconfigure_swap_override;
|
static bool input_autoconfigure_swap_override;
|
||||||
|
|
||||||
bool input_autoconfigure_get_swap_override(void)
|
bool input_autoconfigure_get_swap_override(void)
|
||||||
|
@ -106,24 +106,38 @@ bool input_autoconfigure_get_swap_override(void)
|
||||||
|
|
||||||
/* Adds an index for devices with the same name,
|
/* Adds an index for devices with the same name,
|
||||||
* so they can be identified in the GUI. */
|
* so they can be identified in the GUI. */
|
||||||
static void input_autoconfigure_joypad_reindex_devices(autoconfig_params_t *params)
|
void input_autoconfigure_joypad_reindex_devices()
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i, j, k;
|
||||||
|
|
||||||
for(i = 0; i < params->max_users; i++)
|
for(i = 0; i < MAX_INPUT_DEVICES; i++)
|
||||||
input_device_name_index[i] = 0;
|
input_device_name_index[i] = 0;
|
||||||
|
|
||||||
for(i = 0; i < params->max_users; i++)
|
for(i = 0; i < MAX_INPUT_DEVICES; i++)
|
||||||
{
|
{
|
||||||
unsigned j;
|
|
||||||
const char *tmp = input_config_get_device_name(i);
|
const char *tmp = input_config_get_device_name(i);
|
||||||
int k = 1;
|
if ( !tmp || input_device_name_index[i] )
|
||||||
|
continue;
|
||||||
|
|
||||||
for(j = 0; j < params->max_users; j++)
|
k = 2; /*Additional devices start at two*/
|
||||||
|
|
||||||
|
for(j = i+1; j < MAX_INPUT_DEVICES; j++)
|
||||||
{
|
{
|
||||||
if(string_is_equal(tmp, input_config_get_device_name(j))
|
const char *other = input_config_get_device_name(j);
|
||||||
&& input_device_name_index[i] == 0)
|
|
||||||
|
if (!other)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*another device with the same name found, for the first time*/
|
||||||
|
if(string_is_equal(tmp, other) &&
|
||||||
|
input_device_name_index[j]==0 )
|
||||||
|
{
|
||||||
|
/*Mark the first device of the set*/
|
||||||
|
input_device_name_index[i] = 1;
|
||||||
|
|
||||||
|
/*count this additional device, from two up*/
|
||||||
input_device_name_index[j] = k++;
|
input_device_name_index[j] = k++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +264,7 @@ static void input_autoconfigure_joypad_add(config_file_t *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
input_autoconfigure_joypad_reindex_devices(params);
|
input_autoconfigure_joypad_reindex_devices();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int input_autoconfigure_joypad_from_conf(
|
static int input_autoconfigure_joypad_from_conf(
|
||||||
|
|
|
@ -245,6 +245,8 @@ bool input_autoconfigure_disconnect(unsigned i, const char *ident);
|
||||||
|
|
||||||
bool input_autoconfigure_get_swap_override(void);
|
bool input_autoconfigure_get_swap_override(void);
|
||||||
|
|
||||||
|
void input_autoconfigure_joypad_reindex_devices(void);
|
||||||
|
|
||||||
void task_push_get_powerstate(void);
|
void task_push_get_powerstate(void);
|
||||||
|
|
||||||
enum frontend_powerstate get_last_powerstate(int *percent);
|
enum frontend_powerstate get_last_powerstate(int *percent);
|
||||||
|
|
Loading…
Reference in New Issue