Mouse Bug (OSX) (As of Beta 3)
by Kodafox · in Torque Game Builder · 04/19/2006 (5:57 pm) · 4 replies
I'm not positive but I think I'd call this a bug.
I'm using a function to rotate a sprite where the mouse starts at (0, 0) every time the mouse is moved I get the new x value and rotate the sprite by that number times a speed modifier. Then I reposition the mouse to (0,0). The problem I'm having is that even though I always set the mouse to the origin only torque's version of the mouse stays there. In other words the system cursor is free to move outside of the window. This causes a problem for my rotation function because as soon as the mouse leaves my window I can't get a new x pos to use for rotating my sprite. I tried this in full screen mode as well. I have the same problem there when the system cursor hits the edge of the screen.
Edit: I noticed this has to do with a setMousePosition bug where when SetMousePosition() is called it moves the cursor to that position but as soon as the mouse is moved it jumps back to it's old location. Has anyone made a fix for this problem that works in OS X?
I'm using a function to rotate a sprite where the mouse starts at (0, 0) every time the mouse is moved I get the new x value and rotate the sprite by that number times a speed modifier. Then I reposition the mouse to (0,0). The problem I'm having is that even though I always set the mouse to the origin only torque's version of the mouse stays there. In other words the system cursor is free to move outside of the window. This causes a problem for my rotation function because as soon as the mouse leaves my window I can't get a new x pos to use for rotating my sprite. I tried this in full screen mode as well. I have the same problem there when the system cursor hits the edge of the screen.
Edit: I noticed this has to do with a setMousePosition bug where when SetMousePosition() is called it moves the cursor to that position but as soon as the mouse is moved it jumps back to it's old location. Has anyone made a fix for this problem that works in OS X?
function StrafeSceneWindow2D::onMouseMove( %this, %mod, %worldPos, %mouseClicks )
{
%speedMod = 1;
%this.rotation = getword(%worldPos, 0);
echo("this.rotation"SPC %this.rotation);
StrafeSceneWindow2D.setMousePosition("0 0");
playerShip.setRotation(playerShip.getRotation() + (%this.rotation * %speedMod));
}
#2
05/15/2006 (4:35 pm)
I'm hoping this doesn't get overlooked for the final release of TGB, because according to the posts I've found on the forum this problem has been around for a very very long time. I wish I had the Mac programming skills to fix it myself but I looked at the code and I couldn't come up with a fix with my limited knowledge. Is the GG team aware of this bug and is it on somebody's to-do list somewhere? It may not seem like such an important feature to some people but if it's not fixed it rules out a control scheme that could make for some interesting games. Also moving the mouse to a specific location is a nice method of suggesting to the user which button to press etc. But if this feature doesn't work It's going to make the game look cheaply designed if the mouse jumps across the screen after being set to a specific location.
#3
For the Mac, it shouldn't be hard to modify things so that setCursorPos() called CGWarpMouseCursorPosition(), but I have no idea about Windows and Linux.
But be very, very, very careful. Moving the cursor yourself seems to be one of the most heinous things you can do on a Mac, at least judging by the many debates I've seen over the years amongst developers. Personally, I can see possible reasons for moving the cursor yourself, but just be warned that you run the risk of annoying (many?) people by doing so.
05/20/2006 (1:32 pm)
Digging around in the code for Beta 2, it doesn't look like SetMousePosition() is intended to move the system mouse cursor at all, Mac or otherwise. All it does is set the canvas cursor position with setCursorPos(). I haven't looked at beta 3 yet.For the Mac, it shouldn't be hard to modify things so that setCursorPos() called CGWarpMouseCursorPosition(), but I have no idea about Windows and Linux.
But be very, very, very careful. Moving the cursor yourself seems to be one of the most heinous things you can do on a Mac, at least judging by the many debates I've seen over the years amongst developers. Personally, I can see possible reasons for moving the cursor yourself, but just be warned that you run the risk of annoying (many?) people by doing so.
#4
I undestand that all that setMousePosition() does is move the canvas cursor but because the cursor always snaps to where the system cursor is this doesn't even work. For example say the user is in the middle of moving the cursor somewhere near the top left corner of the screen. if you call setMousePosition() to somewhere around the bottom right corner, for one instant the canvas cursor will be in the bottom right and the system cursor in the top left where the user was moving it. However since the user was moving the mouse at the time the canvas cursor will snap back to the system cursor (upper left) before the user even knows it moved.
I agree moving the cursor around without asking can be a real annoyance to users. But what I actually want to do with the cursor is recenter it every frame so that I can measure the mouse movement for a specific control scheme. Since doing this would capitalize the mouse I would release the mouse when the game was paused or closed. I can see why this bug isn't getting much attention as it's not that common to want to move the cursor around programatically but I think this is a legit reason and if the function is going to remain as part of TGB I think it ought to be fixed.
Thanks for reading :)
Jake
05/21/2006 (8:39 am)
Thanks for your reply.I undestand that all that setMousePosition() does is move the canvas cursor but because the cursor always snaps to where the system cursor is this doesn't even work. For example say the user is in the middle of moving the cursor somewhere near the top left corner of the screen. if you call setMousePosition() to somewhere around the bottom right corner, for one instant the canvas cursor will be in the bottom right and the system cursor in the top left where the user was moving it. However since the user was moving the mouse at the time the canvas cursor will snap back to the system cursor (upper left) before the user even knows it moved.
I agree moving the cursor around without asking can be a real annoyance to users. But what I actually want to do with the cursor is recenter it every frame so that I can measure the mouse movement for a specific control scheme. Since doing this would capitalize the mouse I would release the mouse when the game was paused or closed. I can see why this bug isn't getting much attention as it's not that common to want to move the cursor around programatically but I think this is a legit reason and if the function is going to remain as part of TGB I think it ought to be fixed.
Thanks for reading :)
Jake
Torque Owner Kodafox
I know the Mac specific beta 3 build isn't out yet so maybe there is chance of this getting fixed by then. I just compiled Beta 3 on the Mac (from the windows release) and it seems to work fine but this bug is still occuring. The setMousePosition(); still only moves the cursor temporarily before it jumps back to where it was before the call. It will stay to where you move it until you move the mouse, then it jumps.
I really need this function to work properly for a control scheme that I am trying to implement. but until then I'll wait and work on another project ;)