Skip to content

Commit

Permalink
Added a remove key to the window interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirul committed Feb 17, 2024
1 parent 91479ba commit 7355ff6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/frame/window_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ struct WindowInterface
*/
virtual void AddKeyCallback(
std::int32_t key, std::function<bool()> 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...).
Expand Down
4 changes: 4 additions & 0 deletions src/frame/opengl/sdl_opengl_none.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeviceInterface>&& device) override
{
device_ = std::move(device);
Expand Down
4 changes: 4 additions & 0 deletions src/frame/opengl/sdl_opengl_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeviceInterface>&& device) override
{
device_ = std::move(device);
Expand Down
4 changes: 4 additions & 0 deletions src/frame/vulkan/sdl_vulkan_none.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeviceInterface>&& device) override
{
device_ = std::move(device);
Expand Down
4 changes: 4 additions & 0 deletions src/frame/vulkan/sdl_vulkan_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DeviceInterface>&& device) override
{
device_ = std::move(device);
Expand Down

0 comments on commit 7355ff6

Please sign in to comment.