Date: Sun, 18 Jul 2004 00:22:07 -0400
From: "Philippe Anctil" Subject: [SDL] odd mouse event generated on init The mouse relative and absolute coordinates appear to be always equal for the first mouse event. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40944
This commit is contained in:
parent
2c65409ade
commit
ddbdb49e06
1 changed files with 19 additions and 9 deletions
|
@ -38,8 +38,8 @@ static char rcsid =
|
||||||
|
|
||||||
|
|
||||||
/* These are static for our mouse handling code */
|
/* These are static for our mouse handling code */
|
||||||
static Sint16 SDL_MouseX = 0;
|
static Sint16 SDL_MouseX = -1;
|
||||||
static Sint16 SDL_MouseY = 0;
|
static Sint16 SDL_MouseY = -1;
|
||||||
static Sint16 SDL_DeltaX = 0;
|
static Sint16 SDL_DeltaX = 0;
|
||||||
static Sint16 SDL_DeltaY = 0;
|
static Sint16 SDL_DeltaY = 0;
|
||||||
static Uint8 SDL_ButtonState = 0;
|
static Uint8 SDL_ButtonState = 0;
|
||||||
|
@ -49,8 +49,8 @@ static Uint8 SDL_ButtonState = 0;
|
||||||
int SDL_MouseInit(void)
|
int SDL_MouseInit(void)
|
||||||
{
|
{
|
||||||
/* The mouse is at (0,0) */
|
/* The mouse is at (0,0) */
|
||||||
SDL_MouseX = 0;
|
SDL_MouseX = -1;
|
||||||
SDL_MouseY = 0;
|
SDL_MouseY = -1;
|
||||||
SDL_DeltaX = 0;
|
SDL_DeltaX = 0;
|
||||||
SDL_DeltaY = 0;
|
SDL_DeltaY = 0;
|
||||||
SDL_ButtonState = 0;
|
SDL_ButtonState = 0;
|
||||||
|
@ -72,10 +72,20 @@ void SDL_ResetMouse(void)
|
||||||
|
|
||||||
Uint8 SDL_GetMouseState (int *x, int *y)
|
Uint8 SDL_GetMouseState (int *x, int *y)
|
||||||
{
|
{
|
||||||
if ( x )
|
if ( x ) {
|
||||||
|
if ( SDL_MouseX < 0 ) {
|
||||||
|
*x = 0;
|
||||||
|
} else {
|
||||||
*x = SDL_MouseX;
|
*x = SDL_MouseX;
|
||||||
if ( y )
|
}
|
||||||
|
}
|
||||||
|
if ( y ) {
|
||||||
|
if ( SDL_MouseY < 0 ) {
|
||||||
|
*y = 0;
|
||||||
|
} else {
|
||||||
*y = SDL_MouseY;
|
*y = SDL_MouseY;
|
||||||
|
}
|
||||||
|
}
|
||||||
return(SDL_ButtonState);
|
return(SDL_ButtonState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +162,7 @@ int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y)
|
||||||
This prevents lots of extraneous large delta relative motion when
|
This prevents lots of extraneous large delta relative motion when
|
||||||
the screen is windowed mode and the mouse is outside the window.
|
the screen is windowed mode and the mouse is outside the window.
|
||||||
*/
|
*/
|
||||||
if ( ! relative ) {
|
if ( ! relative && SDL_MouseX >= 0 && SDL_MouseY >= 0 ) {
|
||||||
Xrel = X-SDL_MouseX;
|
Xrel = X-SDL_MouseX;
|
||||||
Yrel = Y-SDL_MouseY;
|
Yrel = Y-SDL_MouseY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue