File: sdlstub.c

package info (click to toggle)
spring 88.0%2Bdfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 41,524 kB
  • sloc: cpp: 343,114; ansic: 38,414; python: 12,257; java: 12,203; awk: 5,748; sh: 1,204; xml: 997; perl: 405; objc: 192; makefile: 181; php: 134; sed: 2
file content (205 lines) | stat: -rwxr-xr-x 4,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

/*
 * documentation for the functions in this file can be found at:
 * http://www.libsdl.org/docs/html/
 */

#include "SDL.h"


#ifdef __cplusplus
extern "C" {
#endif

// @see sdlstub_cppbit.cpp
int stub_sdl_getSystemMilliSeconds();
void stub_sdl_sleepMilliSeconds(int milliSeconds);


static int startSystemMilliSeconds;
static struct SDL_Surface stubSurface;
static struct SDL_RWops stubRWops;
static Uint8 stubKeyState[0];
static SDL_version stubVersion;
static SDL_VideoInfo stubVideo;
static Uint32 stubSubSystemsInit = 0;

extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags) {

	startSystemMilliSeconds = stub_sdl_getSystemMilliSeconds();

	stubSurface.w = 512;
	stubSurface.h = 512;
	stubVideo.current_w = 512;
	stubVideo.current_h = 512;
	stubSubSystemsInit = SDL_INIT_EVERYTHING;

	return 0;
}

extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags) {
	return (stubSubSystemsInit & flags);
}

extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags) {
	return 0;
}

extern DECLSPEC char* SDLCALL SDL_GetError() {
	return "using the SDL stub library";
}

extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value) {
	return 0;
}

extern DECLSPEC SDL_Surface* SDLCALL SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) {
	return &stubSurface;
}

extern DECLSPEC const SDL_VideoInfo* SDLCALL SDL_GetVideoInfo(void) {
	return &stubVideo;
}

extern DECLSPEC struct SDL_RWops* SDLCALL SDL_RWFromFile(const char* file, const char* mode) {
	return &stubRWops;
}

extern DECLSPEC SDL_Surface* SDLCALL SDL_LoadBMP_RW(SDL_RWops* src, int freesrc) {
	return &stubSurface;
}

extern DECLSPEC void SDLCALL SDL_Quit() {
}

extern DECLSPEC SDL_Surface* SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) {
	return NULL;
}

extern DECLSPEC SDL_Surface* SDLCALL SDL_CreateRGBSurfaceFrom(void* pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) {
	return NULL;
}

extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface* surface) {
}

extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers() {
}

extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms) {
	stub_sdl_sleepMilliSeconds(ms);
}

extern DECLSPEC Uint32 SDLCALL SDL_GetTicks() {
	return stub_sdl_getSystemMilliSeconds() - startSystemMilliSeconds;
}

extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y) {
}

extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow() {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int i) {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int i, int j) {
	return 0;
}

extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod i) {
}

extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event* event) {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event* event) {
	return 0;
}

extern DECLSPEC void SDLCALL SDL_PumpEvents() {
}

extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface* icon, Uint8* mask) {
}

extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char* title, const char* icon) {
}

extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value) {
	*value = 0;
	return 0;
}

extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode) {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_GetWMInfo(void* infostruct) {

	// TODO: probably needs to populate infostruct with something reasonable...

	// I _think_ this triggers SpringApp.cpp to just use the screen geometry
	return 0;
}

extern DECLSPEC Uint8* SDLCALL SDL_GetKeyState(int* numkeys) {
	*numkeys = 0;
	return stubKeyState;
}

extern DECLSPEC SDLMod SDLCALL SDL_GetModState() {
	return 0;
}

extern DECLSPEC const SDL_version* SDLCALL SDL_Linked_Version() {
	return &stubVersion;
}

extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) {
	return 0;
}

extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int* x, int* y) {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue) {
	return 0;
}

extern DECLSPEC int SDLCALL SDL_NumJoysticks() {
	return 0;
}

extern DECLSPEC const char* SDLCALL SDL_JoystickName(int device_index) {
	return "";
}

extern DECLSPEC SDL_Joystick* SDLCALL SDL_JoystickOpen(int device_index) {
	return 0;
}

extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick* joystick) {
}

extern DECLSPEC SDL_Rect** SDLCALL SDL_ListModes(SDL_PixelFormat* format, Uint32 flags) {
	return NULL;
}

extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, Uint32 mask) {
	return 0;
}

extern DECLSPEC Uint8 SDLCALL SDL_GetAppState() {
	return 0;
}

#ifdef __cplusplus
} // extern "C"
#endif