Left mouse button causes moueup event despite button still being pressed.
Hello everyone 
I am working on mouse input for a game, I am having trouble with the left mouse button, the right button works perfectly.
I am using GLUT.
Here is my mouse event handling code.
I am using integers to keep track of the mouse button states. when the mouse button is released, this is represented by a continually decreasing negative value in iMouseLeftButton and iMouseRightButton.
When the button is depressed, it is represented by a continually increasing positive value.
The right mouse button portion works perfectly, but the left mouse button not so well.
When I press the left button, the code works fine for one cycle, after that it thinks that the left button has been released, even though i am still holding it.
I have tried switching the code around, substituting GL_LEFT_BUTTON with GL_RIGHT_BUTTON, just to see if I had written it incorrectly. GL_RIGHT_BUTTON works perfectly.
Any ideas?
Thanks in advance. : )

I am working on mouse input for a game, I am having trouble with the left mouse button, the right button works perfectly.
I am using GLUT.
Here is my mouse event handling code.
I am using integers to keep track of the mouse button states. when the mouse button is released, this is represented by a continually decreasing negative value in iMouseLeftButton and iMouseRightButton.
When the button is depressed, it is represented by a continually increasing positive value.
Code:
void HandleMousePress (int button, int state, int x, int y)
{
if ( button == GLUT_LEFT_BUTTON )
{
if ( state == GLUT_DOWN )
{
if ( iMouseLeftButton < 0 )
{
iMouseLeftButton = 1;
}
}
else if ( state == GLUT_UP )
{
if ( iMouseLeftButton > 0 )
{
iMouseLeftButton = -1;
}
}
}
else if ( button == GLUT_RIGHT_BUTTON )
{
if ( state == GLUT_DOWN )
{
if ( iMouseRightButton < 0 )
{
iMouseRightButton = 1;
}
}
else if ( state == GLUT_UP )
{
if ( iMouseRightButton > 0 )
{
iMouseRightButton = -1;
}
}
}
}The right mouse button portion works perfectly, but the left mouse button not so well.
When I press the left button, the code works fine for one cycle, after that it thinks that the left button has been released, even though i am still holding it.
I have tried switching the code around, substituting GL_LEFT_BUTTON with GL_RIGHT_BUTTON, just to see if I had written it incorrectly. GL_RIGHT_BUTTON works perfectly.
Any ideas?
Thanks in advance. : )
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| customize an action of iphone home button to submit score in gamecenter | sefiroths | 7 | 6,017 |
Nov 30, 2011 01:59 AM Last Post: sefiroths |
|
| only one error left! Please help... | Kingbry | 10 | 4,508 |
Sep 11, 2007 01:38 AM Last Post: OneSadCookie |
|
| Mouse button enabler, like GamePad Companion | setera | 4 | 3,882 |
Apr 30, 2006 06:32 PM Last Post: setera |
|
| Event Handling (Keyboard and Mouse) | bwalters | 6 | 6,622 |
Mar 12, 2006 08:17 PM Last Post: OneSadCookie |
|
| Configurable keys - describe key that was pressed | MattDiamond | 13 | 6,547 |
Oct 27, 2003 11:23 PM Last Post: OneSadCookie |
|

