Mercurial > sdl-ios-xcode
comparison src/events/SDL_mouse.c @ 1525:23a347cfbed8
Fixed bug #38
I'm using SDL 1.2.9 with Visual C++ 7.0 on Windows 2000.
Here's the setup: my game starts in a window, with
SDL_WM_GrabInput(SDL_GRAB_ON) to constrain the cursor to the game window. The
mouse cursor is outside of the window when the game launches, and when the
window appears the cursor is grabbed and placed at the top left corner of the
inside of the game window. At this point, if I click the mouse without moving
it, the SDL_MOUSEBUTTONDOWN event's mouse coordinates are (65535,65535).
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 14 Mar 2006 06:00:30 +0000 |
parents | e3242177fe4a |
children | 782fd950bd46 c121d94672cb a1b03ba2fcd0 |
comparison
equal
deleted
inserted
replaced
1524:38a12fd1a2c1 | 1525:23a347cfbed8 |
---|---|
28 #include "../video/SDL_cursor_c.h" | 28 #include "../video/SDL_cursor_c.h" |
29 #include "../video/SDL_sysvideo.h" | 29 #include "../video/SDL_sysvideo.h" |
30 | 30 |
31 | 31 |
32 /* These are static for our mouse handling code */ | 32 /* These are static for our mouse handling code */ |
33 static Sint16 SDL_MouseX = -1; | 33 static Sint16 SDL_MouseX = 0; |
34 static Sint16 SDL_MouseY = -1; | 34 static Sint16 SDL_MouseY = 0; |
35 static Sint16 SDL_DeltaX = 0; | 35 static Sint16 SDL_DeltaX = 0; |
36 static Sint16 SDL_DeltaY = 0; | 36 static Sint16 SDL_DeltaY = 0; |
37 static Uint8 SDL_ButtonState = 0; | 37 static Uint8 SDL_ButtonState = 0; |
38 | 38 |
39 | 39 |
40 /* Public functions */ | 40 /* Public functions */ |
41 int SDL_MouseInit(void) | 41 int SDL_MouseInit(void) |
42 { | 42 { |
43 /* The mouse is at (0,0) */ | 43 /* The mouse is at (0,0) */ |
44 SDL_MouseX = -1; | 44 SDL_MouseX = 0; |
45 SDL_MouseY = -1; | 45 SDL_MouseY = 0; |
46 SDL_DeltaX = 0; | 46 SDL_DeltaX = 0; |
47 SDL_DeltaY = 0; | 47 SDL_DeltaY = 0; |
48 SDL_ButtonState = 0; | 48 SDL_ButtonState = 0; |
49 | 49 |
50 /* That's it! */ | 50 /* That's it! */ |
66 } | 66 } |
67 | 67 |
68 Uint8 SDL_GetMouseState (int *x, int *y) | 68 Uint8 SDL_GetMouseState (int *x, int *y) |
69 { | 69 { |
70 if ( x ) { | 70 if ( x ) { |
71 if ( SDL_MouseX < 0 ) { | 71 *x = SDL_MouseX; |
72 *x = 0; | |
73 } else { | |
74 *x = SDL_MouseX; | |
75 } | |
76 } | 72 } |
77 if ( y ) { | 73 if ( y ) { |
78 if ( SDL_MouseY < 0 ) { | 74 *y = SDL_MouseY; |
79 *y = 0; | |
80 } else { | |
81 *y = SDL_MouseY; | |
82 } | |
83 } | 75 } |
84 return(SDL_ButtonState); | 76 return(SDL_ButtonState); |
85 } | 77 } |
86 | 78 |
87 Uint8 SDL_GetRelativeMouseState (int *x, int *y) | 79 Uint8 SDL_GetRelativeMouseState (int *x, int *y) |
155 | 147 |
156 /* If not relative mode, generate relative motion from clamped X/Y. | 148 /* If not relative mode, generate relative motion from clamped X/Y. |
157 This prevents lots of extraneous large delta relative motion when | 149 This prevents lots of extraneous large delta relative motion when |
158 the screen is windowed mode and the mouse is outside the window. | 150 the screen is windowed mode and the mouse is outside the window. |
159 */ | 151 */ |
160 if ( ! relative && SDL_MouseX >= 0 && SDL_MouseY >= 0 ) { | 152 if ( ! relative ) { |
161 Xrel = X-SDL_MouseX; | 153 Xrel = X-SDL_MouseX; |
162 Yrel = Y-SDL_MouseY; | 154 Yrel = Y-SDL_MouseY; |
163 } | 155 } |
164 | 156 |
165 /* Drop events that don't change state */ | 157 /* Drop events that don't change state */ |