From 7355ff6d8061677aa44a862cb72a9592abec95a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Dubouchet?= Date: Sat, 17 Feb 2024 11:14:19 +0100 Subject: [PATCH] Added a remove key to the window interface. --- include/frame/window_interface.h | 5 +++++ src/frame/opengl/sdl_opengl_none.h | 4 ++++ src/frame/opengl/sdl_opengl_window.h | 4 ++++ src/frame/vulkan/sdl_vulkan_none.h | 4 ++++ src/frame/vulkan/sdl_vulkan_window.h | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/include/frame/window_interface.h b/include/frame/window_interface.h index 77b836d..c4337f6 100644 --- a/include/frame/window_interface.h +++ b/include/frame/window_interface.h @@ -38,6 +38,11 @@ struct WindowInterface */ virtual void AddKeyCallback( std::int32_t key, std::function func) = 0; + /** + * @brief Remove a callback to a key. + * @param key: The key to remove the callback from. + */ + virtual void RemoveKeyCallback(std::int32_t key) = 0; /** * @brief Set the unique device (this is suppose to be variable to the * one you are using see : DirectX, OpenGL, etc...). diff --git a/src/frame/opengl/sdl_opengl_none.h b/src/frame/opengl/sdl_opengl_none.h index 0c125c2..b014543 100644 --- a/src/frame/opengl/sdl_opengl_none.h +++ b/src/frame/opengl/sdl_opengl_none.h @@ -35,6 +35,10 @@ class SDLOpenGLNone : public WindowInterface { throw std::runtime_error("Not implemented."); } + void RemoveKeyCallback(std::int32_t key) override + { + throw std::runtime_error("Not implemented."); + } void SetUniqueDevice(std::unique_ptr&& device) override { device_ = std::move(device); diff --git a/src/frame/opengl/sdl_opengl_window.h b/src/frame/opengl/sdl_opengl_window.h index 67eeafd..73d2d1f 100644 --- a/src/frame/opengl/sdl_opengl_window.h +++ b/src/frame/opengl/sdl_opengl_window.h @@ -31,6 +31,10 @@ class SDLOpenGLWindow : public WindowInterface { key_callbacks_.insert({key, func}); } + void RemoveKeyCallback(std::int32_t key) override + { + key_callbacks_.erase(key); + } void SetUniqueDevice(std::unique_ptr&& device) override { device_ = std::move(device); diff --git a/src/frame/vulkan/sdl_vulkan_none.h b/src/frame/vulkan/sdl_vulkan_none.h index ebf8fa0..ff32244 100644 --- a/src/frame/vulkan/sdl_vulkan_none.h +++ b/src/frame/vulkan/sdl_vulkan_none.h @@ -36,6 +36,10 @@ class SDLVulkanNone : public WindowInterface { throw std::runtime_error("Not implemented yet!"); } + void RemoveKeyCallback(std::int32_t key) override + { + throw std::runtime_error("Not implemented yet!"); + } void SetUniqueDevice(std::unique_ptr&& device) override { device_ = std::move(device); diff --git a/src/frame/vulkan/sdl_vulkan_window.h b/src/frame/vulkan/sdl_vulkan_window.h index 2596dc3..a689e65 100644 --- a/src/frame/vulkan/sdl_vulkan_window.h +++ b/src/frame/vulkan/sdl_vulkan_window.h @@ -32,6 +32,10 @@ class SDLVulkanWindow : public WindowInterface { throw std::runtime_error("Not implemented yet!"); } + void RemoveKeyCallback(std::int32_t key) override + { + throw std::runtime_error("Not implemented yet!"); + } void SetUniqueDevice(std::unique_ptr&& device) override { device_ = std::move(device);