emu_window.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common.h"
  6. #include "common/scm_rev.h"
  7. #include "common/key_map.h"
  8. // Abstraction class used to provide an interface between emulation code and the frontend (e.g. SDL,
  9. // QGLWidget, GLFW, etc...)
  10. class EmuWindow
  11. {
  12. public:
  13. /// Data structure to store an emuwindow configuration
  14. struct Config{
  15. bool fullscreen;
  16. int res_width;
  17. int res_height;
  18. };
  19. /// Swap buffers to display the next frame
  20. virtual void SwapBuffers() = 0;
  21. /// Polls window events
  22. virtual void PollEvents() = 0;
  23. /// Makes the graphics context current for the caller thread
  24. virtual void MakeCurrent() = 0;
  25. /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread
  26. virtual void DoneCurrent() = 0;
  27. /// Signals a key press action to the HID module
  28. static void KeyPressed(KeyMap::HostDeviceKey key);
  29. /// Signals a key release action to the HID module
  30. static void KeyReleased(KeyMap::HostDeviceKey key);
  31. Config GetConfig() const {
  32. return m_config;
  33. }
  34. void SetConfig(const Config& val) {
  35. m_config = val;
  36. }
  37. int GetClientAreaWidth() const {
  38. return m_client_area_width;
  39. }
  40. void SetClientAreaWidth(const int val) {
  41. m_client_area_width = val;
  42. }
  43. int GetClientAreaHeight() const {
  44. return m_client_area_height;
  45. }
  46. void SetClientAreaHeight(const int val) {
  47. m_client_area_height = val;
  48. }
  49. std::string GetWindowTitle() const {
  50. return m_window_title;
  51. }
  52. void SetWindowTitle(std::string val) {
  53. m_window_title = val;
  54. }
  55. protected:
  56. EmuWindow() : m_client_area_width(640), m_client_area_height(480) {
  57. char window_title[255];
  58. sprintf(window_title, "Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
  59. m_window_title = window_title;
  60. }
  61. virtual ~EmuWindow() {}
  62. std::string m_window_title; ///< Current window title, should be used by window impl.
  63. int m_client_area_width; ///< Current client width, should be set by window impl.
  64. int m_client_area_height; ///< Current client height, should be set by window impl.
  65. private:
  66. Config m_config; ///< Internal configuration
  67. };