| 10594 | static struct jport jport_config_store[MAX_JPORTS]; |
| 10595 | |
| 10596 | void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig) |
| 10597 | { |
| 10598 | bool changed = false; |
| 10599 | |
| 10600 | for (int i = 0; i < MAX_JPORTS; i++) { |
| 10601 | memcpy(&jport_config_store[i], &p->jports[i], sizeof(struct jport)); |
| 10602 | changed |= p->jports[i].changed; |
| 10603 | } |
| 10604 | |
| 10605 | if (!changed) |
| 10606 | return; |
| 10607 | |
| 10608 | bool defaultports = userconfig == false; |
| 10609 | // Convert old style custom mapping to new style |
| 10610 | for (int i = 0; i < MAX_JPORTS_CUSTOM; i++) { |
| 10611 | struct jport_custom *jpc = &p->jports_custom[i]; |
| 10612 | if (!_tcscmp(jpc->custom, _T("#"))) { |
| 10613 | TCHAR tmp[16]; |
| 10614 | _sntprintf(tmp, sizeof tmp, _T("custom%d"), i); |
| 10615 | inputdevice_joyport_config(p, tmp, NULL, i, -1, -1, 0, userconfig); |
| 10616 | inputdevice_generate_jport_custom(p, i); |
| 10617 | } |
| 10618 | } |
| 10619 | bool matched[MAX_JPORTS]; |
| 10620 | // configname+friendlyname first |
| 10621 | for (int i = 0; i < MAX_JPORTS; i++) { |
| 10622 | struct jport *jp = &jport_config_store[i]; |
| 10623 | matched[i] = false; |
| 10624 | if (jp->idc.configname[0] && jp->idc.name[0] && (p->input_device_match_mask & INPUT_MATCH_BOTH)) { |
| 10625 | if (inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, i, jp->mode, jp->submode, 1, userconfig)) { |
| 10626 | inputdevice_validate_jports(p, i, matched); |
| 10627 | inputdevice_store_used_device(&p->jports[i], i, defaultports); |
| 10628 | matched[i] = true; |
| 10629 | write_log(_T("Port%d: COMBO '%s' + '%s' matched\n"), i, jp->idc.name, jp->idc.configname); |
| 10630 | } |
| 10631 | } |
| 10632 | } |
| 10633 | // configname next |
| 10634 | for (int i = 0; i < MAX_JPORTS; i++) { |
| 10635 | if (!matched[i]) { |
| 10636 | struct jport *jp = &jport_config_store[i]; |
| 10637 | if (jp->idc.configname[0] && (p->input_device_match_mask & INPUT_MATCH_CONFIG_NAME_ONLY)) { |
| 10638 | if (inputdevice_joyport_config(p, NULL, jp->idc.configname, i, jp->mode, jp->submode, 1, userconfig)) { |
| 10639 | inputdevice_validate_jports(p, i, matched); |
| 10640 | inputdevice_store_used_device(&p->jports[i], i, defaultports); |
| 10641 | matched[i] = true; |
| 10642 | write_log(_T("Port%d: CONFIG '%s' matched\n"), i, jp->idc.configname); |
| 10643 | } |
| 10644 | } |
| 10645 | } |
| 10646 | } |
| 10647 | // friendly name next |
| 10648 | for (int i = 0; i < MAX_JPORTS; i++) { |
| 10649 | if (!matched[i]) { |
| 10650 | struct jport *jp = &jport_config_store[i]; |
| 10651 | if (jp->idc.name[0] && (p->input_device_match_mask & INPUT_MATCH_FRIENDLY_NAME_ONLY)) { |
| 10652 | if (inputdevice_joyport_config(p, jp->idc.name, NULL, i, jp->mode, jp->submode, 1, userconfig)) { |
| 10653 | inputdevice_validate_jports(p, i, matched); |
no test coverage detected