MCPcopy Create free account
hub / github.com/TASEmulators/fceux / UpdateGamepad

Function UpdateGamepad

src/drivers/Qt/input.cpp:1470–1569  ·  view source on GitHub ↗

* Update the status of the gamepad input devices. */

Source from the content-addressed store, hash-verified

1468 * Update the status of the gamepad input devices.
1469 */
1470static void
1471UpdateGamepad(void)
1472{
1473 // don't update during movie playback
1474 if (FCEUMOV_Mode(MOVIEMODE_PLAY))
1475 {
1476 return;
1477 }
1478
1479 uint32 JS = 0;
1480 int x,c;
1481 int wg;
1482 bool fire;
1483 char btns[GAMEPAD_NUM_BUTTONS];
1484
1485 int opposite_dirs;
1486 g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs);
1487
1488 // go through each of the four game pads
1489 for (wg = 0; wg < 4; wg++)
1490 {
1491 bool left = false;
1492 bool up = false;
1493 memset( btns, 0, sizeof(btns) );
1494
1495 for (c = 0; c < GamePad_t::NUM_CONFIG; c++)
1496 {
1497 // a, b, select, start, up, down, left, right
1498 for (x = 0; x < 8; x++)
1499 {
1500 if (DTestButton(&GamePad[wg].bmap[c][x]))
1501 {
1502 btns[x] = 1;
1503 //printf("GamePad%i Button Hit: %i \n", wg, x );
1504 if (opposite_dirs == 0)
1505 {
1506 // test for left+right and up+down
1507 if (x == 4)
1508 {
1509 up = true;
1510 }
1511 if ((x == 5) && (up == true))
1512 {
1513 continue;
1514 }
1515 if (x == 6)
1516 {
1517 left = true;
1518 }
1519 if ((x == 7) && (left == true))
1520 {
1521 continue;
1522 }
1523 }
1524 JS |= (1 << x) << (wg << 3);
1525 }
1526 }
1527

Callers 1

FCEUD_UpdateInputFunction · 0.70

Calls 6

FCEUMOV_ModeFunction · 0.85
FCEUI_KillFunction · 0.85
GetAutoFireStateFunction · 0.85
getOptionMethod · 0.80
DTestButtonFunction · 0.70
CloseGameFunction · 0.70

Tested by

no test coverage detected