fork download
  1. void x360::InputUpdate()
  2. {
  3. XINPUT_STATE state;
  4. x360::InputManager& manager = x360::InputManager::get_instance();
  5.  
  6. for (int i=0; i<4; ++i)
  7. {
  8. ZeroMemory(&state, sizeof XINPUT_STATE);
  9. if (XInputGetState(i,&state) == ERROR_SUCCESS)
  10. {
  11. if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) {
  12. manager.events.push(x360::Event(X360_PRESS,XINPUT_GAMEPAD_A));
  13. }
  14.  
  15. if (state.Gamepad.wButtons & XINPUT_GAMEPAD_B) {
  16. manager.events.push(x360::Event(X360_PRESS,XINPUT_GAMEPAD_B));
  17. }
  18.  
  19. if (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) {
  20. manager.events.push(x360::Event(X360_PRESS,XINPUT_GAMEPAD_X));
  21. }
  22.  
  23. if (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) {
  24. manager.events.push(x360::Event(X360_PRESS,XINPUT_GAMEPAD_Y));
  25. }
  26. }
  27. }
  28. }
  29.  
  30. bool x360::GetEvent(x360::Event* eventptr)
  31. {
  32. x360::InputManager& manager = x360::InputManager::get_instance();
  33. std::queue<x360::Event>::size_type previousSize = manager.events.size();
  34.  
  35. if (previousSize > 0)
  36. {
  37. *eventptr = manager.events.front();
  38. manager.events.pop();
  39. }
  40.  
  41. return previousSize != manager.events.size();
  42. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty