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

Function inputdevice_validate_jports

src/inputdevice.cpp:10318–10379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10316}
10317
10318void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fixedports)
10319{
10320 for (int i = 0; i < MAX_JPORTS; i++) {
10321 fixjport (&p->jports[i], 0, changedport == i);
10322 }
10323
10324 for (int i = 0; i < MAX_JPORTS; i++) {
10325 if (p->jports[i].id < 0)
10326 continue;
10327 for (int j = 0; j < MAX_JPORTS; j++) {
10328 if (p->jports[j].id < 0)
10329 continue;
10330 if (j == i)
10331 continue;
10332 if (p->jports[i].id == p->jports[j].id) {
10333 int cnt = 0;
10334 for (;;) {
10335 int k;
10336 if (i == changedport) {
10337 k = j;
10338 if (fixedports && fixedports[k]) {
10339 k = i;
10340 }
10341 } else {
10342 k = i;
10343 }
10344 // same in other slots too?
10345 bool other = false;
10346 for (int l = 0; l < MAX_JPORTS; l++) {
10347 if (l == k)
10348 continue;
10349 if (p->jports[l].id == p->jports[k].id) {
10350 other = true;
10351 }
10352 }
10353
10354 if (!other && p->jports[i].id != p->jports[j].id)
10355 break;
10356
10357 struct jport *jp = NULL;
10358 for (;;) {
10359 jp = inputdevice_get_used_device(k, cnt);
10360 cnt++;
10361 if (!jp)
10362 break;
10363 if (jp->id < 0)
10364 continue;
10365 memcpy(&p->jports[k].id, jp, sizeof(struct jport));
10366 if (fixjport(&p->jports[k], 0, false))
10367 continue;
10368 inputdevice_set_newest_used_device(k, &p->jports[k]);
10369 break;
10370 }
10371 if (jp)
10372 continue;
10373 freejport(p, k);
10374 break;
10375 }

Callers 5

switchdeviceFunction · 0.85
inputdevice_devicechangeFunction · 0.85
inputdevice_mouse_reinitFunction · 0.85
inputdevice_fix_prefsFunction · 0.85
render_panel_inputFunction · 0.85

Calls 4

fixjportFunction · 0.85
freejportFunction · 0.85

Tested by

no test coverage detected