From 17a238ad8fe52cf8fbf6bf99ad7cc59043ba14dc Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 19 Oct 2025 20:38:37 +0200 Subject: [PATCH] Implement glfwGetKey for a future plugin Signed-off-by: falkTX --- src/custom/glfw.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/custom/glfw.cpp b/src/custom/glfw.cpp index b9c72b9..f069ac2 100644 --- a/src/custom/glfw.cpp +++ b/src/custom/glfw.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2024 Filipe Coelho + * Copyright (C) 2021-2025 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,6 +17,7 @@ #include "Application.hpp" #include "CardinalPluginContext.hpp" +#include "widget/event.hpp" #include @@ -207,3 +208,12 @@ GLFWAPI const char* glfwGetKeyName(const int key, int) default: return nullptr; } } + +int glfwGetKey(GLFWwindow*, const int key) +{ + CardinalPluginContext* const context = static_cast(APP); + DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, GLFW_RELEASE); + DISTRHO_SAFE_ASSERT_RETURN(context->event != nullptr, GLFW_RELEASE); + + return context->event->heldKeys.find(key) != context->event->heldKeys.end() ? GLFW_PRESS : GLFW_RELEASE; +}