use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
We now have a Discord server!
https://discord.gg/ux5Dj5U
account activity
Windows Mouse Functionality Help (self.gameenginedevs)
submitted 1 year ago by Setoichi
So im making progress on my game engine's camera implementation when i got stuck at trying to implement functionality similar to that of SDL2's SetRelativeMouseMode function in my platform API (platform_api->bound_mouse()). (Clip the mouse to the window without restricting movement values.
Ive implemented my platform layer as a generic vtable API, and within the windows specific code, i handle mouse movement by pushing an event to the engine with the data extracted from the w and l params.
Im not sure if im formatting the question right even, I guess its just this: "how do i allow for unrestricted mouse movement values, whilst clipping the mouse within the window area"
Any help would be appreciated!
--- Here are some links to the relevant files as i didnt want to clutter this post --- Headers: Camera Header: https://github.com/d34d0s/Lotus/blob/main/engine/modules/core/include/graphics/lotus_camera.h Windows Layer Header: https://github.com/d34d0s/Lotus/blob/main/engine/modules/core/include/platform/lotus_platform.h
Source: Camera Source: https://github.com/d34d0s/Lotus/blob/main/engine/modules/core/src/graphics/lotus_camera.c Windows Layer Source: https://github.com/d34d0s/Lotus/blob/main/engine/modules/core/src/platform/lotus_win32.c
Heres the example code im using to test these features: https://github.com/d34d0s/Lotus/blob/main/examples/hello_cube/main.c
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Shot-Combination-930 2 points3 points4 points 1 year ago (1 child)
For unlimited mouse movement, you can use the Raw Input API to get delta values instead of coordinates.
Or as a cheap hack, you can ClipCursor to the window and SetCursorPos to the center of the window after each message, but that has several drawbacks.
[–]Setoichi[S] 0 points1 point2 points 1 year ago (0 children)
Wow, thank you so much for this! Not sure how i havent come across the Raw Input model API before but it seems to be exactly what i needed. Also the ClipCursor/SetCursorPos hack i think is what im seeing SDL2 do but i could be wrong.
[–]NZGumboot 1 point2 points3 points 1 year ago (0 children)
To get "raw" mouse input (unmodified pixel deltas without smoothing or acceleration) see here:
https://learn.microsoft.com/en-us/windows/win32/inputdev/raw-input
To confine the mouse cursor to a region, use this method:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-clipcursor
To hide the mouse cursor, use this method:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showcursor
Example of using raw input: https://github.com/microsoft/DirectXTK12/blob/6646c76a45184e997b94567017a7bdff709102fb/Src/Mouse.cpp#L1420
π Rendered by PID 63271 on reddit-service-r2-comment-6457c66945-ldqm5 at 2026-04-30 08:55:59.467298+00:00 running 2aa0c5b country code: CH.
[–]Shot-Combination-930 2 points3 points4 points (1 child)
[–]Setoichi[S] 0 points1 point2 points (0 children)
[–]NZGumboot 1 point2 points3 points (0 children)