Mercurial > sdl-ios-xcode
annotate src/events/SDL_mouse.c @ 1724:6c63fc2bd986 SDL-1.3
Proof of concept done - Win32 GDI implementation mostly complete.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 06 Jul 2006 07:17:11 +0000 |
parents | 5daa04d862f1 |
children | 875c3cf1a12c |
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 int selected_mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
57 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
58 /* 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
|
59 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
|
60 mice = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
61 (SDL_Mouse **) SDL_realloc(SDL_mice, |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
62 (SDL_num_mice + 1) * sizeof(*mice)); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
63 if (!mice) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
64 SDL_OutOfMemory(); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
65 return -1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
66 } |
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 SDL_mice = mice; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
69 index = SDL_num_mice++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
70 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
71 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
|
72 if (!SDL_mice[index]) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
73 SDL_OutOfMemory(); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
74 return -1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
75 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
76 *SDL_mice[index] = *mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
77 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
78 /* 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
|
79 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
|
80 selected_mouse = SDL_SelectMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
81 SDL_mice[index]->cur_cursor = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
82 SDL_mice[index]->def_cursor = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
83 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
|
84 DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
85 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
|
86 SDL_SelectMouse(selected_mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
87 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
88 return index; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
89 } |
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 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
92 SDL_DelMouse(int index) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
93 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
94 SDL_Mouse *mouse = SDL_GetMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
95 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
96 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
97 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
98 } |
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 mouse->def_cursor = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
101 while (mouse->cursors) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
102 SDL_FreeCursor(mouse->cursors); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
103 } |
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 if (mouse->FreeMouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
106 mouse->FreeMouse(mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
107 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
108 SDL_free(mouse); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
109 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
110 SDL_mice[index] = NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
111 } |
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 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
114 SDL_ResetMouse(int index) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
115 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
116 SDL_Mouse *mouse = SDL_GetMouse(index); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
117 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
118 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
119 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
120 } |
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 /* FIXME */ |
0 | 123 } |
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
|
124 |
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 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
126 SDL_MouseQuit(void) |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
943
diff
changeset
|
127 { |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
128 int i; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
129 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
130 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
|
131 SDL_DelMouse(i); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
132 } |
1670 | 133 SDL_num_mice = 0; |
134 SDL_current_mouse = 0; | |
135 | |
136 if (SDL_mice) { | |
137 SDL_free(SDL_mice); | |
138 SDL_mice = NULL; | |
139 } | |
140 } | |
141 | |
142 int | |
143 SDL_GetNumMice(void) | |
144 { | |
145 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
|
146 } |
0 | 147 |
1670 | 148 int |
149 SDL_SelectMouse(int index) | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
150 { |
1670 | 151 if (index >= 0 && index < SDL_num_mice) { |
152 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
|
153 } |
1670 | 154 return SDL_current_mouse; |
155 } | |
156 | |
157 SDL_WindowID | |
158 SDL_GetMouseFocusWindow() | |
159 { | |
160 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); | |
161 | |
162 if (!mouse) { | |
163 return 0; | |
164 } | |
165 return mouse->focus; | |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
166 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
167 |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
168 static int |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
169 FlushMouseMotion(void *param, SDL_Event * event) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
170 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
171 if (event->type == SDL_MOUSEMOTION |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
172 && event->motion.which == (Uint8) SDL_current_mouse) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
173 return 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
174 } else { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
175 return 1; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
176 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
177 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
178 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
179 int |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
180 SDL_SetRelativeMouseMode(SDL_bool enabled) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
181 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
182 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
183 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
184 if (!mouse) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
185 return -1; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
186 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
187 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
188 /* Flush pending mouse motion */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
189 mouse->flush_motion = SDL_TRUE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
190 SDL_PumpEvents(); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
191 mouse->flush_motion = SDL_FALSE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
192 SDL_FilterEvents(FlushMouseMotion, mouse); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
193 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
194 /* Set the relative mode */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
195 mouse->relative_mode = enabled; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
196 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
197 /* Update cursor visibility */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
198 SDL_SetCursor(NULL); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
199 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
200 if (!enabled) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
201 /* Restore the expected mouse position */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
202 SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
203 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
204 return 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
205 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
206 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
207 SDL_bool |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
208 SDL_GetRelativeMouseMode() |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
209 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
210 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
211 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
212 if (!mouse) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
213 return SDL_FALSE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
214 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
215 return mouse->relative_mode; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
216 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
217 |
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
|
218 Uint8 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
219 SDL_GetMouseState(int *x, int *y) |
0 | 220 { |
1670 | 221 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
222 | |
223 if (!mouse) { | |
224 if (x) { | |
225 *x = 0; | |
226 } | |
227 if (y) { | |
228 *y = 0; | |
229 } | |
230 return 0; | |
231 } | |
232 | |
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
|
233 if (x) { |
1670 | 234 *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
|
235 } |
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
|
236 if (y) { |
1670 | 237 *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
|
238 } |
1670 | 239 return mouse->buttonstate; |
0 | 240 } |
241 | |
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
|
242 Uint8 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
243 SDL_GetRelativeMouseState(int *x, int *y) |
0 | 244 { |
1670 | 245 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
|
246 |
1670 | 247 if (!mouse) { |
248 if (x) { | |
249 *x = 0; | |
250 } | |
251 if (y) { | |
252 *y = 0; | |
253 } | |
254 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
|
255 } |
0 | 256 |
1670 | 257 if (x) { |
258 *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
|
259 } |
1670 | 260 if (y) { |
261 *y = mouse->ydelta; | |
262 } | |
263 mouse->xdelta = 0; | |
264 mouse->ydelta = 0; | |
265 return mouse->buttonstate; | |
266 } | |
0 | 267 |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
268 void |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
269 SDL_SetMouseFocus(int index, SDL_WindowID windowID) |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
270 { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
271 SDL_Mouse *mouse = SDL_GetMouse(index); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
272 int i; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
273 SDL_bool focus; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
274 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
275 if (!mouse || (mouse->focus == windowID)) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
276 return; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
277 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
278 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
279 /* See if the current window has lost focus */ |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
280 if (mouse->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
281 focus = SDL_FALSE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
282 for (i = 0; i < SDL_num_mice; ++i) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
283 SDL_Mouse *check; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
284 if (i != index) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
285 check = SDL_GetMouse(i); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
286 if (check && check->focus == mouse->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
287 focus = SDL_TRUE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
288 break; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
289 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
290 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
291 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
292 if (!focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
293 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_LEAVE, 0, 0); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
294 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
295 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
296 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
297 mouse->focus = windowID; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
298 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
299 if (mouse->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
300 focus = SDL_FALSE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
301 for (i = 0; i < SDL_num_mice; ++i) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
302 SDL_Mouse *check; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
303 if (i != index) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
304 check = SDL_GetMouse(i); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
305 if (check && check->focus == mouse->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
306 focus = SDL_TRUE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
307 break; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
308 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
309 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
310 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
311 if (!focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
312 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_ENTER, 0, 0); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
313 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
314 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
315 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
316 |
1670 | 317 int |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
318 SDL_SendMouseMotion(int index, int relative, int x, int y) |
1670 | 319 { |
320 SDL_Mouse *mouse = SDL_GetMouse(index); | |
321 int posted; | |
322 int xrel; | |
323 int yrel; | |
324 | |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
325 if (!mouse || mouse->flush_motion) { |
1670 | 326 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
|
327 } |
0 | 328 |
1670 | 329 if (relative) { |
330 /* Push the cursor around */ | |
331 xrel = x; | |
332 yrel = y; | |
333 x = (mouse->x + xrel); | |
334 y = (mouse->y + yrel); | |
335 } else { | |
336 xrel = x - mouse->x; | |
337 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
|
338 } |
0 | 339 |
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
|
340 /* Drop events that don't change state */ |
1670 | 341 if (!xrel && !yrel) { |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
342 #if 0 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
343 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
|
344 #endif |
1670 | 345 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
|
346 } |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
347 |
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
|
348 /* Update internal mouse state */ |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
349 if (!mouse->relative_mode) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
350 mouse->x = x; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
351 mouse->y = y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
352 } |
1670 | 353 mouse->xdelta += xrel; |
354 mouse->ydelta += yrel; | |
0 | 355 |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
356 /* Move the mouse cursor, if needed */ |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
357 if (mouse->cursor_shown && !mouse->relative_mode && |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
358 mouse->MoveCursor && mouse->cur_cursor) { |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
359 mouse->MoveCursor(mouse->cur_cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
360 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
361 |
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
|
362 /* 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
|
363 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
|
364 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
|
365 SDL_Event event; |
1670 | 366 event.motion.type = SDL_MOUSEMOTION; |
367 event.motion.which = (Uint8) index; | |
368 event.motion.state = mouse->buttonstate; | |
369 event.motion.x = mouse->x; | |
370 event.motion.y = mouse->y; | |
371 event.motion.xrel = xrel; | |
372 event.motion.yrel = yrel; | |
373 event.motion.windowID = mouse->focus; | |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
374 if ((SDL_EventOK == NULL) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
375 || (*SDL_EventOK) (SDL_EventOKParam, &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
|
376 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
377 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
|
378 } |
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
|
379 } |
1670 | 380 return posted; |
0 | 381 } |
382 | |
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
|
383 int |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
384 SDL_SendMouseButton(int index, Uint8 state, Uint8 button) |
0 | 385 { |
1670 | 386 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
|
387 int posted; |
1670 | 388 Uint8 type; |
0 | 389 |
1670 | 390 if (!mouse) { |
391 return 0; | |
392 } | |
0 | 393 |
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
|
394 /* 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
|
395 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
|
396 case SDL_PRESSED: |
1670 | 397 if (mouse->buttonstate & SDL_BUTTON(button)) { |
398 /* Ignore this event, no state change */ | |
399 return 0; | |
400 } | |
401 type = SDL_MOUSEBUTTONDOWN; | |
402 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
|
403 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
|
404 case SDL_RELEASED: |
1670 | 405 if (!(mouse->buttonstate & SDL_BUTTON(button))) { |
406 /* Ignore this event, no state change */ | |
407 return 0; | |
408 } | |
409 type = SDL_MOUSEBUTTONUP; | |
410 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
|
411 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
|
412 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
|
413 /* Invalid state -- bail */ |
1670 | 414 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
|
415 } |
0 | 416 |
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
|
417 /* 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
|
418 posted = 0; |
1670 | 419 if (SDL_ProcessEvents[type] == SDL_ENABLE) { |
420 SDL_Event event; | |
421 event.type = type; | |
422 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
|
423 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
|
424 event.button.button = button; |
1670 | 425 event.button.x = mouse->x; |
426 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
|
427 event.button.windowID = mouse->focus; |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
428 if ((SDL_EventOK == NULL) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
429 || (*SDL_EventOK) (SDL_EventOKParam, &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
|
430 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
431 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
|
432 } |
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
|
433 } |
1670 | 434 return posted; |
0 | 435 } |
436 | |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
437 int |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
438 SDL_SendMouseWheel(int index, int motion) |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
439 { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
440 SDL_Mouse *mouse = SDL_GetMouse(index); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
441 int posted; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
442 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
443 if (!mouse || !motion) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
444 return 0; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
445 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
446 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
447 /* Post the event, if desired */ |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
448 posted = 0; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
449 if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
450 SDL_Event event; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
451 event.type = SDL_MOUSEWHEEL; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
452 event.wheel.which = (Uint8) index; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
453 event.wheel.motion = motion; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
454 event.wheel.windowID = mouse->focus; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
455 if ((SDL_EventOK == NULL) |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
456 || (*SDL_EventOK) (SDL_EventOKParam, &event)) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
457 posted = 1; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
458 SDL_PushEvent(&event); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
459 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
460 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
461 return posted; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
462 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
463 |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
464 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
465 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
|
466 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
467 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
|
468 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
469 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
470 return; |
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 if (mouse->WarpMouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
474 mouse->WarpMouse(mouse, windowID, x, y); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
475 } else { |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
476 SDL_SetMouseFocus(SDL_current_mouse, windowID); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
477 SDL_SendMouseMotion(SDL_current_mouse, 0, x, y); |
1671
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 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
480 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
481 SDL_Cursor * |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
482 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
|
483 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
|
484 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
485 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
|
486 SDL_Surface *surface; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
487 SDL_Cursor *cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
488 int x, y; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
489 Uint32 *pixel; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
490 Uint8 datab, maskb; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
491 const Uint32 black = 0xFF000000; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
492 const Uint32 white = 0xFFFFFFFF; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
493 const Uint32 transparent = 0x00000000; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
494 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
495 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
496 SDL_SetError("No mice are initialized"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
497 return NULL; |
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 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
500 if (!mouse->CreateCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
501 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
|
502 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
503 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
504 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
505 /* Sanity check the hot spot */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
506 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
|
507 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
|
508 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
509 } |
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 /* 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
|
512 w = ((w + 7) & ~7); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
513 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
514 /* Create the surface from a bitmap */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
515 surface = |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
516 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
|
517 0xFF000000); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
518 if (!surface) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
519 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
520 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
521 for (y = 0; y < h; ++y) { |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1674
diff
changeset
|
522 pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
523 for (x = 0; x < w; ++x) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
524 if ((x % 8) == 0) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
525 datab = *data++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
526 maskb = *mask++; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
527 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
528 if (maskb & 0x80) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
529 *pixel++ = (datab & 0x80) ? black : white; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
530 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
531 *pixel++ = (datab & 0x80) ? black : transparent; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
532 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
533 datab <<= 1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
534 maskb <<= 1; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
535 } |
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 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
538 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
|
539 if (cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
540 cursor->mouse = mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
541 cursor->next = mouse->cursors; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
542 mouse->cursors = cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
543 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
544 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
545 SDL_FreeSurface(surface); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
546 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
547 return cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
548 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
549 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
550 /* 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
|
551 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
|
552 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
|
553 */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
554 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
555 SDL_SetCursor(SDL_Cursor * cursor) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
556 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
557 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
|
558 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
559 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
560 SDL_SetError("No mice are initialized"); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
561 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
562 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
563 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
564 /* Set the new cursor */ |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
565 if (cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
566 /* 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
|
567 SDL_Cursor *found; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
568 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
|
569 if (found == cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
570 break; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
571 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
572 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
573 if (!found) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
574 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
|
575 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
576 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
577 mouse->cur_cursor = cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
578 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
579 cursor = mouse->cur_cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
580 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
581 |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
582 if (cursor && mouse->cursor_shown && !mouse->relative_mode) { |
1671
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
583 if (mouse->ShowCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
584 mouse->ShowCursor(cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
585 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
586 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
587 if (mouse->ShowCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
588 mouse->ShowCursor(NULL); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
589 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
590 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
591 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
592 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
593 SDL_Cursor * |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
594 SDL_GetCursor(void) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
595 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
596 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
|
597 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
598 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
599 return NULL; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
600 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
601 return mouse->cur_cursor; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
602 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
603 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
604 void |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
605 SDL_FreeCursor(SDL_Cursor * cursor) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
606 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
607 SDL_Mouse *mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
608 SDL_Cursor *curr, *prev; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
609 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
610 if (!cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
611 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
612 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
613 mouse = cursor->mouse; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
614 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
615 if (cursor == mouse->def_cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
616 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
617 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
618 if (cursor == mouse->cur_cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
619 SDL_SetCursor(mouse->def_cursor); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
620 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
621 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
622 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
|
623 prev = curr, curr = curr->next) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
624 if (curr == cursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
625 if (prev) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
626 prev->next = curr->next; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
627 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
628 mouse->cursors = curr->next; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
629 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
630 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
631 if (mouse->FreeCursor) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
632 mouse->FreeCursor(curr); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
633 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
634 return; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
635 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
636 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
637 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
638 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
639 int |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
640 SDL_ShowCursor(int toggle) |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
641 { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
642 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
|
643 SDL_bool shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
644 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
645 if (!mouse) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
646 return 0; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
647 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
648 |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
649 shown = mouse->cursor_shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
650 if (toggle >= 0) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
651 if (toggle) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
652 mouse->cursor_shown = SDL_TRUE; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
653 } else { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
654 mouse->cursor_shown = SDL_FALSE; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
655 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
656 if (mouse->cursor_shown != shown) { |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
657 SDL_SetCursor(NULL); |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
658 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
659 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
660 return shown; |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
661 } |
89f7510fe17a
Moved the cursor handling into the mouse code.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
662 |
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
|
663 /* vi: set ts=4 sw=4 expandtab: */ |