Browse Source

Implement glfwGetKey for a future plugin

Signed-off-by: falkTX <falktx@falktx.com>
tags/26.01
falkTX 3 months ago
parent
commit
17a238ad8f
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      src/custom/glfw.cpp

+ 11
- 1
src/custom/glfw.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Cardinal Plugin * DISTRHO Cardinal Plugin
* Copyright (C) 2021-2024 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2025 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -17,6 +17,7 @@


#include "Application.hpp" #include "Application.hpp"
#include "CardinalPluginContext.hpp" #include "CardinalPluginContext.hpp"
#include "widget/event.hpp"


#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>


@@ -207,3 +208,12 @@ GLFWAPI const char* glfwGetKeyName(const int key, int)
default: return nullptr; default: return nullptr;
} }
} }

int glfwGetKey(GLFWwindow*, const int key)
{
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(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;
}

Loading…
Cancel
Save