X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=config_file.c;h=248025d1a257d590f488e26d032871fb98e55a13;hb=HEAD;hp=4fbc36ac36e487b553448bbce2a3170a16cbe047;hpb=0418cc5ca78dc31a9039cc028108294335899746;p=libpicofe.git diff --git a/config_file.c b/config_file.c index 4fbc36a..248025d 100644 --- a/config_file.c +++ b/config_file.c @@ -5,6 +5,7 @@ * (at your option): * - GNU GPL, version 2 or later. * - GNU LGPL, version 2.1 or later. + * - MAME license. * See the COPYING file in the top-level directory. */ @@ -91,6 +92,22 @@ void config_write_keys(FILE *f) } } + kbinds = binds[IN_BIND_OFFS(k, IN_BINDTYPE_PLAYER34)]; + for (i = 0; kbinds && me_ctrl_actions[i].name != NULL; i++) { + mask = me_ctrl_actions[i].mask; + if (mask & kbinds) { + strncpy(act, me_ctrl_actions[i].name, 31); + fprintf(f, "bind %s = player3 %s\n", name, mystrip(act)); + kbinds &= ~mask; + } + mask = me_ctrl_actions[i].mask << 16; + if (mask & kbinds) { + strncpy(act, me_ctrl_actions[i].name, 31); + fprintf(f, "bind %s = player4 %s\n", name, mystrip(act)); + kbinds &= ~mask; + } + } + kbinds = binds[IN_BIND_OFFS(k, IN_BINDTYPE_EMU)]; for (i = 0; kbinds && emuctrl_actions[i].name != NULL; i++) { mask = emuctrl_actions[i].mask; @@ -125,12 +142,12 @@ static int parse_bind_val(const char *val, int *type) int player, shift = 0; player = atoi(val + 6) - 1; - if ((unsigned int)player > 1) + if ((unsigned int)player > 3) return -1; - if (player == 1) + if (player & 1) shift = 16; - *type = IN_BINDTYPE_PLAYER12; + *type = IN_BINDTYPE_PLAYER12 + (player >> 1); for (i = 0; me_ctrl_actions[i].name != NULL; i++) { if (strncasecmp(me_ctrl_actions[i].name, val + 8, strlen(val + 8)) == 0) return me_ctrl_actions[i].mask << shift; @@ -146,14 +163,14 @@ static int parse_bind_val(const char *val, int *type) return -1; } -void config_read_keys(const char *cfg) +void config_read_keys(const char *cfg_content) { char dev[256], key[128], *act; const char *p; int bind, bindtype; int dev_id; - p = cfg; + p = cfg_content; while (p != NULL && (p = strstr(p, "binddev = ")) != NULL) { p += 10;