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

Function process_custom_event

src/inputdevice.cpp:6446–6535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6444
6445
6446static bool process_custom_event (struct uae_input_device *id, int offset, int state, uae_u64 *qualmask, int autofire, int sub)
6447{
6448 int idx, slotoffset, custompos;
6449 TCHAR *custom;
6450 uae_u64 flags, qual;
6451
6452 if (!id)
6453 return false;
6454
6455 slotoffset = sub & ~3;
6456 sub &= 3;
6457 flags = id->flags[offset][slotoffset];
6458 qual = flags & ID_FLAG_QUALIFIER_MASK;
6459 custom = id->custom[offset][slotoffset];
6460
6461 for (idx = 1; idx < 4; idx++) {
6462 uae_u64 flags2 = id->flags[offset][slotoffset + idx];
6463
6464 // all slots must have same qualifier
6465 if ((flags2 & ID_FLAG_QUALIFIER_MASK) != qual)
6466 break;
6467 // no slot must have autofire
6468 if ((flags2 & ID_FLAG_AUTOFIRE_MASK) || (flags & ID_FLAG_AUTOFIRE_MASK))
6469 break;
6470 }
6471 // at least slot 0 and 2 must have custom
6472 if (custom == NULL || id->custom[offset][slotoffset + 2] == NULL)
6473 idx = -1;
6474
6475 if (idx < 4) {
6476 id->flags[offset][slotoffset] &= ~(ID_FLAG_CUSTOMEVENT_TOGGLED1 | ID_FLAG_CUSTOMEVENT_TOGGLED2);
6477 int evt2 = id->eventid[offset][slotoffset + sub];
6478 uae_u64 flags2 = id->flags[offset][slotoffset + sub];
6479 if (checkqualifiers (evt2, flags2, qualmask, NULL)) {
6480 custom = id->custom[offset][slotoffset + sub];
6481 if (state && custom) {
6482 if (autofire)
6483 queue_input_event (-1, custom, 1, 1, currprefs.input_autofire_linecnt, 1);
6484 handle_custom_event (custom, 0);
6485 return true;
6486 }
6487 }
6488 return false;
6489 }
6490
6491 if (sub != 0)
6492 return false;
6493
6494 slotoffset = 0;
6495 if (!checkqualifiers (id->eventid[offset][slotoffset], id->flags[offset][slotoffset], qualmask, NULL)) {
6496 slotoffset = 4;
6497 if (!checkqualifiers (id->eventid[offset][slotoffset], id->flags[offset][slotoffset], qualmask, NULL))
6498 return false;
6499 }
6500
6501 flags = id->flags[offset][slotoffset];
6502 custompos = (flags & ID_FLAG_CUSTOMEVENT_TOGGLED1) ? 1 : 0;
6503 custompos |= (flags & ID_FLAG_CUSTOMEVENT_TOGGLED2) ? 2 : 0;

Callers 2

setbuttonstateallFunction · 0.85

Calls 3

checkqualifiersFunction · 0.85
queue_input_eventFunction · 0.85
handle_custom_eventFunction · 0.85

Tested by

no test coverage detected