Applied John Popplewell's fix for left-handed mice under Windows.
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Sep 2002 06:14:46 +0000
changeset 491da6a7e859616
parent 490 7e53d17ec798
child 492 c59692dcdce0
Applied John Popplewell's fix for left-handed mice under Windows.
src/video/windx5/SDL_dx5events.c
     1.1 --- a/src/video/windx5/SDL_dx5events.c	Mon Sep 09 05:28:06 2002 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5events.c	Mon Sep 16 06:14:46 2002 +0000
     1.3 @@ -58,6 +58,7 @@
     1.4  static int SDL_DIndev = 0;
     1.5  static int mouse_lost;
     1.6  static int mouse_pressed;
     1.7 +static int mouse_buttons_swapped = 0;
     1.8  
     1.9  /* The translation table from a DirectInput scancode to an SDL keysym */
    1.10  static SDLKey DIK_keymap[256];
    1.11 @@ -216,6 +217,7 @@
    1.12  		++SDL_DIndev;
    1.13  	}
    1.14  	mouse_pressed = 0;
    1.15 +	mouse_buttons_swapped = GetSystemMetrics(SM_SWAPBUTTON);
    1.16  
    1.17  	/* DirectInput is ready! */
    1.18  	return(0);
    1.19 @@ -340,6 +342,11 @@
    1.20  					}
    1.21  					state = SDL_RELEASED;
    1.22  				}
    1.23 +				if ( mouse_buttons_swapped ) {
    1.24 +					if ( button == 1 ) button = 3;
    1.25 +					else
    1.26 +					if ( button == 3 ) button = 1;
    1.27 +				}
    1.28  				posted = SDL_PrivateMouseButton(state, button,
    1.29  									0, 0);
    1.30  			}
    1.31 @@ -411,6 +418,11 @@
    1.32  					}
    1.33  					state = SDL_RELEASED;
    1.34  				}
    1.35 +				if ( mouse_buttons_swapped ) {
    1.36 +					if ( button == 1 ) button = 3;
    1.37 +					else
    1.38 +					if ( button == 3 ) button = 1;
    1.39 +				}
    1.40  				posted = SDL_PrivateMouseButton(state, button,
    1.41  									0, 0);
    1.42  				break;