MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / matchdevices

Function matchdevices

src/inputdevice.cpp:8019–8119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8017}
8018
8019static void matchdevices(struct uae_prefs *p, struct inputdevice_functions *inf, struct uae_input_device *uid, int devnum, int match_mask)
8020{
8021 int i, j;
8022
8023 for (int l = 0; l < 2; l++) {
8024 bool fullmatch = l == 0;
8025 int match = -1;
8026 for (i = 0; i < inf->get_num (); i++) {
8027 const TCHAR* aname1 = inf->get_friendlyname (i);
8028 const TCHAR* aname2 = inf->get_uniquename (i);
8029 for (j = 0; j < MAX_INPUT_DEVICES; j++) {
8030 if (aname2 && uid[j].configname) {
8031 bool matched = false;
8032 TCHAR bname[MAX_DPATH];
8033 TCHAR bname2[MAX_DPATH];
8034 TCHAR *p1 ,*p2;
8035 TCHAR *bname1 = uid[j].name;
8036
8037 if (fullmatch) {
8038 if (!(match_mask & INPUT_MATCH_BOTH))
8039 continue;
8040 } else {
8041 if (!(match_mask & INPUT_MATCH_CONFIG_NAME_ONLY))
8042 continue;
8043 }
8044
8045 _tcscpy (bname, uid[j].configname);
8046 _tcscpy (bname2, aname2);
8047 // strip possible local guid part
8048 p1 = _tcschr (bname, '{');
8049 p2 = _tcschr (bname2, '{');
8050 if (!p1 && !p2) {
8051 // check possible directinput names too
8052 p1 = _tcschr (bname, ' ');
8053 p2 = _tcschr (bname2, ' ');
8054 }
8055 if (!_tcscmp (bname, bname2)) {
8056 matched = true;
8057 } else if (p1 && p2 && p1 - bname == p2 - bname2) {
8058 *p1 = 0;
8059 *p2 = 0;
8060 if (bname[0] && !_tcscmp (bname2, bname))
8061 matched = true;
8062 }
8063 if (matched && fullmatch && aname1 && bname1 && _tcscmp(aname1, bname1) != 0)
8064 matched = false;
8065 if (matched) {
8066 if (match >= 0)
8067 match = -2;
8068 else
8069 match = j;
8070 }
8071 if (match == -2)
8072 break;
8073 }
8074 }
8075 if (!fullmatch) {
8076 // multiple matches -> use complete local-only id string for comparisons

Callers 1

matchdevices_allFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected