Mercurial > sdl-ios-xcode
annotate src/SDL.c @ 2472:3f73c88c9abb gsoc2008_force_feedback
First commit of the SDL_haptic subsystem.
Code compiles and works, very limited functionality (linux only).
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 01 Jun 2008 11:44:25 +0000 |
parents | 8f1ab2f7c722 |
children | 64fa227c01ce |
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:
1190
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:
1190
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:
1190
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:
1190
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:
1190
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:
1190
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:
1190
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:
36
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 /* Initialization code for SDL */ | |
25 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 #include "SDL.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
27 #include "SDL_fatal.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
28 #if !SDL_VIDEO_DISABLED |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
29 #include "video/SDL_leaks.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
30 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #if SDL_THREAD_PTH |
557
0ce5a68278fd
Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
33 #include <pth.h> |
0ce5a68278fd
Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
34 #endif |
0 | 35 |
36 /* Initialization/Cleanup routines */ | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
37 #if !SDL_JOYSTICK_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
38 extern int SDL_JoystickInit(void); |
0 | 39 extern void SDL_JoystickQuit(void); |
40 #endif | |
2472
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
41 #if !SDL_HAPTIC_DISABLED |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
42 extern int SDL_HapticInit(void); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
43 extern int SDL_HapticQuit(void); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
44 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
45 #if !SDL_CDROM_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
46 extern int SDL_CDROMInit(void); |
0 | 47 extern void SDL_CDROMQuit(void); |
48 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
49 #if !SDL_TIMERS_DISABLED |
0 | 50 extern void SDL_StartTicks(void); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
51 extern int SDL_TimerInit(void); |
0 | 52 extern void SDL_TimerQuit(void); |
53 #endif | |
54 | |
55 /* The initialized subsystems */ | |
56 static Uint32 SDL_initialized = 0; | |
57 static Uint32 ticks_started = 0; | |
58 | |
59 #ifdef CHECK_LEAKS | |
60 int surfaces_allocated = 0; | |
61 #endif | |
62 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
63 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
64 SDL_InitSubSystem(Uint32 flags) |
0 | 65 { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
66 #if !SDL_VIDEO_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
67 /* Initialize the video/event subsystem */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
68 if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) { |
1909
8f1ab2f7c722
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
69 if (SDL_VideoInit(NULL, (flags & SDL_INIT_EVENTTHREAD)) < 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
70 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
71 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
72 SDL_initialized |= SDL_INIT_VIDEO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
73 } |
0 | 74 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
75 if (flags & SDL_INIT_VIDEO) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
76 SDL_SetError("SDL not built with video support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
77 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
78 } |
0 | 79 #endif |
80 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
81 #if !SDL_AUDIO_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
82 /* Initialize the audio subsystem */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
83 if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) { |
1909
8f1ab2f7c722
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
84 if (SDL_AudioInit(NULL) < 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
85 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
86 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
87 SDL_initialized |= SDL_INIT_AUDIO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
88 } |
0 | 89 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
90 if (flags & SDL_INIT_AUDIO) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
91 SDL_SetError("SDL not built with audio support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
92 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
93 } |
0 | 94 #endif |
95 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
96 #if !SDL_TIMERS_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
97 /* Initialize the timer subsystem */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
98 if (!ticks_started) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
99 SDL_StartTicks(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
100 ticks_started = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
101 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
102 if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
103 if (SDL_TimerInit() < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
104 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
105 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
106 SDL_initialized |= SDL_INIT_TIMER; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
107 } |
0 | 108 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
109 if (flags & SDL_INIT_TIMER) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
110 SDL_SetError("SDL not built with timer support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
111 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
112 } |
0 | 113 #endif |
114 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
115 #if !SDL_JOYSTICK_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
116 /* Initialize the joystick subsystem */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
117 if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
118 if (SDL_JoystickInit() < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
119 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
120 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
121 SDL_initialized |= SDL_INIT_JOYSTICK; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
122 } |
0 | 123 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
124 if (flags & SDL_INIT_JOYSTICK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
125 SDL_SetError("SDL not built with joystick support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
126 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
127 } |
0 | 128 #endif |
129 | |
2472
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
130 #if !SDL_HAPTIC_DISABLED |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
131 /* Initialize the haptic subsystem */ |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
132 if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) { |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
133 if (SDL_HapticInit() < 0) { |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
134 return (-1); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
135 } |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
136 SDL_initialized |= SDL_INIT_HAPTIC; |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
137 } |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
138 #else |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
139 if (flags & SDL_INIT_HAPTIC) { |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
140 SDL_SetError("SDL not built with haptic (force feedback) support"); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
141 return (-1); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
142 } |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
143 #endif |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
144 |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
145 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
146 #if !SDL_CDROM_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
147 /* Initialize the CD-ROM subsystem */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
148 if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
149 if (SDL_CDROMInit() < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
150 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
151 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
152 SDL_initialized |= SDL_INIT_CDROM; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
153 } |
0 | 154 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
155 if (flags & SDL_INIT_CDROM) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
156 SDL_SetError("SDL not built with cdrom support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
157 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
158 } |
0 | 159 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
160 return (0); |
0 | 161 } |
162 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
163 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
164 SDL_Init(Uint32 flags) |
0 | 165 { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
166 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
167 if (!pth_init()) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
168 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
169 } |
397 | 170 #endif |
171 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
172 /* Clear the error message */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
173 SDL_ClearError(); |
0 | 174 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
175 /* Initialize the desired subsystems */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
176 if (SDL_InitSubSystem(flags) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
177 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
178 } |
0 | 179 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
180 /* Everything is initialized */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
181 if (!(flags & SDL_INIT_NOPARACHUTE)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
182 SDL_InstallParachute(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
183 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
184 return (0); |
0 | 185 } |
186 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
187 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
188 SDL_QuitSubSystem(Uint32 flags) |
0 | 189 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
190 /* Shut down requested initialized subsystems */ |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
191 #if !SDL_CDROM_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
192 if ((flags & SDL_initialized & SDL_INIT_CDROM)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
193 SDL_CDROMQuit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
194 SDL_initialized &= ~SDL_INIT_CDROM; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
195 } |
0 | 196 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
197 #if !SDL_JOYSTICK_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
198 if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
199 SDL_JoystickQuit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
200 SDL_initialized &= ~SDL_INIT_JOYSTICK; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
201 } |
0 | 202 #endif |
2472
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
203 #if !SDL_HAPTIC_DISABLED |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
204 if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) { |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
205 SDL_HapticQuit(); |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
206 SDL_initialized &= ~SDL_INIT_HAPTIC; |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
207 } |
3f73c88c9abb
First commit of the SDL_haptic subsystem.
Edgar Simo <bobbens@gmail.com>
parents:
1909
diff
changeset
|
208 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
209 #if !SDL_TIMERS_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
210 if ((flags & SDL_initialized & SDL_INIT_TIMER)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
211 SDL_TimerQuit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
212 SDL_initialized &= ~SDL_INIT_TIMER; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
213 } |
0 | 214 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
215 #if !SDL_AUDIO_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
216 if ((flags & SDL_initialized & SDL_INIT_AUDIO)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
217 SDL_AudioQuit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
218 SDL_initialized &= ~SDL_INIT_AUDIO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
219 } |
0 | 220 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
221 #if !SDL_VIDEO_DISABLED |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
222 if ((flags & SDL_initialized & SDL_INIT_VIDEO)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
223 SDL_VideoQuit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
224 SDL_initialized &= ~SDL_INIT_VIDEO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
225 } |
0 | 226 #endif |
227 } | |
228 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
229 Uint32 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
230 SDL_WasInit(Uint32 flags) |
0 | 231 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
232 if (!flags) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
233 flags = SDL_INIT_EVERYTHING; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
234 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
235 return (SDL_initialized & flags); |
0 | 236 } |
237 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
238 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
239 SDL_Quit(void) |
0 | 240 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
241 /* Quit all subsystems */ |
1190 | 242 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
243 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
244 fflush(stdout); |
1190 | 245 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
246 SDL_QuitSubSystem(SDL_INIT_EVERYTHING); |
0 | 247 |
248 #ifdef CHECK_LEAKS | |
1190 | 249 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
250 printf("[SDL_Quit] : CHECK_LEAKS\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
251 fflush(stdout); |
1190 | 252 #endif |
253 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
254 /* Print the number of surfaces not freed */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
255 if (surfaces_allocated != 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
256 fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
257 surfaces_allocated); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
258 } |
0 | 259 #endif |
1190 | 260 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
261 printf("[SDL_Quit] : SDL_UninstallParachute()\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
262 fflush(stdout); |
1190 | 263 #endif |
0 | 264 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
265 /* Uninstall any parachute signal handlers */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
266 SDL_UninstallParachute(); |
397 | 267 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
268 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
269 pth_kill(); |
397 | 270 #endif |
1190 | 271 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
272 printf("[SDL_Quit] : Returning!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
273 fflush(stdout); |
1190 | 274 #endif |
275 | |
0 | 276 } |
277 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
278 /* Get the library version number */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
279 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
280 SDL_GetVersion(SDL_version * ver) |
0 | 281 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
282 SDL_VERSION(ver); |
0 | 283 } |
284 | |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
285 #if defined(__OS2__) |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
286 /* Building for OS/2 */ |
1190 | 287 #ifdef __WATCOMC__ |
288 | |
289 #define INCL_DOSERRORS | |
290 #define INCL_DOSEXCEPTIONS | |
291 #include <os2.h> | |
292 | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
293 /* Exception handler to prevent the Audio thread hanging, making a zombie process! */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
294 ULONG _System |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
295 SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
296 PEXCEPTIONREGISTRATIONRECORD pERegRec, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
297 PCONTEXTRECORD pCtxRec, PVOID p) |
1190 | 298 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
299 if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
300 return XCPT_CONTINUE_SEARCH; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
301 if (pERepRec->fHandlerFlags & EH_UNWINDING) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
302 return XCPT_CONTINUE_SEARCH; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
303 if (pERepRec->fHandlerFlags & EH_NESTED_CALL) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
304 return XCPT_CONTINUE_SEARCH; |
1190 | 305 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
306 /* Do cleanup at every fatal exception! */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
307 if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
308 XCPT_FATAL_EXCEPTION) && (pERepRec->ExceptionNum != XCPT_BREAKPOINT) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
309 && (pERepRec->ExceptionNum != XCPT_SINGLE_STEP)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
310 if (SDL_initialized & SDL_INIT_AUDIO) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
311 /* This removes the zombie audio thread in case of emergency. */ |
1190 | 312 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
313 printf |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
314 ("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n"); |
1190 | 315 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
316 SDL_CloseAudio(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
317 } |
1190 | 318 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
319 return (XCPT_CONTINUE_SEARCH); |
1190 | 320 } |
321 | |
322 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
323 EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
324 { 0, SDL_Main_ExceptionHandler }; |
1190 | 325 |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
326 /* The main DLL entry for DLL Initialization and Uninitialization: */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
327 unsigned _System |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
328 LibMain(unsigned hmod, unsigned termination) |
1190 | 329 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
330 if (termination) { |
1190 | 331 #ifdef DEBUG_BUILD |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
332 /* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */ |
1190 | 333 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
334 DosUnsetExceptionHandler(&SDL_Main_xcpthand); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
335 return 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
336 } else { |
1190 | 337 #ifdef DEBUG_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
338 /* Make stdout and stderr unbuffered! */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
339 setbuf(stdout, NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
340 setbuf(stderr, NULL); |
1190 | 341 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
342 /* Fire up exception handler */ |
1190 | 343 #ifdef DEBUG_BUILD |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
344 /* printf("[SDL DLL Initialization] : Setting exception handler\n"); */ |
1190 | 345 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
346 /* Set exception handler */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
347 DosSetExceptionHandler(&SDL_Main_xcpthand); |
1190 | 348 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
349 return 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
350 } |
1190 | 351 } |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
352 #endif /* __WATCOMC__ */ |
1190 | 353 |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
354 #elif defined(__WIN32__) |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
355 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
356 #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
357 /* Need to include DllMain() on Watcom C for some reason.. */ |
1433
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
358 #define WIN32_LEAN_AND_MEAN |
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
359 #include <windows.h> |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
360 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
361 BOOL APIENTRY |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
362 _DllMainCRTStartup(HANDLE hModule, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
363 DWORD ul_reason_for_call, LPVOID lpReserved) |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
364 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
365 switch (ul_reason_for_call) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
366 case DLL_PROCESS_ATTACH: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
367 case DLL_THREAD_ATTACH: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
368 case DLL_THREAD_DETACH: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
369 case DLL_PROCESS_DETACH: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
370 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
371 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
372 return TRUE; |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
373 } |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
374 #endif /* building DLL with Watcom C */ |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
375 |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
376 #endif /* OS/2 elif __WIN32__ */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
377 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1487
diff
changeset
|
378 /* vi: set ts=4 sw=4 expandtab: */ |