Function mouseButtonCallback

Synopsis

#include <Source/Falcor/Core/Window.cpp>

static void mouseButtonCallback(GLFWwindow *pGlfwWindow, int button, int action, int modifiers)

Description

No description yet.

Source

Lines 114-145 in Source/Falcor/Core/Window.cpp.

static void mouseButtonCallback(GLFWwindow* pGlfwWindow, int button, int action, int modifiers)
{
    MouseEvent event;
    // Prepare the mouse data
    switch (button)
    {
    case GLFW_MOUSE_BUTTON_LEFT:
        event.type = (action == GLFW_PRESS) ? MouseEvent::Type::LeftButtonDown : MouseEvent::Type::LeftButtonUp;
        break;
    case GLFW_MOUSE_BUTTON_MIDDLE:
        event.type = (action == GLFW_PRESS) ? MouseEvent::Type::MiddleButtonDown : MouseEvent::Type::MiddleButtonUp;
        break;
    case GLFW_MOUSE_BUTTON_RIGHT:
        event.type = (action == GLFW_PRESS) ? MouseEvent::Type::RightButtonDown : MouseEvent::Type::RightButtonUp;
        break;
    default:
        // Other keys are not supported
        break;
    }
    Window* pWindow = (Window*)glfwGetWindowUserPointer(pGlfwWindow);
    if (pWindow != nullptr)
    {
        // Modifiers
        event.mods = getInputModifiers(modifiers);
        double x, y;
        glfwGetCursorPos(pGlfwWindow, &x, &y);
        event.pos = calcMousePos(x, y, pWindow->getMouseScale());
        pWindow->mpCallbacks->handleMouseEvent(event);
    }
}





Add Discussion as Guest

Log in to DocsForge