diff options
Diffstat (limited to 'src/citra/emu_window')
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 168 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.h | 54 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 167 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.h | 64 |
4 files changed, 231 insertions, 222 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp deleted file mode 100644 index 9453b1f48..000000000 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <cstdlib> | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | // Let’s use our own GL header, instead of one from GLFW. | ||
| 10 | #include <glad/glad.h> | ||
| 11 | #define GLFW_INCLUDE_NONE | ||
| 12 | #include <GLFW/glfw3.h> | ||
| 13 | |||
| 14 | #include "common/assert.h" | ||
| 15 | #include "common/key_map.h" | ||
| 16 | #include "common/logging/log.h" | ||
| 17 | #include "common/scm_rev.h" | ||
| 18 | #include "common/string_util.h" | ||
| 19 | |||
| 20 | #include "video_core/video_core.h" | ||
| 21 | |||
| 22 | #include "core/settings.h" | ||
| 23 | #include "core/hle/service/hid/hid.h" | ||
| 24 | |||
| 25 | #include "citra/emu_window/emu_window_glfw.h" | ||
| 26 | |||
| 27 | EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) { | ||
| 28 | return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win)); | ||
| 29 | } | ||
| 30 | |||
| 31 | void EmuWindow_GLFW::OnMouseButtonEvent(GLFWwindow* win, int button, int action, int mods) { | ||
| 32 | if (button == GLFW_MOUSE_BUTTON_LEFT) { | ||
| 33 | auto emu_window = GetEmuWindow(win); | ||
| 34 | auto layout = emu_window->GetFramebufferLayout(); | ||
| 35 | double x, y; | ||
| 36 | glfwGetCursorPos(win, &x, &y); | ||
| 37 | |||
| 38 | if (action == GLFW_PRESS) | ||
| 39 | emu_window->TouchPressed(static_cast<unsigned>(x), static_cast<unsigned>(y)); | ||
| 40 | else if (action == GLFW_RELEASE) | ||
| 41 | emu_window->TouchReleased(); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* win, double x, double y) { | ||
| 46 | GetEmuWindow(win)->TouchMoved(static_cast<unsigned>(std::max(x, 0.0)), static_cast<unsigned>(std::max(y, 0.0))); | ||
| 47 | } | ||
| 48 | |||
| 49 | /// Called by GLFW when a key event occurs | ||
| 50 | void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) { | ||
| 51 | auto emu_window = GetEmuWindow(win); | ||
| 52 | int keyboard_id = emu_window->keyboard_id; | ||
| 53 | |||
| 54 | if (action == GLFW_PRESS) { | ||
| 55 | emu_window->KeyPressed({key, keyboard_id}); | ||
| 56 | } else if (action == GLFW_RELEASE) { | ||
| 57 | emu_window->KeyReleased({key, keyboard_id}); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | /// Whether the window is still open, and a close request hasn't yet been sent | ||
| 62 | const bool EmuWindow_GLFW::IsOpen() { | ||
| 63 | return glfwWindowShouldClose(m_render_window) == 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) { | ||
| 67 | GetEmuWindow(win)->NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); | ||
| 68 | } | ||
| 69 | |||
| 70 | void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) { | ||
| 71 | // NOTE: GLFW provides no proper way to set a minimal window size. | ||
| 72 | // Hence, we just ignore the corresponding EmuWindow hint. | ||
| 73 | OnFramebufferResizeEvent(win, width, height); | ||
| 74 | } | ||
| 75 | |||
| 76 | /// EmuWindow_GLFW constructor | ||
| 77 | EmuWindow_GLFW::EmuWindow_GLFW() { | ||
| 78 | keyboard_id = KeyMap::NewDeviceId(); | ||
| 79 | |||
| 80 | ReloadSetKeymaps(); | ||
| 81 | |||
| 82 | glfwSetErrorCallback([](int error, const char *desc){ | ||
| 83 | LOG_ERROR(Frontend, "GLFW 0x%08x: %s", error, desc); | ||
| 84 | }); | ||
| 85 | |||
| 86 | // Initialize the window | ||
| 87 | if(glfwInit() != GL_TRUE) { | ||
| 88 | LOG_CRITICAL(Frontend, "Failed to initialize GLFW! Exiting..."); | ||
| 89 | exit(1); | ||
| 90 | } | ||
| 91 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); | ||
| 92 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); | ||
| 93 | // GLFW on OSX requires these window hints to be set to create a 3.2+ GL context. | ||
| 94 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | ||
| 95 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | ||
| 96 | |||
| 97 | std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); | ||
| 98 | m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, | ||
| 99 | (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), | ||
| 100 | window_title.c_str(), nullptr, nullptr); | ||
| 101 | |||
| 102 | if (m_render_window == nullptr) { | ||
| 103 | LOG_CRITICAL(Frontend, "Failed to create GLFW window! Exiting..."); | ||
| 104 | exit(1); | ||
| 105 | } | ||
| 106 | |||
| 107 | glfwSetWindowUserPointer(m_render_window, this); | ||
| 108 | |||
| 109 | // Notify base interface about window state | ||
| 110 | int width, height; | ||
| 111 | glfwGetFramebufferSize(m_render_window, &width, &height); | ||
| 112 | OnFramebufferResizeEvent(m_render_window, width, height); | ||
| 113 | |||
| 114 | glfwGetWindowSize(m_render_window, &width, &height); | ||
| 115 | OnClientAreaResizeEvent(m_render_window, width, height); | ||
| 116 | |||
| 117 | // Setup callbacks | ||
| 118 | glfwSetKeyCallback(m_render_window, OnKeyEvent); | ||
| 119 | glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent); | ||
| 120 | glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent); | ||
| 121 | glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent); | ||
| 122 | glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent); | ||
| 123 | |||
| 124 | DoneCurrent(); | ||
| 125 | } | ||
| 126 | |||
| 127 | /// EmuWindow_GLFW destructor | ||
| 128 | EmuWindow_GLFW::~EmuWindow_GLFW() { | ||
| 129 | glfwTerminate(); | ||
| 130 | } | ||
| 131 | |||
| 132 | /// Swap buffers to display the next frame | ||
| 133 | void EmuWindow_GLFW::SwapBuffers() { | ||
| 134 | glfwSwapBuffers(m_render_window); | ||
| 135 | } | ||
| 136 | |||
| 137 | /// Polls window events | ||
| 138 | void EmuWindow_GLFW::PollEvents() { | ||
| 139 | glfwPollEvents(); | ||
| 140 | } | ||
| 141 | |||
| 142 | /// Makes the GLFW OpenGL context current for the caller thread | ||
| 143 | void EmuWindow_GLFW::MakeCurrent() { | ||
| 144 | glfwMakeContextCurrent(m_render_window); | ||
| 145 | } | ||
| 146 | |||
| 147 | /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread | ||
| 148 | void EmuWindow_GLFW::DoneCurrent() { | ||
| 149 | glfwMakeContextCurrent(nullptr); | ||
| 150 | } | ||
| 151 | |||
| 152 | void EmuWindow_GLFW::ReloadSetKeymaps() { | ||
| 153 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | ||
| 154 | KeyMap::SetKeyMapping({Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id}, Service::HID::pad_mapping[i]); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { | ||
| 159 | std::pair<int,int> current_size; | ||
| 160 | glfwGetWindowSize(m_render_window, ¤t_size.first, ¤t_size.second); | ||
| 161 | |||
| 162 | DEBUG_ASSERT((int)minimal_size.first > 0 && (int)minimal_size.second > 0); | ||
| 163 | int new_width = std::max(current_size.first, (int)minimal_size.first); | ||
| 164 | int new_height = std::max(current_size.second, (int)minimal_size.second); | ||
| 165 | |||
| 166 | if (current_size != std::make_pair(new_width, new_height)) | ||
| 167 | glfwSetWindowSize(m_render_window, new_width, new_height); | ||
| 168 | } | ||
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h deleted file mode 100644 index 7ccd5e6aa..000000000 --- a/src/citra/emu_window/emu_window_glfw.h +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | #include "common/emu_window.h" | ||
| 10 | |||
| 11 | struct GLFWwindow; | ||
| 12 | |||
| 13 | class EmuWindow_GLFW : public EmuWindow { | ||
| 14 | public: | ||
| 15 | EmuWindow_GLFW(); | ||
| 16 | ~EmuWindow_GLFW(); | ||
| 17 | |||
| 18 | /// Swap buffers to display the next frame | ||
| 19 | void SwapBuffers() override; | ||
| 20 | |||
| 21 | /// Polls window events | ||
| 22 | void PollEvents() override; | ||
| 23 | |||
| 24 | /// Makes the graphics context current for the caller thread | ||
| 25 | void MakeCurrent() override; | ||
| 26 | |||
| 27 | /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread | ||
| 28 | void DoneCurrent() override; | ||
| 29 | |||
| 30 | static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods); | ||
| 31 | |||
| 32 | static void OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods); | ||
| 33 | |||
| 34 | static void OnCursorPosEvent(GLFWwindow* window, double x, double y); | ||
| 35 | |||
| 36 | /// Whether the window is still open, and a close request hasn't yet been sent | ||
| 37 | const bool IsOpen(); | ||
| 38 | |||
| 39 | static void OnClientAreaResizeEvent(GLFWwindow* win, int width, int height); | ||
| 40 | |||
| 41 | static void OnFramebufferResizeEvent(GLFWwindow* win, int width, int height); | ||
| 42 | |||
| 43 | void ReloadSetKeymaps() override; | ||
| 44 | |||
| 45 | private: | ||
| 46 | void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override; | ||
| 47 | |||
| 48 | static EmuWindow_GLFW* GetEmuWindow(GLFWwindow* win); | ||
| 49 | |||
| 50 | GLFWwindow* m_render_window; ///< Internal GLFW render window | ||
| 51 | |||
| 52 | /// Device id of keyboard for use with KeyMap | ||
| 53 | int keyboard_id; | ||
| 54 | }; | ||
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp new file mode 100644 index 000000000..1fed82e78 --- /dev/null +++ b/src/citra/emu_window/emu_window_sdl2.cpp | |||
| @@ -0,0 +1,167 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <cstdlib> | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | #define SDL_MAIN_HANDLED | ||
| 10 | #include <SDL.h> | ||
| 11 | |||
| 12 | #include "common/key_map.h" | ||
| 13 | #include "common/logging/log.h" | ||
| 14 | #include "common/scm_rev.h" | ||
| 15 | #include "common/string_util.h" | ||
| 16 | |||
| 17 | #include "core/settings.h" | ||
| 18 | #include "core/hle/service/hid/hid.h" | ||
| 19 | |||
| 20 | #include "citra/emu_window/emu_window_sdl2.h" | ||
| 21 | |||
| 22 | #include "video_core/video_core.h" | ||
| 23 | |||
| 24 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | ||
| 25 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); | ||
| 26 | } | ||
| 27 | |||
| 28 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | ||
| 29 | if (button != SDL_BUTTON_LEFT) | ||
| 30 | return; | ||
| 31 | |||
| 32 | if (state == SDL_PRESSED) { | ||
| 33 | TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); | ||
| 34 | } else { | ||
| 35 | TouchReleased(); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { | ||
| 40 | if (state == SDL_PRESSED) { | ||
| 41 | KeyPressed({ key, keyboard_id }); | ||
| 42 | } else if (state == SDL_RELEASED) { | ||
| 43 | KeyReleased({ key, keyboard_id }); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | bool EmuWindow_SDL2::IsOpen() const { | ||
| 48 | return is_open; | ||
| 49 | } | ||
| 50 | |||
| 51 | void EmuWindow_SDL2::OnResize() { | ||
| 52 | int width, height; | ||
| 53 | |||
| 54 | SDL_GetWindowSize(render_window, &width, &height); | ||
| 55 | |||
| 56 | NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); | ||
| 57 | } | ||
| 58 | |||
| 59 | EmuWindow_SDL2::EmuWindow_SDL2() { | ||
| 60 | keyboard_id = KeyMap::NewDeviceId(); | ||
| 61 | |||
| 62 | ReloadSetKeymaps(); | ||
| 63 | |||
| 64 | SDL_SetMainReady(); | ||
| 65 | |||
| 66 | // Initialize the window | ||
| 67 | if (SDL_Init(SDL_INIT_VIDEO) < 0) { | ||
| 68 | LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); | ||
| 69 | exit(1); | ||
| 70 | } | ||
| 71 | |||
| 72 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); | ||
| 73 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); | ||
| 74 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); | ||
| 75 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); | ||
| 76 | |||
| 77 | std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); | ||
| 78 | render_window = SDL_CreateWindow(window_title.c_str(), | ||
| 79 | SDL_WINDOWPOS_UNDEFINED, // x position | ||
| 80 | SDL_WINDOWPOS_UNDEFINED, // y position | ||
| 81 | VideoCore::kScreenTopWidth, | ||
| 82 | VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight, | ||
| 83 | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); | ||
| 84 | |||
| 85 | if (render_window == nullptr) { | ||
| 86 | LOG_CRITICAL(Frontend, "Failed to create SDL2 window! Exiting..."); | ||
| 87 | exit(1); | ||
| 88 | } | ||
| 89 | |||
| 90 | gl_context = SDL_GL_CreateContext(render_window); | ||
| 91 | |||
| 92 | if (gl_context == nullptr) { | ||
| 93 | LOG_CRITICAL(Frontend, "Failed to create SDL2 GL context! Exiting..."); | ||
| 94 | exit(1); | ||
| 95 | } | ||
| 96 | |||
| 97 | OnResize(); | ||
| 98 | OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); | ||
| 99 | SDL_PumpEvents(); | ||
| 100 | |||
| 101 | DoneCurrent(); | ||
| 102 | } | ||
| 103 | |||
| 104 | EmuWindow_SDL2::~EmuWindow_SDL2() { | ||
| 105 | SDL_GL_DeleteContext(gl_context); | ||
| 106 | SDL_Quit(); | ||
| 107 | } | ||
| 108 | |||
| 109 | void EmuWindow_SDL2::SwapBuffers() { | ||
| 110 | SDL_GL_SwapWindow(render_window); | ||
| 111 | } | ||
| 112 | |||
| 113 | void EmuWindow_SDL2::PollEvents() { | ||
| 114 | SDL_Event event; | ||
| 115 | |||
| 116 | // SDL_PollEvent returns 0 when there are no more events in the event queue | ||
| 117 | while (SDL_PollEvent(&event)) { | ||
| 118 | switch (event.type) { | ||
| 119 | case SDL_WINDOWEVENT: | ||
| 120 | switch (event.window.event) { | ||
| 121 | case SDL_WINDOWEVENT_SIZE_CHANGED: | ||
| 122 | case SDL_WINDOWEVENT_RESIZED: | ||
| 123 | case SDL_WINDOWEVENT_MAXIMIZED: | ||
| 124 | case SDL_WINDOWEVENT_RESTORED: | ||
| 125 | case SDL_WINDOWEVENT_MINIMIZED: | ||
| 126 | OnResize(); | ||
| 127 | break; | ||
| 128 | case SDL_WINDOWEVENT_CLOSE: | ||
| 129 | is_open = false; | ||
| 130 | break; | ||
| 131 | } | ||
| 132 | break; | ||
| 133 | case SDL_KEYDOWN: | ||
| 134 | case SDL_KEYUP: | ||
| 135 | OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state); | ||
| 136 | break; | ||
| 137 | case SDL_MOUSEMOTION: | ||
| 138 | OnMouseMotion(event.motion.x, event.motion.y); | ||
| 139 | break; | ||
| 140 | case SDL_MOUSEBUTTONDOWN: | ||
| 141 | case SDL_MOUSEBUTTONUP: | ||
| 142 | OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y); | ||
| 143 | break; | ||
| 144 | case SDL_QUIT: | ||
| 145 | is_open = false; | ||
| 146 | break; | ||
| 147 | } | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | void EmuWindow_SDL2::MakeCurrent() { | ||
| 152 | SDL_GL_MakeCurrent(render_window, gl_context); | ||
| 153 | } | ||
| 154 | |||
| 155 | void EmuWindow_SDL2::DoneCurrent() { | ||
| 156 | SDL_GL_MakeCurrent(render_window, nullptr); | ||
| 157 | } | ||
| 158 | |||
| 159 | void EmuWindow_SDL2::ReloadSetKeymaps() { | ||
| 160 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | ||
| 161 | KeyMap::SetKeyMapping({ Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id }, Service::HID::pad_mapping[i]); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) { | ||
| 166 | SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); | ||
| 167 | } | ||
diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h new file mode 100644 index 000000000..77279f022 --- /dev/null +++ b/src/citra/emu_window/emu_window_sdl2.h | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | #include "common/emu_window.h" | ||
| 10 | |||
| 11 | struct SDL_Window; | ||
| 12 | |||
| 13 | class EmuWindow_SDL2 : public EmuWindow { | ||
| 14 | public: | ||
| 15 | EmuWindow_SDL2(); | ||
| 16 | ~EmuWindow_SDL2(); | ||
| 17 | |||
| 18 | /// Swap buffers to display the next frame | ||
| 19 | void SwapBuffers() override; | ||
| 20 | |||
| 21 | /// Polls window events | ||
| 22 | void PollEvents() override; | ||
| 23 | |||
| 24 | /// Makes the graphics context current for the caller thread | ||
| 25 | void MakeCurrent() override; | ||
| 26 | |||
| 27 | /// Releases the GL context from the caller thread | ||
| 28 | void DoneCurrent() override; | ||
| 29 | |||
| 30 | /// Whether the window is still open, and a close request hasn't yet been sent | ||
| 31 | bool IsOpen() const; | ||
| 32 | |||
| 33 | /// Load keymap from configuration | ||
| 34 | void ReloadSetKeymaps() override; | ||
| 35 | |||
| 36 | private: | ||
| 37 | /// Called by PollEvents when a key is pressed or released. | ||
| 38 | void OnKeyEvent(int key, u8 state); | ||
| 39 | |||
| 40 | /// Called by PollEvents when the mouse moves. | ||
| 41 | void OnMouseMotion(s32 x, s32 y); | ||
| 42 | |||
| 43 | /// Called by PollEvents when a mouse button is pressed or released | ||
| 44 | void OnMouseButton(u32 button, u8 state, s32 x, s32 y); | ||
| 45 | |||
| 46 | /// Called by PollEvents when any event that may cause the window to be resized occurs | ||
| 47 | void OnResize(); | ||
| 48 | |||
| 49 | /// Called when a configuration change affects the minimal size of the window | ||
| 50 | void OnMinimalClientAreaChangeRequest(const std::pair<unsigned, unsigned>& minimal_size) override; | ||
| 51 | |||
| 52 | /// Is the window still open? | ||
| 53 | bool is_open = true; | ||
| 54 | |||
| 55 | /// Internal SDL2 render window | ||
| 56 | SDL_Window* render_window; | ||
| 57 | |||
| 58 | using SDL_GLContext = void *; | ||
| 59 | /// The OpenGL context associated with the window | ||
| 60 | SDL_GLContext gl_context; | ||
| 61 | |||
| 62 | /// Device id of keyboard for use with KeyMap | ||
| 63 | int keyboard_id; | ||
| 64 | }; | ||