mattiasgustavsson / dos-like

Engine for making things with a MS-DOS feel, but for modern platforms
Other
1k stars 49 forks source link

Fully capture mouse cursor #33

Open Kapouett opened 2 years ago

Kapouett commented 2 years ago

Preventing the cursor from escaping the window is necessary for any program featuring some form of mouse look.

mattiasgustavsson commented 2 years ago

If you have any ideas how to do it, I would welcome suggestions :)

Softwave commented 1 year ago

This can be done in the SDL side of things in app.h by just adding:

SDL_SetRelativeMouseMode(SDL_TRUE);

on app opening, and:

SDL_SetRelativeMouseMode(SDL_FALSE);

on closing or whenever else you want to release the mouse.

Windows you can use the ClipCursor function. I'd show more but I'm not a Windows PC.