equal
deleted
inserted
replaced
36 #include "SDL_cursor_c.h" |
36 #include "SDL_cursor_c.h" |
37 #include "SDL_sysvideo.h" |
37 #include "SDL_sysvideo.h" |
38 |
38 |
39 |
39 |
40 /* These are static for our mouse handling code */ |
40 /* These are static for our mouse handling code */ |
41 static Sint16 SDL_MouseX = 0; |
41 static Sint16 SDL_MouseX = -1; |
42 static Sint16 SDL_MouseY = 0; |
42 static Sint16 SDL_MouseY = -1; |
43 static Sint16 SDL_DeltaX = 0; |
43 static Sint16 SDL_DeltaX = 0; |
44 static Sint16 SDL_DeltaY = 0; |
44 static Sint16 SDL_DeltaY = 0; |
45 static Uint8 SDL_ButtonState = 0; |
45 static Uint8 SDL_ButtonState = 0; |
46 |
46 |
47 |
47 |
48 /* Public functions */ |
48 /* Public functions */ |
49 int SDL_MouseInit(void) |
49 int SDL_MouseInit(void) |
50 { |
50 { |
51 /* The mouse is at (0,0) */ |
51 /* The mouse is at (0,0) */ |
52 SDL_MouseX = 0; |
52 SDL_MouseX = -1; |
53 SDL_MouseY = 0; |
53 SDL_MouseY = -1; |
54 SDL_DeltaX = 0; |
54 SDL_DeltaX = 0; |
55 SDL_DeltaY = 0; |
55 SDL_DeltaY = 0; |
56 SDL_ButtonState = 0; |
56 SDL_ButtonState = 0; |
57 |
57 |
58 /* That's it! */ |
58 /* That's it! */ |
70 } |
70 } |
71 } |
71 } |
72 |
72 |
73 Uint8 SDL_GetMouseState (int *x, int *y) |
73 Uint8 SDL_GetMouseState (int *x, int *y) |
74 { |
74 { |
75 if ( x ) |
75 if ( x ) { |
76 *x = SDL_MouseX; |
76 if ( SDL_MouseX < 0 ) { |
77 if ( y ) |
77 *x = 0; |
78 *y = SDL_MouseY; |
78 } else { |
|
79 *x = SDL_MouseX; |
|
80 } |
|
81 } |
|
82 if ( y ) { |
|
83 if ( SDL_MouseY < 0 ) { |
|
84 *y = 0; |
|
85 } else { |
|
86 *y = SDL_MouseY; |
|
87 } |
|
88 } |
79 return(SDL_ButtonState); |
89 return(SDL_ButtonState); |
80 } |
90 } |
81 |
91 |
82 Uint8 SDL_GetRelativeMouseState (int *x, int *y) |
92 Uint8 SDL_GetRelativeMouseState (int *x, int *y) |
83 { |
93 { |
150 |
160 |
151 /* If not relative mode, generate relative motion from clamped X/Y. |
161 /* If not relative mode, generate relative motion from clamped X/Y. |
152 This prevents lots of extraneous large delta relative motion when |
162 This prevents lots of extraneous large delta relative motion when |
153 the screen is windowed mode and the mouse is outside the window. |
163 the screen is windowed mode and the mouse is outside the window. |
154 */ |
164 */ |
155 if ( ! relative ) { |
165 if ( ! relative && SDL_MouseX >= 0 && SDL_MouseY >= 0 ) { |
156 Xrel = X-SDL_MouseX; |
166 Xrel = X-SDL_MouseX; |
157 Yrel = Y-SDL_MouseY; |
167 Yrel = Y-SDL_MouseY; |
158 } |
168 } |
159 |
169 |
160 /* Update internal mouse state */ |
170 /* Update internal mouse state */ |