| 507 | } |
| 508 | |
| 509 | bool DispatchInputEvents(D3D9Wrapper::IDirect3DDevice9 *device) |
| 510 | { |
| 511 | std::vector<class InputAction *>::iterator i; |
| 512 | class InputAction *action; |
| 513 | bool input_processed = false; |
| 514 | static time_t last_time = 0; |
| 515 | time_t now = time(NULL); |
| 516 | int j; |
| 517 | |
| 518 | if (!CheckForegroundWindow()) |
| 519 | return false; |
| 520 | |
| 521 | for (j = 0; j < 4; j++) { |
| 522 | // Stagger polling controllers that were not connected last |
| 523 | // frame over four seconds to minimise performance impact, |
| 524 | // which has been observed to be extremely significant. |
| 525 | if (!XInputState[j].connected && ((now == last_time) || (now % 4 != j))) |
| 526 | continue; |
| 527 | |
| 528 | XInputState[j].connected = |
| 529 | (_XInputGetState(j, &XInputState[j].state) == ERROR_SUCCESS); |
| 530 | } |
| 531 | |
| 532 | last_time = now; |
| 533 | |
| 534 | for (i = actions.begin(); i != actions.end(); i++) { |
| 535 | action = *i; |
| 536 | |
| 537 | input_processed |= action->Dispatch(device); |
| 538 | } |
| 539 | |
| 540 | return input_processed; |
| 541 | } |
no test coverage detected