1.1 --- a/src/events/SDL_mouse.c Sun Sep 27 04:49:30 2009 +0000
1.2 +++ b/src/events/SDL_mouse.c Sun Sep 27 05:18:43 2009 +0000
1.3 @@ -34,6 +34,8 @@
1.4 static Sint16 SDL_MouseY = 0;
1.5 static Sint16 SDL_DeltaX = 0;
1.6 static Sint16 SDL_DeltaY = 0;
1.7 +static Sint16 SDL_MouseMaxX = 0;
1.8 +static Sint16 SDL_MouseMaxY = 0;
1.9 static Uint8 SDL_ButtonState = 0;
1.10
1.11
1.12 @@ -45,6 +47,8 @@
1.13 SDL_MouseY = 0;
1.14 SDL_DeltaX = 0;
1.15 SDL_DeltaY = 0;
1.16 + SDL_MouseMaxX = 0;
1.17 + SDL_MouseMaxY = 0;
1.18 SDL_ButtonState = 0;
1.19
1.20 /* That's it! */
1.21 @@ -92,13 +96,19 @@
1.22 /* This clips absolute mouse coordinates when the apparent
1.23 display surface is smaller than the real display surface.
1.24 */
1.25 - if ( SDL_VideoSurface->offset ) {
1.26 + if ( SDL_VideoSurface && SDL_VideoSurface->offset ) {
1.27 *y -= SDL_VideoSurface->offset/SDL_VideoSurface->pitch;
1.28 *x -= (SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
1.29 SDL_VideoSurface->format->BytesPerPixel;
1.30 }
1.31 }
1.32
1.33 +void SDL_SetMouseRange(int maxX, int maxY)
1.34 +{
1.35 + SDL_MouseMaxX = (Sint16)maxX;
1.36 + SDL_MouseMaxY = (Sint16)maxY;
1.37 +}
1.38 +
1.39 /* These are global for SDL_eventloop.c */
1.40 int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y)
1.41 {
1.42 @@ -107,11 +117,6 @@
1.43 Sint16 Xrel;
1.44 Sint16 Yrel;
1.45
1.46 - /* Don't handle mouse motion if there's no cursor surface */
1.47 - if ( SDL_VideoSurface == NULL ) {
1.48 - return(0);
1.49 - }
1.50 -
1.51 /* Default buttonstate is the current one */
1.52 if ( ! buttonstate ) {
1.53 buttonstate = SDL_ButtonState;
1.54 @@ -132,16 +137,16 @@
1.55 if ( x < 0 )
1.56 X = 0;
1.57 else
1.58 - if ( x >= SDL_VideoSurface->w )
1.59 - X = SDL_VideoSurface->w-1;
1.60 + if ( x >= SDL_MouseMaxX )
1.61 + X = SDL_MouseMaxX-1;
1.62 else
1.63 X = (Uint16)x;
1.64
1.65 if ( y < 0 )
1.66 Y = 0;
1.67 else
1.68 - if ( y >= SDL_VideoSurface->h )
1.69 - Y = SDL_VideoSurface->h-1;
1.70 + if ( y >= SDL_MouseMaxY )
1.71 + Y = SDL_MouseMaxY-1;
1.72 else
1.73 Y = (Uint16)y;
1.74
1.75 @@ -206,14 +211,14 @@
1.76 if ( x < 0 )
1.77 x = 0;
1.78 else
1.79 - if ( x >= SDL_VideoSurface->w )
1.80 - x = SDL_VideoSurface->w-1;
1.81 + if ( x >= SDL_MouseMaxX )
1.82 + x = SDL_MouseMaxX-1;
1.83
1.84 if ( y < 0 )
1.85 y = 0;
1.86 else
1.87 - if ( y >= SDL_VideoSurface->h )
1.88 - y = SDL_VideoSurface->h-1;
1.89 + if ( y >= SDL_MouseMaxY )
1.90 + y = SDL_MouseMaxY-1;
1.91 } else {
1.92 move_mouse = 0;
1.93 }