开发者

XLib Lock Mouse position (Mouse wrap)

I am trying to create a a mouse wrap within X11 for openGL games/content. The approach I was trying to take is to hide the cursor (which I can do just fine), lock the mouse position in the center of the window and then use the mouse delta positions to detect movement. I cannot find any way however to lock the mouse position other then to keep moving it back to the center every frame.

In windows this can be done with ClipCursor() and in OSX mouse wrap can be done using CGWarpMouseCurs开发者_如何学运维orPosition. Does anything similar exist within the XLib libraries?


libSDL does almost exactly that and the source code of this might be a good starting point for your own implementation. Alternatively if the goal is cross-platform fullscreen application then just using SDL directly might save you reinventing the wheel here.

The file in question for X11 seems to be src/video/x11/SDL_x11mouse.c, in particular the implementation of X11_WarpWMCursor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜