Fixed bug #382 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Jul 2007 09:15:43 +0000
branchSDL-1.2
changeset 40091146681dbb74
parent 4008 a19fd8bcdd52
child 4010 3aa1406620f6
Fixed bug #382

Added horizontal scrolling support: SDL_BUTTON_WHEELLEFT (6) and SDL_BUTTON_WHEELRIGHT (7)
WhatsNew
docs.html
include/SDL_mouse.h
src/video/bwindow/SDL_sysevents.cc
src/video/quartz/SDL_QuartzEvents.m
     1.1 --- a/WhatsNew	Fri Jul 06 07:45:33 2007 +0000
     1.2 +++ b/WhatsNew	Fri Jul 06 09:15:43 2007 +0000
     1.3 @@ -7,6 +7,8 @@
     1.4  	Added SDL_VIDEO_ALLOW_SCREENSAVER to override SDL's disabling
     1.5  	of the screensaver on Mac OS X and X11.
     1.6  
     1.7 +	Added SDL_BUTTON_WHEELLEFT (6) and SDL_BUTTON_WHEELRIGHT (7)
     1.8 +
     1.9  1.2.10:
    1.10  	If SDL_OpenAudio() is passed zero for the desired format
    1.11  	fields, the following environment variables will be used
     2.1 --- a/docs.html	Fri Jul 06 07:45:33 2007 +0000
     2.2 +++ b/docs.html	Fri Jul 06 09:15:43 2007 +0000
     2.3 @@ -29,6 +29,9 @@
     2.4  	Added SDL_VIDEO_ALLOW_SCREENSAVER to override SDL's disabling of the screensaver on Mac OS X, Windows, and X11.
     2.5  </P>
     2.6  <P>
     2.7 +	Added SDL_BUTTON_WHEELLEFT (6) and SDL_BUTTON_WHEELRIGHT (7)
     2.8 +</P>
     2.9 +<P>
    2.10  	Fixed buffer overrun crash when resampling audio rates.
    2.11  </P>
    2.12  <P>
     3.1 --- a/include/SDL_mouse.h	Fri Jul 06 07:45:33 2007 +0000
     3.2 +++ b/include/SDL_mouse.h	Fri Jul 06 09:15:43 2007 +0000
     3.3 @@ -115,6 +115,8 @@
     3.4     Button 3:	Right mouse button
     3.5     Button 4:	Mouse wheel up	 (may also be a real button)
     3.6     Button 5:	Mouse wheel down (may also be a real button)
     3.7 +   Button 6:	Mouse wheel left (may also be a real button)
     3.8 +   Button 7:	Mouse wheel right (may also be a real button)
     3.9   */
    3.10  #define SDL_BUTTON(X)		(1 << ((X)-1))
    3.11  #define SDL_BUTTON_LEFT		1
    3.12 @@ -122,6 +124,8 @@
    3.13  #define SDL_BUTTON_RIGHT	3
    3.14  #define SDL_BUTTON_WHEELUP	4
    3.15  #define SDL_BUTTON_WHEELDOWN	5
    3.16 +#define SDL_BUTTON_WHEELLEFT	6
    3.17 +#define SDL_BUTTON_WHEELRIGHT	7
    3.18  #define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
    3.19  #define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
    3.20  #define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
     4.1 --- a/src/video/bwindow/SDL_sysevents.cc	Fri Jul 06 07:45:33 2007 +0000
     4.2 +++ b/src/video/bwindow/SDL_sysevents.cc	Fri Jul 06 09:15:43 2007 +0000
     4.3 @@ -294,12 +294,23 @@
     4.4  			float x, y;
     4.5  			x = y = 0;
     4.6  			if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
     4.7 -				if (x < 0 || y < 0) {
     4.8 -					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
     4.9 -					SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
    4.10 -				} else if (x > 0 || y > 0) {
    4.11 -					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
    4.12 -					SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
    4.13 +				if ( y ) {
    4.14 +					if (y < 0) {
    4.15 +						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
    4.16 +						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
    4.17 +					} else {
    4.18 +						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
    4.19 +						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
    4.20 +					}
    4.21 +				}
    4.22 +				if ( x ) {
    4.23 +					if (x < 0) {
    4.24 +						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELRIGHT, 0, 0);
    4.25 +						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELRIGHT, 0, 0);
    4.26 +					} else {
    4.27 +						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELLEFT, 0, 0);
    4.28 +						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELLEFT, 0, 0);
    4.29 +					}
    4.30  				}
    4.31  			}
    4.32  			break;
     5.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Fri Jul 06 07:45:33 2007 +0000
     5.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Fri Jul 06 09:15:43 2007 +0000
     5.3 @@ -932,13 +932,24 @@
     5.4                          Uint8 button;
     5.5                          dy = [ event deltaY ];
     5.6                          dx = [ event deltaX ];
     5.7 -                        if ( dy > 0.0 || dx > 0.0 ) /* Scroll up */
     5.8 -                            button = SDL_BUTTON_WHEELUP;
     5.9 -                        else /* Scroll down */
    5.10 -                            button = SDL_BUTTON_WHEELDOWN;
    5.11 -                        /* For now, wheel is sent as a quick down+up */
    5.12 -                        SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);
    5.13 -                        SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);
    5.14 +			if ( dy ) {
    5.15 +				if ( dy > 0.0 ) /* Scroll up */
    5.16 +				    button = SDL_BUTTON_WHEELUP;
    5.17 +				else /* Scroll down */
    5.18 +				    button = SDL_BUTTON_WHEELDOWN;
    5.19 +				/* For now, wheel is sent as a quick down+up */
    5.20 +				SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);
    5.21 +				SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);
    5.22 +			}
    5.23 +			if ( dx ) {
    5.24 +				if ( dx > 0.0 ) /* Scroll left */
    5.25 +				    button = SDL_BUTTON_WHEELLEFT;
    5.26 +				else /* Scroll right */
    5.27 +				    button = SDL_BUTTON_WHEELRIGHT;
    5.28 +				/* For now, wheel is sent as a quick down+up */
    5.29 +				SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);
    5.30 +				SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);
    5.31 +			}
    5.32                      }
    5.33                      break;
    5.34                  case NSKeyUp: