MCPcopy Create free account
hub / github.com/VCVRack/Rack / cursorLock

Method cursorLock

src/window/Window.cpp:644–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642
643
644void Window::cursorLock() {
645 if (!settings::allowCursorLock)
646 return;
647 if (internal->cursorLocked)
648 return;
649
650 // GLFW_CURSOR_DISABLED is buggy.
651 // https://github.com/glfw/glfw/issues/2523
652 // So instead, hide the cursor, move cursor to center of window, and reset mouse position every frame in cursorPosCallback().
653 glfwGetCursorPos(win, &internal->cursorLockedPosX, &internal->cursorLockedPosY);
654 internal->cursorLocked = true;
655 glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
656
657 int width, height;
658 glfwGetWindowSize(win, &width, &height);
659 glfwSetCursorPos(win, width / 2, height / 2);
660}
661
662
663void Window::cursorUnlock() {

Callers 2

onDragStartMethod · 0.80
onDragStartMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected