emu_window_sdl2.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2016 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 <utility>
  7. #include "core/frontend/emu_window.h"
  8. #include "core/frontend/motion_emu.h"
  9. struct SDL_Window;
  10. class EmuWindow_SDL2 : public EmuWindow {
  11. public:
  12. EmuWindow_SDL2();
  13. ~EmuWindow_SDL2();
  14. /// Swap buffers to display the next frame
  15. void SwapBuffers() override;
  16. /// Polls window events
  17. void PollEvents() override;
  18. /// Makes the graphics context current for the caller thread
  19. void MakeCurrent() override;
  20. /// Releases the GL context from the caller thread
  21. void DoneCurrent() override;
  22. /// Whether the window is still open, and a close request hasn't yet been sent
  23. bool IsOpen() const;
  24. /// Load keymap from configuration
  25. void ReloadSetKeymaps() override;
  26. private:
  27. /// Called by PollEvents when a key is pressed or released.
  28. void OnKeyEvent(int key, u8 state);
  29. /// Called by PollEvents when the mouse moves.
  30. void OnMouseMotion(s32 x, s32 y);
  31. /// Called by PollEvents when a mouse button is pressed or released
  32. void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
  33. /// Called by PollEvents when any event that may cause the window to be resized occurs
  34. void OnResize();
  35. /// Called when a configuration change affects the minimal size of the window
  36. void OnMinimalClientAreaChangeRequest(
  37. const std::pair<unsigned, unsigned>& minimal_size) override;
  38. /// Is the window still open?
  39. bool is_open = true;
  40. /// Internal SDL2 render window
  41. SDL_Window* render_window;
  42. using SDL_GLContext = void*;
  43. /// The OpenGL context associated with the window
  44. SDL_GLContext gl_context;
  45. /// Device id of keyboard for use with KeyMap
  46. int keyboard_id;
  47. /// Motion sensors emulation
  48. std::unique_ptr<Motion::MotionEmu> motion_emu;
  49. };