sdl.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2017 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <vector>
  7. #include "core/frontend/input.h"
  8. union SDL_Event;
  9. namespace Common {
  10. class ParamPackage;
  11. }
  12. namespace InputCommon {
  13. namespace Polling {
  14. class DevicePoller;
  15. enum class DeviceType;
  16. } // namespace Polling
  17. } // namespace InputCommon
  18. namespace InputCommon {
  19. namespace SDL {
  20. /// Initializes and registers SDL device factories
  21. void Init();
  22. /// Unresisters SDL device factories and shut them down.
  23. void Shutdown();
  24. /// Needs to be called before SDL_QuitSubSystem.
  25. void CloseSDLJoysticks();
  26. /// Handle SDL_Events for joysticks from SDL_PollEvent
  27. void HandleGameControllerEvent(const SDL_Event& event);
  28. /// A Loop that calls HandleGameControllerEvent until Shutdown is called
  29. void PollLoop();
  30. /// Creates a ParamPackage from an SDL_Event that can directly be used to create a ButtonDevice
  31. Common::ParamPackage SDLEventToButtonParamPackage(const SDL_Event& event);
  32. namespace Polling {
  33. /// Get all DevicePoller that use the SDL backend for a specific device type
  34. std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers(
  35. InputCommon::Polling::DeviceType type);
  36. } // namespace Polling
  37. } // namespace SDL
  38. } // namespace InputCommon