There's been several discussions here recently about _MouseMovementX and _MouseMovementY, and how they don't work 100% as expected in Linux and Mac. Unfortunately, the problem here is an underlying issue with glut itself not reporting that relative movement back to us.
The only real solution at the moment is for one to write their own routine to handle this type of situation, so I thought I'd take a few minutes and write up a quick example of how to do that for someone:
Test that out and see if it doesn't keep track of the current mouse position, while also allowing for mouse movement to take place regardless of the edge of the screen.
Feel free to ask/add any questions, comments, or insights into the process here, but I'm thinking this should work on all OSes without any issues. (As long as _MouseHide works on all OSes... I didn't think to check to see if it does or doesn't, to be honest.)
The only real solution at the moment is for one to write their own routine to handle this type of situation, so I thought I'd take a few minutes and write up a quick example of how to do that for someone:
Code: (Select All)
DIM SHARED AS LONG MouseMoveX, MouseMoveY, MouseX, MouseY
SCREEN _NEWIMAGE(800, 600, 32)
_SCREENMOVE _MIDDLE
DO
CLS
Mouse
TMMX = TMMX + MouseMoveX: TMMY = TMMY + MouseMoveY
PRINT "Mouse x:"; MouseX
PRINT "Mouse y:"; MouseY
PRINT "MouseMoveX:"; MouseMoveX
PRINT "MouseMoveY:"; MouseMoveY
PRINT "Total MouseMoveX:"; TMMX
PRINT "TOtal MouseMoveY:"; TMMY
_LIMIT 30
_DISPLAY
LOOP UNTIL _MOUSEBUTTON(2)
SYSTEM
SUB Mouse
STATIC AS LONG CurrentX, CurrentY
STATIC AS LONG Pointer 'We need a pointer of some sort for a manual pointer. Here's a cheesy one by default.
STATIC AS INTEGER Init
WHILE _MOUSEINPUT: WEND 'catch up to the current mouse's position so we sync properly
X = _MOUSEX: Y = _MOUSEY
MouseMoveX = 0: MouseMoveY = 0
IF Init = 0 THEN
Init = -1
CurrentX = _WIDTH \ 2: CurrentY = _HEIGHT \ 2
_MOUSEHIDE
_MOUSEMOVE _WIDTH \ 2, _HEIGHT \ 2
Pointer = _NEWIMAGE(16, 8, 32)
COLOR -1, 0
_PRINTSTRING (0, 0), CHR$(24), Pointer
ELSE
IF X <> _WIDTH \ 2 OR Y <> _HEIGHT \ 2 THEN
MouseMoveX = X - _WIDTH \ 2: MouseMoveY = Y - _HEIGHT \ 2
CurrentX = CurrentX + MouseMoveX
CurrentY = CurrentY + MouseMoveY
IF CurrentX < 0 THEN CurrentX = 0
IF CurrentX >= _WIDTH THEN CurrentX = _WIDTH - 1
IF CurrentY < 0 THEN CurrentY = 0
IF CurrentY >= _HEIGHT THEN CurrentY = _HEIGHT - 1
END IF
END IF
_PUTIMAGE (CurrentX - 8, CurrentY - 8)-STEP(32, 32), Pointer
_MOUSEMOVE _WIDTH / 2, _HEIGHT / 2
MouseX = CurrentX: MouseY = CurrentY
END SUB
Test that out and see if it doesn't keep track of the current mouse position, while also allowing for mouse movement to take place regardless of the edge of the screen.
Feel free to ask/add any questions, comments, or insights into the process here, but I'm thinking this should work on all OSes without any issues. (As long as _MouseHide works on all OSes... I didn't think to check to see if it does or doesn't, to be honest.)