204 |
|
|
205 |
|
|
206 |
|
/* |
207 |
+ |
* Windows message handler |
208 |
+ |
*/ |
209 |
+ |
|
210 |
+ |
#ifdef WIN32 |
211 |
+ |
#include <dbt.h> |
212 |
+ |
static WNDPROC sdl_window_proc = NULL; // Window proc used by SDL |
213 |
+ |
|
214 |
+ |
extern void SysMediaArrived(void); |
215 |
+ |
extern void SysMediaRemoved(void); |
216 |
+ |
extern HWND GetMainWindowHandle(void); |
217 |
+ |
|
218 |
+ |
static LRESULT CALLBACK windows_message_handler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
219 |
+ |
{ |
220 |
+ |
switch (msg) { |
221 |
+ |
case WM_DEVICECHANGE: |
222 |
+ |
if (wParam == DBT_DEVICEREMOVECOMPLETE) { |
223 |
+ |
DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam; |
224 |
+ |
if (p->dbch_devicetype == DBT_DEVTYP_VOLUME) |
225 |
+ |
SysMediaRemoved(); |
226 |
+ |
} |
227 |
+ |
else if (wParam == DBT_DEVICEARRIVAL) { |
228 |
+ |
DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam; |
229 |
+ |
if (p->dbch_devicetype == DBT_DEVTYP_VOLUME) |
230 |
+ |
SysMediaArrived(); |
231 |
+ |
} |
232 |
+ |
return 0; |
233 |
+ |
|
234 |
+ |
default: |
235 |
+ |
if (sdl_window_proc) |
236 |
+ |
return CallWindowProc(sdl_window_proc, hwnd, msg, wParam, lParam); |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
return DefWindowProc(hwnd, msg, wParam, lParam); |
240 |
+ |
} |
241 |
+ |
#endif |
242 |
+ |
|
243 |
+ |
|
244 |
+ |
/* |
245 |
|
* SheepShaver glue |
246 |
|
*/ |
247 |
|
|
1063 |
|
return false; |
1064 |
|
} |
1065 |
|
|
1066 |
+ |
#ifdef WIN32 |
1067 |
+ |
// Chain in a new message handler for WM_DEVICECHANGE |
1068 |
+ |
HWND the_window = GetMainWindowHandle(); |
1069 |
+ |
sdl_window_proc = (WNDPROC)GetWindowLongPtr(the_window, GWLP_WNDPROC); |
1070 |
+ |
SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)windows_message_handler); |
1071 |
+ |
#endif |
1072 |
+ |
|
1073 |
|
// Initialize VideoRefresh function |
1074 |
|
VideoRefreshInit(); |
1075 |
|
|
1304 |
|
{ |
1305 |
|
D(bug("video_close()\n")); |
1306 |
|
|
1307 |
+ |
#ifdef WIN32 |
1308 |
+ |
// Remove message handler for WM_DEVICECHANGE |
1309 |
+ |
HWND the_window = GetMainWindowHandle(); |
1310 |
+ |
SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)sdl_window_proc); |
1311 |
+ |
#endif |
1312 |
+ |
|
1313 |
|
// Stop redraw thread |
1314 |
|
#ifndef USE_CPU_EMUL_SERVICES |
1315 |
|
if (redraw_thread_active) { |