mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
remap-redux part2: fix saving, loading and set defaults
This commit is contained in:
parent
f517ca3b56
commit
2b9b829459
@ -158,15 +158,21 @@ void input_mapper_poll(input_mapper_t *handle)
|
||||
current_button_value = BIT256_GET(current_input, j);
|
||||
remap_button = settings->uints.input_remap_ids[i][j];
|
||||
if (current_button_value == 1 && j != remap_button &&
|
||||
remap_button != RARCH_UNMAPPED)
|
||||
remap_button != RARCH_UNMAPPED && remap_button < RARCH_FIRST_CUSTOM_BIND)
|
||||
BIT256_SET(handle->buttons[i], remap_button);
|
||||
else if (current_button_value == 1 && j != remap_button &&
|
||||
remap_button != RARCH_UNMAPPED && remap_button >= RARCH_FIRST_CUSTOM_BIND)
|
||||
{
|
||||
int invert = 1;
|
||||
|
||||
if (remap_button % 2 != 0)
|
||||
invert = -1;
|
||||
|
||||
handle->analog_value[i][remap_button - RARCH_FIRST_CUSTOM_BIND] = 32767 * invert;
|
||||
/* RARCH_LOG("axis %d(%d) remapped to axis %d val %d\n", j, k,
|
||||
remap_button - RARCH_FIRST_CUSTOM_BIND, current_axis_value); */
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
/* --CURRENTLY NOT IMPLEMENTED--
|
||||
this loop should iterate on all users and all analog stick axes and if the axes are
|
||||
moved and is assigned to a button it should set the bit on the mapper input bitmap.
|
||||
Once implemented we should make sure to clear the original analog
|
||||
stick input in input_state in input_driver.c */
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
@ -180,25 +186,23 @@ void input_mapper_poll(input_mapper_t *handle)
|
||||
if (remap_axis < RARCH_FIRST_CUSTOM_BIND)
|
||||
{
|
||||
BIT256_SET(handle->buttons[i], remap_axis);
|
||||
/* RARCH_LOG("axis %d remapped to button %d val %d\n", j, remap_axis, current_axis_value); */
|
||||
/* RARCH_LOG("axis %d remapped to button %d val %d\n", j,
|
||||
remap_axis, current_axis_value); */
|
||||
}
|
||||
else
|
||||
{
|
||||
int invert = 1;
|
||||
/*if ((k == 16 && remap_axis == 17) || (k == 17 && remap_axis == 16) ||
|
||||
(k == 18 && remap_axis == 19) || (k == 19 && remap_axis == 18) ||
|
||||
(k == 20 && remap_axis == 21) || (k == 21 && remap_axis == 20) ||
|
||||
(k == 22 && remap_axis == 23) || (k == 23 && remap_axis == 22))*/
|
||||
|
||||
if ((k % 2 == 0 && remap_axis % 2 != 0) || (k % 2 != 0 && remap_axis % 2 == 0))
|
||||
invert = -1;
|
||||
|
||||
handle->analog_value[i][remap_axis - RARCH_FIRST_CUSTOM_BIND] = current_axis_value * invert;
|
||||
/* RARCH_LOG("axis %d(%d) remapped to axis %d val %d\n", j, k, remap_axis - RARCH_FIRST_CUSTOM_BIND, current_axis_value); */
|
||||
/* RARCH_LOG("axis %d(%d) remapped to axis %d val %d\n", j, k,
|
||||
remap_axis - RARCH_FIRST_CUSTOM_BIND, current_axis_value); */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,7 +238,7 @@ void input_mapper_state(
|
||||
|
||||
if(handle->analog_value[port][0] || handle->analog_value[port][1])
|
||||
{
|
||||
*ret = val;
|
||||
*ret |= val;
|
||||
}
|
||||
}
|
||||
if (id == 1)
|
||||
@ -246,7 +250,7 @@ void input_mapper_state(
|
||||
|
||||
if(handle->analog_value[port][2] || handle->analog_value[port][3])
|
||||
{
|
||||
*ret = val;
|
||||
*ret |= val;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,7 +265,7 @@ void input_mapper_state(
|
||||
|
||||
if(handle->analog_value[port][4] || handle->analog_value[port][5])
|
||||
{
|
||||
*ret = val;
|
||||
*ret |= val;
|
||||
}
|
||||
}
|
||||
if (id == 1)
|
||||
@ -273,7 +277,7 @@ void input_mapper_state(
|
||||
|
||||
if(handle->analog_value[port][6] || handle->analog_value[port][7])
|
||||
{
|
||||
*ret = val;
|
||||
*ret |= val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||
char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}};
|
||||
char stk_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}};
|
||||
|
||||
bool ret = false;
|
||||
|
||||
char key_strings[RARCH_FIRST_CUSTOM_BIND + 8][128] = {
|
||||
"b", "y", "select", "start",
|
||||
"up", "down", "left", "right",
|
||||
@ -85,11 +87,12 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||
key_strings[j], '_', sizeof(btn_ident[j]));
|
||||
|
||||
if (config_get_int(conf, btn_ident[j], &btn_remap)
|
||||
&& (btn_remap < RARCH_FIRST_CUSTOM_BIND && btn_remap != -1))
|
||||
&& btn_remap != -1)
|
||||
settings->uints.input_remap_ids[i][j] = btn_remap;
|
||||
else if (config_get_int(conf, btn_ident[j], &btn_remap)
|
||||
&& (btn_remap == -1))
|
||||
&& btn_remap == -1)
|
||||
settings->uints.input_remap_ids[i][j] = RARCH_UNMAPPED;
|
||||
/* else do nothing, important */
|
||||
|
||||
int key_remap = -1;
|
||||
|
||||
@ -112,11 +115,15 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||
s3,
|
||||
key_strings[j]);
|
||||
|
||||
if (config_get_int(conf, stk_ident[j],
|
||||
&stk_remap))
|
||||
settings->uints.input_remap_ids[i][j] =
|
||||
stk_remap;
|
||||
RARCH_LOG("stk_ident: %s:%d\n", stk_ident[j], settings->uints.input_remap_ids[i][j]);
|
||||
RARCH_LOG("pre_ident: %s:%d\n", stk_ident[j], settings->uints.input_remap_ids[i][j]);
|
||||
|
||||
if (config_get_int(conf, stk_ident[j], &stk_remap) && stk_remap != -1)
|
||||
settings->uints.input_remap_ids[i][j] = stk_remap;
|
||||
else if (config_get_int(conf, stk_ident[j], &stk_remap) && stk_remap == -1)
|
||||
settings->uints.input_remap_ids[i][j] = RARCH_UNMAPPED;
|
||||
/* else do nothing, important */
|
||||
|
||||
/*RARCH_LOG("stk_ident: %s:%d\n", stk_ident[j], settings->uints.input_remap_ids[i][j]);*/
|
||||
}
|
||||
|
||||
snprintf(s1, sizeof(s1), "input_player%u_analog_dpad_mode", i + 1);
|
||||
@ -191,7 +198,7 @@ bool input_remapping_save_file(const char *path)
|
||||
snprintf(s2, sizeof(s2), "input_player%u_key", i + 1);
|
||||
snprintf(s3, sizeof(s1), "input_player%u_stk", i + 1);
|
||||
|
||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 4; j++)
|
||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 8; j++)
|
||||
{
|
||||
fill_pathname_join_delim(btn_ident[j], s1,
|
||||
key_strings[j], '_', sizeof(btn_ident[j]));
|
||||
@ -201,9 +208,11 @@ bool input_remapping_save_file(const char *path)
|
||||
/* only save values that have been modified */
|
||||
if(j < RARCH_FIRST_CUSTOM_BIND)
|
||||
{
|
||||
if(settings->uints.input_remap_ids[i][j] != j && settings->uints.input_remap_ids[i][j] != RARCH_UNMAPPED)
|
||||
if(settings->uints.input_remap_ids[i][j] != j &&
|
||||
settings->uints.input_remap_ids[i][j] != RARCH_UNMAPPED)
|
||||
config_set_int(conf, btn_ident[j], settings->uints.input_remap_ids[i][j]);
|
||||
else if (settings->uints.input_remap_ids[i][j] != j && settings->uints.input_remap_ids[i][j] == RARCH_UNMAPPED)
|
||||
else if (settings->uints.input_remap_ids[i][j] != j &&
|
||||
settings->uints.input_remap_ids[i][j] == RARCH_UNMAPPED)
|
||||
config_set_int(conf, btn_ident[j], -1);
|
||||
else
|
||||
config_unset(conf,btn_ident[j]);
|
||||
@ -217,9 +226,14 @@ bool input_remapping_save_file(const char *path)
|
||||
{
|
||||
fill_pathname_join_delim(stk_ident[j], s3,
|
||||
key_strings[j], '_', sizeof(stk_ident[j]));
|
||||
if(settings->uints.input_remap_ids[i][j] != j - RARCH_FIRST_CUSTOM_BIND)
|
||||
if(settings->uints.input_remap_ids[i][j] != j &&
|
||||
settings->uints.input_remap_ids[i][j] != RARCH_UNMAPPED)
|
||||
config_set_int(conf, stk_ident[j],
|
||||
settings->uints.input_remap_ids[i][j]);
|
||||
else if(settings->uints.input_remap_ids[i][j] != j &&
|
||||
settings->uints.input_remap_ids[i][j] == RARCH_UNMAPPED)
|
||||
config_set_int(conf, stk_ident[j],
|
||||
-1);
|
||||
else
|
||||
config_unset(conf,btn_ident[j]);
|
||||
}
|
||||
@ -286,7 +300,10 @@ void input_remapping_set_defaults(bool deinit)
|
||||
settings->uints.input_keymapper_ids[i][j] = RETROK_UNKNOWN;
|
||||
}
|
||||
for (j = RARCH_FIRST_CUSTOM_BIND; j < RARCH_FIRST_CUSTOM_BIND + 8; j++)
|
||||
{
|
||||
RARCH_LOG("******************User: %d Val: %d\n", i, j );
|
||||
settings->uints.input_remap_ids[i][j] = j;
|
||||
}
|
||||
|
||||
if (old_analog_dpad_mode[i])
|
||||
settings->uints.input_analog_dpad_mode[i] = old_analog_dpad_mode[i];
|
||||
|
Loading…
x
Reference in New Issue
Block a user