X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fconfig.c;h=c117fb901fec26991009479ef476bf8a4a6895b7;hb=8e708f920ffd20b026aed616e58c8c8e94c8fb8d;hp=534fb4000dea7abad9d5df987933a38f3fc32f86;hpb=367b6f1f939dcd7930d372aee0ca900b0b8790b1;p=libpicofe.git diff --git a/common/config.c b/common/config.c index 534fb40..c117fb9 100644 --- a/common/config.c +++ b/common/config.c @@ -24,7 +24,7 @@ static const int *cfg_opt_counts[] = { &opt_entry_count, &opt2_entry_count, &cdo #define NL "\n" -static void mystrip(char *str) +static char *mystrip(char *str) { int i, len; @@ -32,10 +32,13 @@ static void mystrip(char *str) for (i = 0; i < len; i++) if (str[i] != ' ') break; if (i > 0) memmove(str, str + i, len - i + 1); + len = strlen(str); for (i = len - 1; i >= 0; i--) if (str[i] != ' ') break; str[i+1] = 0; + + return str; } @@ -167,22 +170,18 @@ static void keys_write(FILE *fn, const char *bind_str, const int binds[32], #endif for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) { if (me_ctrl_actions[i].mask & binds[t]) { - sprintf(act, "player%i ", ((binds[t]>>16)&1)+1); - strncpy(act + 8, me_ctrl_actions[i].name, 31); - break; + strncpy(act, me_ctrl_actions[i].name, 31); + fprintf(fn, "%s %s = player%i %s" NL, bind_str, names[t], + ((binds[t]>>16)&1)+1, mystrip(act)); } } - if (act[0] == 0) - { - for (i = 0; emuctrl_actions[i].name != NULL; i++) - if (emuctrl_actions[i].mask & binds[t]) { - strncpy(act, emuctrl_actions[i].name, 31); - break; - } - } - mystrip(act); - fprintf(fn, "%s %s = %s" NL, bind_str, names[t], act); + for (i = 0; emuctrl_actions[i].name != NULL; i++) { + if (emuctrl_actions[i].mask & binds[t]) { + strncpy(act, emuctrl_actions[i].name, 31); + fprintf(fn, "%s %s = %s" NL, bind_str, names[t], mystrip(act)); + } + } } } @@ -566,9 +565,11 @@ static int custom_read(menu_entry *me, const char *var, const char *val) } +static unsigned int keys_encountered = 0; + static void keys_parse(const char *var, const char *val, int binds[32], const char *names[32]) { - int t, i, keys_encountered = 0; + int t, i; unsigned int player; for (t = 0; t < 32; t++) @@ -580,7 +581,7 @@ static void keys_parse(const char *var, const char *val, int binds[32], const ch return; } - if (!(keys_encountered & (1<