I'm developing a game using an engine called Gameplay 3D on Ubuntu and while trying to use the engine's "captureMouse" function I learned that this particular function has not yet been defined for the linux distro. I've already told them about my need for this function to be defined, but luckily the engine is open source; so for quite a few hours now I've been trying to get the cursor to lock in the center of the screen.
This is what I've been able to do so far:
- using this function
XWarpPointer(__display, None, __window, 0, 0, 0, 0, getDisplayWidth()/2, getDisplayHeight/2);
I've been able to move the cursor onto the center of the window, but if I move the mouse the cursor will leave the center. This seemed like a step in the right directing so I kept looking for another function for actually locked the cursor in place
- using this code:
/* vars to make blank cursor */
Pixmap blank;
XColor dummy;
char data[1] = {0};
Cursor cursor;
/* make a blank cursor */
blank = XCreateBitmapFromData (dpy, win, data, 1, 1);
if(blank == None) fprintf(stderr, "error: out of memory.\n");
cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);
XFreePixmap (dpy, blank);
Con_Printf("Cursor blanked.\n")
found here: Link; I was able to make an invisible with the help of this function:
XGrabPointer(__display, __window, true, 0, GrabModeAsync, GrabModeASnyc, __window, cursor, CurrentTime)
Unfortunatly the XGrabPointer function didn't lock the pointer in place. Instead it just disabled the cursor from leaving the window, ei.: the cursor wouldn't move past the edges of the window.
So right now I have an invisible cursor, confined to the application window, that jumps the center (of the window) when I run the program. My question: How do I lock the cursor in place (at the center)?






