Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_video.c @ 2998:d364ee9b9c15
Date: Sun, 04 Jan 2009 20:53:30 +0100
From: Couriersud
Subject: SDL1.3 DirectFB patches
The attached contains the following directfb changes:
- Dynamic loading of libdirectfb.so. This may to turned off as well in configure
- Use linux-input by default. May be switched off by environment variable.
- Added some code which will use directfb's x11 backend when DISPLAY is set.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2009 23:43:33 +0000 |
parents | 6ce28e5287e9 |
children | 8f4ed5ec2b06 |
comparison
equal
deleted
inserted
replaced
2997:e4f025078c1c | 2998:d364ee9b9c15 |
---|---|
44 #include "SDL_DirectFB_video.h" | 44 #include "SDL_DirectFB_video.h" |
45 #include "SDL_DirectFB_events.h" | 45 #include "SDL_DirectFB_events.h" |
46 #include "SDL_DirectFB_render.h" | 46 #include "SDL_DirectFB_render.h" |
47 #include "SDL_DirectFB_mouse.h" | 47 #include "SDL_DirectFB_mouse.h" |
48 | 48 |
49 #include "SDL_DirectFB_dyn.h" | |
50 | |
49 /* Initialization/Query functions */ | 51 /* Initialization/Query functions */ |
50 static int DirectFB_VideoInit(_THIS); | 52 static int DirectFB_VideoInit(_THIS); |
51 static void DirectFB_VideoQuit(_THIS); | 53 static void DirectFB_VideoQuit(_THIS); |
52 | 54 |
53 static int DirectFB_Available(void); | 55 static int DirectFB_Available(void); |
64 /* DirectFB driver bootstrap functions */ | 66 /* DirectFB driver bootstrap functions */ |
65 | 67 |
66 static int | 68 static int |
67 DirectFB_Available(void) | 69 DirectFB_Available(void) |
68 { | 70 { |
71 if (!SDL_DirectFB_LoadLibrary()) | |
72 return 0; | |
73 SDL_DirectFB_UnLoadLibrary(); | |
69 return 1; | 74 return 1; |
70 } | 75 } |
71 | 76 |
72 static void | 77 static void |
73 DirectFB_DeleteDevice(SDL_VideoDevice * device) | 78 DirectFB_DeleteDevice(SDL_VideoDevice * device) |
74 { | 79 { |
75 SDL_free(device->driverdata); | 80 SDL_DirectFB_UnLoadLibrary(); |
76 SDL_free(device); | 81 SDL_DFB_FREE(device->driverdata); |
82 SDL_DFB_FREE(device); | |
77 } | 83 } |
78 | 84 |
79 static SDL_VideoDevice * | 85 static SDL_VideoDevice * |
80 DirectFB_CreateDevice(int devindex) | 86 DirectFB_CreateDevice(int devindex) |
81 { | 87 { |
82 SDL_VideoDevice *device; | 88 SDL_VideoDevice *device; |
89 | |
90 if (!SDL_DirectFB_LoadLibrary()) | |
91 return NULL; | |
83 | 92 |
84 /* Initialize all variables that we clean on shutdown */ | 93 /* Initialize all variables that we clean on shutdown */ |
85 SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice)); | 94 SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice)); |
86 | 95 |
87 /* Set the function pointers */ | 96 /* Set the function pointers */ |
138 | 147 |
139 static int | 148 static int |
140 DirectFB_VideoInit(_THIS) | 149 DirectFB_VideoInit(_THIS) |
141 { | 150 { |
142 IDirectFB *dfb = NULL; | 151 IDirectFB *dfb = NULL; |
143 DFB_DeviceData *devdata; | 152 DFB_DeviceData *devdata = NULL; |
144 char *stemp; | 153 char *stemp; |
145 DFBResult ret; | 154 DFBResult ret; |
146 | 155 |
156 SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); | |
157 | |
147 SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); | 158 SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); |
159 | |
160 /* avoid switching to the framebuffer when we | |
161 * are running X11 */ | |
162 stemp = getenv(DFBENV_USE_X11_CHECK); | |
163 if (stemp) | |
164 ret = atoi(stemp); | |
165 else | |
166 ret = 1; | |
167 | |
168 if (ret) { | |
169 if (getenv("DISPLAY")) | |
170 DirectFBSetOption("system", "x11"); | |
171 else | |
172 DirectFBSetOption("disable-module", "x11input"); | |
173 } | |
174 | |
175 devdata->use_linux_input = 1; /* default: on */ | |
176 stemp = getenv(DFBENV_USE_LINUX_INPUT); | |
177 if (stemp) | |
178 devdata->use_linux_input = atoi(stemp); | |
179 | |
180 if (!devdata->use_linux_input) | |
181 DirectFBSetOption("disable-module", "linux_input"); | |
182 | |
148 SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); | 183 SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); |
149 | |
150 SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); | |
151 | 184 |
152 devdata->use_yuv_underlays = 0; /* default: off */ | 185 devdata->use_yuv_underlays = 0; /* default: off */ |
153 stemp = getenv(DFBENV_USE_YUV_UNDERLAY); | 186 stemp = getenv(DFBENV_USE_YUV_UNDERLAY); |
154 if (stemp) | 187 if (stemp) |
155 devdata->use_yuv_underlays = atoi(stemp); | 188 devdata->use_yuv_underlays = atoi(stemp); |
156 | 189 |
190 | |
157 /* Create global Eventbuffer for axis events */ | 191 /* Create global Eventbuffer for axis events */ |
158 if (LINUX_INPUT_SUPPORT) { | 192 if (devdata->use_linux_input) { |
159 SDL_DFB_CHECKERR(dfb-> | 193 SDL_DFB_CHECKERR(dfb-> |
160 CreateInputEventBuffer(dfb, DICAPS_ALL, | 194 CreateInputEventBuffer(dfb, DICAPS_ALL, |
161 DFB_TRUE, &devdata->events)); | 195 DFB_TRUE, &devdata->events)); |
162 } else { | 196 } else { |
163 SDL_DFB_CHECKERR(dfb-> | 197 SDL_DFB_CHECKERR(dfb-> |
185 | 219 |
186 return 0; | 220 return 0; |
187 | 221 |
188 | 222 |
189 error: | 223 error: |
224 SDL_DFB_FREE(devdata); | |
190 SDL_DFB_RELEASE(dfb); | 225 SDL_DFB_RELEASE(dfb); |
191 return -1; | 226 return -1; |
192 } | 227 } |
193 | 228 |
194 static void | 229 static void |
200 DirectFB_QuitKeyboard(_this); | 235 DirectFB_QuitKeyboard(_this); |
201 DirectFB_QuitMouse(_this); | 236 DirectFB_QuitMouse(_this); |
202 | 237 |
203 SDL_DFB_RELEASE(devdata->events); | 238 SDL_DFB_RELEASE(devdata->events); |
204 SDL_DFB_RELEASE(devdata->dfb); | 239 SDL_DFB_RELEASE(devdata->dfb); |
205 SDL_DFB_FREE(_this->driverdata); | |
206 | 240 |
207 #if SDL_DIRECTFB_OPENGL | 241 #if SDL_DIRECTFB_OPENGL |
208 DirectFB_GL_Shutdown(_this); | 242 DirectFB_GL_Shutdown(_this); |
209 #endif | 243 #endif |
210 | 244 |