diff -r a9c6e65c1416 -r 429c8dd3175d src/events/SDL_mouse.c --- a/src/events/SDL_mouse.c Sun Sep 27 04:49:30 2009 +0000 +++ b/src/events/SDL_mouse.c Sun Sep 27 05:18:43 2009 +0000 @@ -34,6 +34,8 @@ static Sint16 SDL_MouseY = 0; static Sint16 SDL_DeltaX = 0; static Sint16 SDL_DeltaY = 0; +static Sint16 SDL_MouseMaxX = 0; +static Sint16 SDL_MouseMaxY = 0; static Uint8 SDL_ButtonState = 0; @@ -45,6 +47,8 @@ SDL_MouseY = 0; SDL_DeltaX = 0; SDL_DeltaY = 0; + SDL_MouseMaxX = 0; + SDL_MouseMaxY = 0; SDL_ButtonState = 0; /* That's it! */ @@ -92,13 +96,19 @@ /* This clips absolute mouse coordinates when the apparent display surface is smaller than the real display surface. */ - if ( SDL_VideoSurface->offset ) { + if ( SDL_VideoSurface && SDL_VideoSurface->offset ) { *y -= SDL_VideoSurface->offset/SDL_VideoSurface->pitch; *x -= (SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ SDL_VideoSurface->format->BytesPerPixel; } } +void SDL_SetMouseRange(int maxX, int maxY) +{ + SDL_MouseMaxX = (Sint16)maxX; + SDL_MouseMaxY = (Sint16)maxY; +} + /* These are global for SDL_eventloop.c */ int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y) { @@ -107,11 +117,6 @@ Sint16 Xrel; Sint16 Yrel; - /* Don't handle mouse motion if there's no cursor surface */ - if ( SDL_VideoSurface == NULL ) { - return(0); - } - /* Default buttonstate is the current one */ if ( ! buttonstate ) { buttonstate = SDL_ButtonState; @@ -132,16 +137,16 @@ if ( x < 0 ) X = 0; else - if ( x >= SDL_VideoSurface->w ) - X = SDL_VideoSurface->w-1; + if ( x >= SDL_MouseMaxX ) + X = SDL_MouseMaxX-1; else X = (Uint16)x; if ( y < 0 ) Y = 0; else - if ( y >= SDL_VideoSurface->h ) - Y = SDL_VideoSurface->h-1; + if ( y >= SDL_MouseMaxY ) + Y = SDL_MouseMaxY-1; else Y = (Uint16)y; @@ -206,14 +211,14 @@ if ( x < 0 ) x = 0; else - if ( x >= SDL_VideoSurface->w ) - x = SDL_VideoSurface->w-1; + if ( x >= SDL_MouseMaxX ) + x = SDL_MouseMaxX-1; if ( y < 0 ) y = 0; else - if ( y >= SDL_VideoSurface->h ) - y = SDL_VideoSurface->h-1; + if ( y >= SDL_MouseMaxY ) + y = SDL_MouseMaxY-1; } else { move_mouse = 0; }