Mercurial > sdl-ios-xcode
annotate src/events/SDL_mouse.c @ 1707:57ce47f033a5 SDL-1.3
Passing NULL to SDL_SetDisplayMode() will set the desktop mode.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Jun 2006 17:01:29 +0000 |
parents | 7688a73b25b1 |
children | a1ebb17f9c52 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* General mouse handling code for SDL */ | |
25 | |
26 #include "SDL_events.h" | |
27 #include "SDL_events_c.h" | |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
28 #include "default_cursor.h" |
0 | 29 |
30 | |
1670 | 31 static int SDL_num_mice; |
32 static int SDL_current_mouse; | |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
33 static SDL_Mouse **SDL_mice; |
0 | 34 |
35 | |
36 /* Public functions */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
37 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
38 SDL_MouseInit(void) |
0 | 39 { |
1670 | 40 return (0); |
41 } | |
42 | |
43 SDL_Mouse * | |
44 SDL_GetMouse(int index) | |
45 { | |
46 if (index < 0 || index >= SDL_num_mice) { | |
47 return NULL; | |
48 } | |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
49 return SDL_mice[index]; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
50 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
51 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
52 int |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
53 SDL_AddMouse(const SDL_Mouse * mouse, int index) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
54 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
55 SDL_Mouse **mice; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
56 SDL_Cursor *cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
57 int selected_mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
58 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
59 /* Add the mouse to the list of mice */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
60 if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
61 mice = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
62 (SDL_Mouse **) SDL_realloc(SDL_mice, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
63 (SDL_num_mice + 1) * sizeof(*mice)); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
64 if (!mice) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
65 SDL_OutOfMemory(); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
66 return -1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
67 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
68 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
69 SDL_mice = mice; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
70 index = SDL_num_mice++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
71 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
72 SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index])); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
73 if (!SDL_mice[index]) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
74 SDL_OutOfMemory(); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
75 return -1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
76 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
77 *SDL_mice[index] = *mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
78 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
79 /* Create the default cursor for the mouse */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
80 SDL_mice[index]->cursor_shown = SDL_TRUE; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
81 selected_mouse = SDL_SelectMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
82 SDL_mice[index]->cur_cursor = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
83 SDL_mice[index]->def_cursor = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
84 SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
85 DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
86 SDL_SetCursor(SDL_mice[index]->def_cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
87 SDL_SelectMouse(selected_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
88 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
89 return index; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
90 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
91 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
92 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
93 SDL_DelMouse(int index) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
94 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
95 SDL_Mouse *mouse = SDL_GetMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
96 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
97 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
98 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
99 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
100 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
101 mouse->def_cursor = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
102 while (mouse->cursors) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
103 SDL_FreeCursor(mouse->cursors); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
104 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
105 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
106 if (mouse->FreeMouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
107 mouse->FreeMouse(mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
108 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
109 SDL_free(mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
110 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
111 SDL_mice[index] = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
112 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
113 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
114 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
115 SDL_ResetMouse(int index) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
116 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
117 SDL_Mouse *mouse = SDL_GetMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
118 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
119 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
120 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
121 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
122 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
123 /* FIXME */ |
0 | 124 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
125 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
126 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
127 SDL_MouseQuit(void) |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
943
diff
changeset
|
128 { |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
129 int i; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
130 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
131 for (i = 0; i < SDL_num_mice; ++i) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
132 SDL_DelMouse(i); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
133 } |
1670 | 134 SDL_num_mice = 0; |
135 SDL_current_mouse = 0; | |
136 | |
137 if (SDL_mice) { | |
138 SDL_free(SDL_mice); | |
139 SDL_mice = NULL; | |
140 } | |
141 } | |
142 | |
143 int | |
144 SDL_GetNumMice(void) | |
145 { | |
146 return SDL_num_mice; | |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
943
diff
changeset
|
147 } |
0 | 148 |
1670 | 149 int |
150 SDL_SelectMouse(int index) | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
151 { |
1670 | 152 if (index >= 0 && index < SDL_num_mice) { |
153 SDL_current_mouse = index; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
154 } |
1670 | 155 return SDL_current_mouse; |
156 } | |
157 | |
158 SDL_WindowID | |
159 SDL_GetMouseFocusWindow() | |
160 { | |
161 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); | |
162 | |
163 if (!mouse) { | |
164 return 0; | |
165 } | |
166 return mouse->focus; | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
167 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
168 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
169 Uint8 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
170 SDL_GetMouseState(int *x, int *y) |
0 | 171 { |
1670 | 172 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
173 | |
174 if (!mouse) { | |
175 if (x) { | |
176 *x = 0; | |
177 } | |
178 if (y) { | |
179 *y = 0; | |
180 } | |
181 return 0; | |
182 } | |
183 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
184 if (x) { |
1670 | 185 *x = mouse->x; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
186 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
187 if (y) { |
1670 | 188 *y = mouse->y; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
189 } |
1670 | 190 return mouse->buttonstate; |
0 | 191 } |
192 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
193 Uint8 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
194 SDL_GetRelativeMouseState(int *x, int *y) |
0 | 195 { |
1670 | 196 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
197 |
1670 | 198 if (!mouse) { |
199 if (x) { | |
200 *x = 0; | |
201 } | |
202 if (y) { | |
203 *y = 0; | |
204 } | |
205 return 0; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
206 } |
0 | 207 |
1670 | 208 if (x) { |
209 *x = mouse->xdelta; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
210 } |
1670 | 211 if (y) { |
212 *y = mouse->ydelta; | |
213 } | |
214 mouse->xdelta = 0; | |
215 mouse->ydelta = 0; | |
216 return mouse->buttonstate; | |
217 } | |
0 | 218 |
1670 | 219 int |
220 SDL_SendMouseMotion(int index, SDL_WindowID windowID, int relative, int x, | |
221 int y) | |
222 { | |
223 SDL_Mouse *mouse = SDL_GetMouse(index); | |
224 int posted; | |
225 int xrel; | |
226 int yrel; | |
227 | |
228 if (!mouse) { | |
229 return 0; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
230 } |
0 | 231 |
1670 | 232 if (windowID) { |
233 mouse->focus = windowID; | |
234 } | |
0 | 235 |
1670 | 236 if (relative) { |
237 /* Push the cursor around */ | |
238 xrel = x; | |
239 yrel = y; | |
240 x = (mouse->x + xrel); | |
241 y = (mouse->y + yrel); | |
242 } else { | |
243 xrel = x - mouse->x; | |
244 yrel = y - mouse->y; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
245 } |
0 | 246 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
247 /* Drop events that don't change state */ |
1670 | 248 if (!xrel && !yrel) { |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
249 #if 0 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
250 printf("Mouse event didn't change state - dropped!\n"); |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
251 #endif |
1670 | 252 return 0; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
253 } |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
254 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
255 /* Update internal mouse state */ |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
256 mouse->x = x; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
257 mouse->y = y; |
1670 | 258 mouse->xdelta += xrel; |
259 mouse->ydelta += yrel; | |
0 | 260 |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
261 /* Move the mouse cursor, if needed */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
262 if (mouse->MoveCursor && mouse->cur_cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
263 mouse->MoveCursor(mouse->cur_cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
264 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
265 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
266 /* Post the event, if desired */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
267 posted = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
268 if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
269 SDL_Event event; |
1670 | 270 event.motion.type = SDL_MOUSEMOTION; |
271 event.motion.which = (Uint8) index; | |
272 event.motion.state = mouse->buttonstate; | |
273 event.motion.x = mouse->x; | |
274 event.motion.y = mouse->y; | |
275 event.motion.xrel = xrel; | |
276 event.motion.yrel = yrel; | |
277 event.motion.windowID = mouse->focus; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
278 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
279 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
280 SDL_PushEvent(&event); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
281 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
282 } |
1670 | 283 return posted; |
0 | 284 } |
285 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
286 int |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
287 SDL_SendMouseButton(int index, SDL_WindowID windowID, Uint8 state, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
288 Uint8 button) |
0 | 289 { |
1670 | 290 SDL_Mouse *mouse = SDL_GetMouse(index); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
291 int posted; |
1670 | 292 Uint8 type; |
0 | 293 |
1670 | 294 if (!mouse) { |
295 return 0; | |
296 } | |
0 | 297 |
1670 | 298 if (windowID) { |
299 mouse->focus = windowID; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
300 } |
0 | 301 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
302 /* Figure out which event to perform */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
303 switch (state) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
304 case SDL_PRESSED: |
1670 | 305 if (mouse->buttonstate & SDL_BUTTON(button)) { |
306 /* Ignore this event, no state change */ | |
307 return 0; | |
308 } | |
309 type = SDL_MOUSEBUTTONDOWN; | |
310 mouse->buttonstate |= SDL_BUTTON(button); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
311 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
312 case SDL_RELEASED: |
1670 | 313 if (!(mouse->buttonstate & SDL_BUTTON(button))) { |
314 /* Ignore this event, no state change */ | |
315 return 0; | |
316 } | |
317 type = SDL_MOUSEBUTTONUP; | |
318 mouse->buttonstate &= ~SDL_BUTTON(button); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
319 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
320 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
321 /* Invalid state -- bail */ |
1670 | 322 return 0; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
323 } |
0 | 324 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
325 /* Post the event, if desired */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
326 posted = 0; |
1670 | 327 if (SDL_ProcessEvents[type] == SDL_ENABLE) { |
328 SDL_Event event; | |
329 event.type = type; | |
330 event.button.which = (Uint8) index; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
331 event.button.state = state; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
332 event.button.button = button; |
1670 | 333 event.button.x = mouse->x; |
334 event.button.y = mouse->y; | |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1671
diff
changeset
|
335 event.button.windowID = mouse->focus; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
336 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
337 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
338 SDL_PushEvent(&event); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
339 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
340 } |
1670 | 341 return posted; |
0 | 342 } |
343 | |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
344 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
345 SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
346 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
347 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
348 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
349 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
350 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
351 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
352 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
353 if (mouse->WarpMouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
354 mouse->WarpMouse(mouse, windowID, x, y); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
355 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
356 SDL_SendMouseMotion(SDL_current_mouse, windowID, 0, x, y); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
357 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
358 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
359 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
360 SDL_Cursor * |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
361 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
362 int w, int h, int hot_x, int hot_y) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
363 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
364 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
365 SDL_Surface *surface; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
366 SDL_Cursor *cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
367 int x, y; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
368 Uint32 *pixel; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
369 Uint8 datab, maskb; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
370 const Uint32 black = 0xFF000000; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
371 const Uint32 white = 0xFFFFFFFF; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
372 const Uint32 transparent = 0x00000000; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
373 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
374 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
375 SDL_SetError("No mice are initialized"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
376 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
377 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
378 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
379 if (!mouse->CreateCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
380 SDL_SetError("Current mouse doesn't have cursor support"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
381 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
382 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
383 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
384 /* Sanity check the hot spot */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
385 if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
386 SDL_SetError("Cursor hot spot doesn't lie within cursor"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
387 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
388 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
389 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
390 /* Make sure the width is a multiple of 8 */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
391 w = ((w + 7) & ~7); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
392 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
393 /* Create the surface from a bitmap */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
394 surface = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
395 SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
396 0xFF000000); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
397 if (!surface) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
398 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
399 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
400 for (y = 0; y < h; ++y) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
401 pixel = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
402 (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch + |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
403 x * 4); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
404 for (x = 0; x < w; ++x) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
405 if ((x % 8) == 0) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
406 datab = *data++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
407 maskb = *mask++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
408 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
409 if (maskb & 0x80) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
410 *pixel++ = (datab & 0x80) ? black : white; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
411 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
412 *pixel++ = (datab & 0x80) ? black : transparent; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
413 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
414 datab <<= 1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
415 maskb <<= 1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
416 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
417 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
418 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
419 cursor = mouse->CreateCursor(surface, hot_x, hot_y); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
420 if (cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
421 cursor->mouse = mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
422 cursor->next = mouse->cursors; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
423 mouse->cursors = cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
424 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
425 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
426 SDL_FreeSurface(surface); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
427 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
428 return cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
429 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
430 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
431 /* SDL_SetCursor(NULL) can be used to force the cursor redraw, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
432 if this is desired for any reason. This is used when setting |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
433 the video mode and when the SDL window gains the mouse focus. |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
434 */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
435 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
436 SDL_SetCursor(SDL_Cursor * cursor) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
437 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
438 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
439 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
440 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
441 SDL_SetError("No mice are initialized"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
442 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
443 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
444 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
445 /* Set the new cursor */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
446 if (cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
447 /* Make sure the cursor is still valid for this mouse */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
448 SDL_Cursor *found; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
449 for (found = mouse->cursors; found; found = found->next) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
450 if (found == cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
451 break; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
452 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
453 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
454 if (!found) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
455 SDL_SetError("Cursor not associated with the current mouse"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
456 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
457 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
458 mouse->cur_cursor = cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
459 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
460 cursor = mouse->cur_cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
461 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
462 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
463 if (cursor && mouse->cursor_shown) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
464 if (mouse->ShowCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
465 mouse->ShowCursor(cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
466 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
467 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
468 if (mouse->ShowCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
469 mouse->ShowCursor(NULL); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
470 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
471 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
472 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
473 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
474 SDL_Cursor * |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
475 SDL_GetCursor(void) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
476 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
477 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
478 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
479 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
480 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
481 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
482 return mouse->cur_cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
483 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
484 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
485 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
486 SDL_FreeCursor(SDL_Cursor * cursor) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
487 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
488 SDL_Mouse *mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
489 SDL_Cursor *curr, *prev; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
490 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
491 if (!cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
492 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
493 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
494 mouse = cursor->mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
495 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
496 if (cursor == mouse->def_cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
497 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
498 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
499 if (cursor == mouse->cur_cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
500 SDL_SetCursor(mouse->def_cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
501 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
502 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
503 for (prev = NULL, curr = mouse->cursors; curr; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
504 prev = curr, curr = curr->next) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
505 if (curr == cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
506 if (prev) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
507 prev->next = curr->next; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
508 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
509 mouse->cursors = curr->next; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
510 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
511 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
512 if (mouse->FreeCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
513 mouse->FreeCursor(curr); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
514 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
515 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
516 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
517 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
518 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
519 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
520 int |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
521 SDL_ShowCursor(int toggle) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
522 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
523 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
524 SDL_bool shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
525 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
526 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
527 return 0; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
528 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
529 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
530 shown = mouse->cursor_shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
531 if (toggle >= 0) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
532 if (toggle) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
533 mouse->cursor_shown = SDL_TRUE; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
534 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
535 mouse->cursor_shown = SDL_FALSE; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
536 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
537 if (mouse->cursor_shown != shown) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
538 SDL_SetCursor(NULL); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
539 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
540 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
541 return shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
542 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
543 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
544 /* vi: set ts=4 sw=4 expandtab: */ |