emu_window_sdl2.h 1.8 KB

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