How do I lock the cursor to the window?

Something like you’d see in a first person game. I’ve already figured out how to hide the cursor, but there doesn’t seem to be any function or variable with a name suggesting it would lock the cursor and I can’t find anything online. Thanks.

Hi @AeroSoap ! Welcome to the forum :slight_smile:

I haven’t played FPS games in a long time so I don’t know how the mouse works there. Could you describe the desired behavior?

import org.openrndr.application

fun main() = application {
    configure {
        hideCursor = true
    program {
        extend {
  , 20.0)

With this program the mouse pointer would be a circle, and it gets locked to the window area. But maybe you want something different?

Hi abe, thanks for the reply. I did end up finding a different control scheme that worked for my use case, but for the sake of the public repository of information: In a first person game, the mouse is hidden and typically doesn’t act as a cursor while the player is looking around. Input hooks will capture relative mouse motion and use that to rotate the camera. What the mouse actually does doesn’t really matter as long as it doesn’t interfere with the aforementioned input or leave the window.

Some behavior I’ve seen in the past includes the mouse jumping back to the center or other side of the window when you reach the edge or it simply hitting the edge like a wall and not being able to get out. This isn’t something you typically observe directly, but the end result would be, for example, being able to continue moving your mouse in one direction indefinitely and the player’s camera rotating in that direction without the mouse escaping the window.

ETA hideCursor doesn’t seem to lock the mouse to the window on my system.

Ah I see! Yeah now I remember :slight_smile:

OPENRNDR uses LWJGL which uses GLFW. There I see raw mouse motion GLFW: Input guide

I’ll try to find out if it’s possible to obtain that raw data.

It’s been a few months. Does anyone know a solution?

Hi! I asked in Slack and Edwin said

There used to be cursorHideMode = MouseCursorHideMode.DISABLE for that but I have never used it and I am not sure if it still works

Might that work?