| 1410 | } |
| 1411 | |
| 1412 | static int matchdevice(struct uae_prefs *p, struct inputdevice_functions *inf, const TCHAR *configname, const TCHAR *name) |
| 1413 | { |
| 1414 | int match = -1; |
| 1415 | for (int j = 0; j < 4; j++) { |
| 1416 | bool fullmatch = j == 0; |
| 1417 | for (int i = 0; i < inf->get_num(); i++) { |
| 1418 | const TCHAR* aname1 = inf->get_friendlyname(i); |
| 1419 | const TCHAR* aname2 = inf->get_uniquename(i); |
| 1420 | if (fullmatch) { |
| 1421 | if (!aname1 || !name) |
| 1422 | continue; |
| 1423 | if (!(p->input_device_match_mask & INPUT_MATCH_BOTH)) |
| 1424 | continue; |
| 1425 | } else { |
| 1426 | if (!(p->input_device_match_mask & INPUT_MATCH_CONFIG_NAME_ONLY)) |
| 1427 | continue; |
| 1428 | } |
| 1429 | if (aname2 && configname && aname2[0] && configname[0]) { |
| 1430 | bool matched = false; |
| 1431 | TCHAR bname[MAX_DPATH]; |
| 1432 | TCHAR bname2[MAX_DPATH]; |
| 1433 | TCHAR *p1 = NULL, *p2 = NULL; |
| 1434 | _tcscpy(bname, configname); |
| 1435 | _tcscpy(bname2, aname2); |
| 1436 | // strip possible local guid part |
| 1437 | if (bname[_tcslen(bname) - 1] == '}') { |
| 1438 | p1 = _tcschr(bname, '{'); |
| 1439 | } |
| 1440 | if (bname[_tcslen(bname2) - 1] == '}') { |
| 1441 | p2 = _tcschr(bname2, '{'); |
| 1442 | } |
| 1443 | if (!p1 && !p2) { |
| 1444 | // check possible directinput names too |
| 1445 | p1 = _tcschr(bname, ' '); |
| 1446 | p2 = _tcschr(bname2, ' '); |
| 1447 | } |
| 1448 | if (!_tcscmp(bname, bname2)) { |
| 1449 | matched = true; |
| 1450 | } else if (p1 && p2 && p1 - bname == p2 - bname2) { |
| 1451 | *p1 = 0; |
| 1452 | *p2 = 0; |
| 1453 | if (bname[0] && !_tcscmp(bname2, bname)) |
| 1454 | matched = true; |
| 1455 | } |
| 1456 | if (matched && fullmatch && _tcscmp(aname1, name) != 0) { |
| 1457 | matched = false; |
| 1458 | } |
| 1459 | if (matched) { |
| 1460 | if (match >= 0) |
| 1461 | match = -2; |
| 1462 | else |
| 1463 | match = i; |
| 1464 | } |
| 1465 | if (match == -2) { |
| 1466 | break; |
| 1467 | } |
| 1468 | } |
| 1469 | } |
no outgoing calls
no test coverage detected