VIDEO: Remove support for libSDL (prior to libSDL2)
All interesting simh host platforms have long supported libSDL2 functionality which wasn't the case when sim_video was initially implemented. The mixed API set significantly complicates maintaining and extending sim_video, hence this explicit effort to remove the vestiges of the old libSDL API.
This commit is contained in:
parent
f8a1e56637
commit
0f992e1db7
2 changed files with 13 additions and 315 deletions
10
makefile
10
makefile
|
@ -1939,13 +1939,11 @@ ifneq (,$(BESM6_BUILD))
|
|||
endif
|
||||
else
|
||||
ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,apt-get)))
|
||||
$(info *** Info *** Install the development components of libSDL-ttf or libSDL2-ttf)
|
||||
$(info *** Info *** Install the development components of libSDL2-ttf)
|
||||
$(info *** Info *** packaged for your Linux operating system distribution:)
|
||||
$(info *** Info *** $$ sudo apt-get install libsdl2-ttf-dev)
|
||||
$(info *** Info *** or)
|
||||
$(info *** Info *** $$ sudo apt-get install libsdl-ttf-dev)
|
||||
else
|
||||
$(info *** Info *** Install the development components of libSDL-ttf packaged by your)
|
||||
$(info *** Info *** Install the development components of libSDL2-ttf packaged by your)
|
||||
$(info *** Info *** operating system distribution and rebuild your simulator to)
|
||||
$(info *** Info *** enable this extra functionality.)
|
||||
endif
|
||||
|
@ -1955,10 +1953,6 @@ ifneq (,$(BESM6_BUILD))
|
|||
$(info using libSDL2_ttf: $(call find_lib,SDL2_ttf) $(call find_include,SDL2/SDL_ttf))
|
||||
$(info ***)
|
||||
BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL2_ttf
|
||||
else ifneq (,$(and $(call find_include,SDL/SDL_ttf),$(call find_lib,SDL_ttf)))
|
||||
$(info using libSDL_ttf: $(call find_lib,SDL_ttf) $(call find_include,SDL/SDL_ttf))
|
||||
$(info ***)
|
||||
BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL_ttf
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
318
sim_video.c
318
sim_video.c
|
@ -341,18 +341,6 @@ void vid_show_video_event (void);
|
|||
void vid_screenshot_event (void);
|
||||
void vid_beep_event (void);
|
||||
|
||||
/*
|
||||
libSDL and libSDL2 have significantly different APIs.
|
||||
The consequence is that this code has significant #ifdef sections.
|
||||
|
||||
The current structure is to implement the API differences in each
|
||||
routine that has a difference. This allows the decision and flow
|
||||
logic to exist once and thus to allow logic changes to be implemented
|
||||
in one place.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
t_bool vid_mouse_captured;
|
||||
int32 vid_flags; /* Open Flags */
|
||||
int32 vid_width;
|
||||
|
@ -361,49 +349,12 @@ t_bool vid_ready;
|
|||
char vid_title[128];
|
||||
static void vid_beep_setup (int duration_ms, int tone_frequency);
|
||||
static void vid_beep_cleanup (void);
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
|
||||
/*
|
||||
Some platforms that use X11 display technology have libSDL
|
||||
environments which need to call XInitThreads when libSDL is used
|
||||
in multi-threaded programs. This routine attempts to locate
|
||||
the X11 shareable library and if it is found loads it and calls
|
||||
the XInitThreads routine to meet this requirement.
|
||||
*/
|
||||
#ifdef HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
static void _XInitThreads (void)
|
||||
{
|
||||
#ifdef HAVE_DLOPEN
|
||||
static void *hLib = NULL; /* handle to Library */
|
||||
#define __STR_QUOTE(tok) #tok
|
||||
#define __STR(tok) __STR_QUOTE(tok)
|
||||
static const char* lib_name = "libX11." __STR(HAVE_DLOPEN);
|
||||
typedef int (*_func)();
|
||||
_func _func_ptr = NULL;
|
||||
|
||||
if (!hLib)
|
||||
hLib = dlopen(lib_name, RTLD_NOW);
|
||||
if (hLib)
|
||||
_func_ptr = (_func)((size_t)dlsym(hLib, "XInitThreads"));
|
||||
if (_func_ptr)
|
||||
_func_ptr();
|
||||
#endif
|
||||
}
|
||||
|
||||
t_bool vid_key_state[SDLK_LAST];
|
||||
SDL_Surface *vid_image; /* video buffer */
|
||||
SDL_Surface *vid_window; /* window handle */
|
||||
#else
|
||||
t_bool vid_key_state[SDL_NUM_SCANCODES];
|
||||
SDL_Texture *vid_texture; /* video buffer in GPU */
|
||||
SDL_Renderer *vid_renderer;
|
||||
SDL_Window *vid_window; /* window handle */
|
||||
SDL_PixelFormat *vid_format;
|
||||
uint32 vid_windowID;
|
||||
#endif
|
||||
SDL_Thread *vid_thread_handle = NULL; /* event thread handle */
|
||||
SDL_Cursor *vid_cursor = NULL; /* current cursor */
|
||||
t_bool vid_cursor_visible = FALSE; /* cursor visibility state */
|
||||
|
@ -443,18 +394,11 @@ int status;
|
|||
main_argc = argc;
|
||||
main_argv = argv;
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
_XInitThreads();
|
||||
status = SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE);
|
||||
|
||||
vid_main_thread_handle = SDL_CreateThread (main_thread , NULL);
|
||||
#else
|
||||
SDL_SetHint (SDL_HINT_RENDER_DRIVER, "software");
|
||||
|
||||
status = SDL_Init (SDL_INIT_VIDEO);
|
||||
|
||||
vid_main_thread_handle = SDL_CreateThread (main_thread , "simh-main", NULL);
|
||||
#endif
|
||||
|
||||
if (status) {
|
||||
fprintf (stderr, "SDL Video subsystem can't initialize\n");
|
||||
|
@ -530,11 +474,7 @@ static int vid_create_window ()
|
|||
{
|
||||
int wait_count = 0;
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
vid_thread_handle = SDL_CreateThread (vid_thread, NULL);
|
||||
#else
|
||||
vid_thread_handle = SDL_CreateThread (vid_thread, "vid-thread", NULL);
|
||||
#endif
|
||||
if (vid_thread_handle == NULL) {
|
||||
vid_close ();
|
||||
return SCPE_OPENERR;
|
||||
|
@ -751,26 +691,11 @@ return stat;
|
|||
|
||||
uint32 vid_map_rgb (uint8 r, uint8 g, uint8 b)
|
||||
{
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
return SDL_MapRGB (vid_image->format, r, g, b);
|
||||
#else
|
||||
return SDL_MapRGB (vid_format, r, g, b);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vid_draw (int32 x, int32 y, int32 w, int32 h, uint32 *buf)
|
||||
{
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
int32 i;
|
||||
uint32* pixels;
|
||||
|
||||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "vid_draw(%d, %d, %d, %d)\n", x, y, w, h);
|
||||
|
||||
pixels = (uint32 *)vid_image->pixels;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
memcpy (pixels + ((i + y) * vid_width) + x, buf + w*i, w*sizeof(*pixels));
|
||||
#else
|
||||
SDL_Event user_event;
|
||||
SDL_Rect *vid_dst;
|
||||
uint32 *vid_data;
|
||||
|
@ -802,7 +727,6 @@ if (SDL_PushEvent (&user_event) < 0) {
|
|||
free (vid_dst);
|
||||
free (vid_data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
t_stat vid_set_cursor (t_bool visible, uint32 width, uint32 height, uint8 *data, uint8 *mask, uint32 hot_x, uint32 hot_y)
|
||||
|
@ -1065,37 +989,6 @@ switch (key) {
|
|||
|
||||
case SDLK_DELETE:
|
||||
return SIM_KEY_DELETE;
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
case SDLK_KP0:
|
||||
return SIM_KEY_KP_INSERT;
|
||||
|
||||
case SDLK_KP1:
|
||||
return SIM_KEY_KP_END;
|
||||
|
||||
case SDLK_KP2:
|
||||
return SIM_KEY_KP_DOWN;
|
||||
|
||||
case SDLK_KP3:
|
||||
return SIM_KEY_KP_PAGE_DOWN;
|
||||
|
||||
case SDLK_KP4:
|
||||
return SIM_KEY_KP_LEFT;
|
||||
|
||||
case SDLK_KP5:
|
||||
return SIM_KEY_KP_5;
|
||||
|
||||
case SDLK_KP6:
|
||||
return SIM_KEY_KP_RIGHT;
|
||||
|
||||
case SDLK_KP7:
|
||||
return SIM_KEY_KP_HOME;
|
||||
|
||||
case SDLK_KP8:
|
||||
return SIM_KEY_KP_UP;
|
||||
|
||||
case SDLK_KP9:
|
||||
return SIM_KEY_KP_PAGE_UP;
|
||||
#else
|
||||
case SDLK_KP_0:
|
||||
return SIM_KEY_KP_INSERT;
|
||||
|
||||
|
@ -1125,7 +1018,7 @@ switch (key) {
|
|||
|
||||
case SDLK_KP_9:
|
||||
return SIM_KEY_KP_PAGE_UP;
|
||||
#endif
|
||||
|
||||
case SDLK_KP_PERIOD:
|
||||
return SIM_KEY_KP_DELETE;
|
||||
|
||||
|
@ -1206,19 +1099,16 @@ switch (key) {
|
|||
|
||||
case SDLK_F12:
|
||||
return SIM_KEY_F12;
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
|
||||
case SDLK_NUMLOCKCLEAR:
|
||||
return SIM_KEY_NUM_LOCK;
|
||||
#endif
|
||||
|
||||
case SDLK_CAPSLOCK:
|
||||
return SIM_KEY_CAPS_LOCK;
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
case SDLK_SCROLLOCK:
|
||||
return SIM_KEY_SCRL_LOCK;
|
||||
#else
|
||||
|
||||
case SDLK_SCROLLLOCK:
|
||||
return SIM_KEY_SCRL_LOCK;
|
||||
#endif
|
||||
|
||||
case SDLK_RSHIFT:
|
||||
return SIM_KEY_SHIFT_R;
|
||||
|
||||
|
@ -1236,26 +1126,16 @@ switch (key) {
|
|||
|
||||
case SDLK_LALT:
|
||||
return SIM_KEY_ALT_L;
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
case SDLK_RMETA:
|
||||
return SIM_KEY_ALT_R;
|
||||
|
||||
case SDLK_LMETA:
|
||||
return SIM_KEY_WIN_L;
|
||||
#else
|
||||
case SDLK_LGUI:
|
||||
return SIM_KEY_WIN_L;
|
||||
|
||||
case SDLK_RGUI:
|
||||
return SIM_KEY_WIN_R;
|
||||
#endif
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
case SDLK_PRINT:
|
||||
return SIM_KEY_PRINT;
|
||||
#else
|
||||
|
||||
case SDLK_PRINTSCREEN:
|
||||
return SIM_KEY_PRINT;
|
||||
#endif
|
||||
|
||||
case SDLK_PAUSE:
|
||||
return SIM_KEY_PAUSE;
|
||||
|
||||
|
@ -1331,29 +1211,14 @@ if (vid_mouse_captured) {
|
|||
static int numkeys;
|
||||
|
||||
if (!KeyStates)
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
KeyStates = SDL_GetKeyState(&numkeys);
|
||||
if ((vid_flags & SIM_VID_INPUTCAPTURED) &&
|
||||
(event->state == SDL_PRESSED) &&
|
||||
KeyStates[SDLK_RSHIFT] &&
|
||||
(KeyStates[SDLK_LCTRL] || KeyStates[SDLK_RCTRL])) {
|
||||
#else
|
||||
KeyStates = SDL_GetKeyboardState(&numkeys);
|
||||
if ((vid_flags & SIM_VID_INPUTCAPTURED) &&
|
||||
(event->state == SDL_PRESSED) &&
|
||||
KeyStates[SDL_SCANCODE_RSHIFT] &&
|
||||
(KeyStates[SDL_SCANCODE_LCTRL] || KeyStates[SDL_SCANCODE_RCTRL])) {
|
||||
#endif
|
||||
sim_debug (SIM_VID_DBG_KEY, vid_dev, "vid_key() - Cursor Release\n");
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (SDL_WM_GrabInput (SDL_GRAB_OFF) < 0) /* relese cursor */
|
||||
sim_printf ("%s: vid_key(): SDL_WM_GrabInput error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
if (SDL_ShowCursor (SDL_ENABLE) < 0) /* show cursor */
|
||||
sim_printf ("%s: vid_key(): SDL_ShowCursor error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
#else
|
||||
if (SDL_SetRelativeMouseMode(SDL_FALSE) < 0) /* release cursor, show cursor */
|
||||
sim_printf ("%s: vid_key(): SDL_SetRelativeMouseMode error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
#endif
|
||||
vid_mouse_captured = FALSE;
|
||||
return;
|
||||
}
|
||||
|
@ -1365,24 +1230,15 @@ if (SDL_SemWait (vid_key_events.sem) == 0) {
|
|||
ev.key = vid_map_key (event->keysym.sym);
|
||||
sim_debug (SIM_VID_DBG_KEY, vid_dev, "Keyboard Event: State: %s, Keysym(scancode,sym): (%d,%d) - %s\n", (event->state == SDL_PRESSED) ? "PRESSED" : "RELEASED", event->keysym.scancode, event->keysym.sym, vid_key_name(ev.key));
|
||||
if (event->state == SDL_PRESSED) {
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (!vid_key_state[event->keysym.sym]) { /* Key was not down before */
|
||||
vid_key_state[event->keysym.sym] = TRUE;
|
||||
#else
|
||||
if (!vid_key_state[event->keysym.scancode]) {/* Key was not down before */
|
||||
vid_key_state[event->keysym.scancode] = TRUE;
|
||||
#endif
|
||||
ev.state = SIM_KEYPRESS_DOWN;
|
||||
}
|
||||
else
|
||||
ev.state = SIM_KEYPRESS_REPEAT;
|
||||
}
|
||||
else {
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
vid_key_state[event->keysym.sym] = FALSE;
|
||||
#else
|
||||
vid_key_state[event->keysym.scancode] = FALSE;
|
||||
#endif
|
||||
ev.state = SIM_KEYPRESS_UP;
|
||||
}
|
||||
vid_key_events.events[vid_key_events.tail++] = ev;
|
||||
|
@ -1413,11 +1269,7 @@ if (!vid_cursor_visible)
|
|||
return;
|
||||
sim_debug (SIM_VID_DBG_MOUSE, vid_dev, "Mouse Move Event: pos:(%d,%d) rel:(%d,%d) buttons:(%d,%d,%d)\n",
|
||||
event->x, event->y, event->xrel, event->yrel, (event->state & SDL_BUTTON(SDL_BUTTON_LEFT)) ? 1 : 0, (event->state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) ? 1 : 0, (event->state & SDL_BUTTON(SDL_BUTTON_RIGHT)) ? 1 : 0);
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
while (SDL_PeepEvents (&dummy_event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK)) {
|
||||
#else
|
||||
while (SDL_PeepEvents (&dummy_event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION)) {
|
||||
#endif
|
||||
/* Coalesce motion activity to avoid thrashing */
|
||||
event->xrel += dev->xrel;
|
||||
event->yrel += dev->yrel;
|
||||
|
@ -1483,19 +1335,11 @@ if ((!vid_mouse_captured) && (vid_flags & SIM_VID_INPUTCAPTURED)) {
|
|||
if ((event->state == SDL_PRESSED) &&
|
||||
(event->button == SDL_BUTTON_LEFT)) { /* left click and cursor not captured? */
|
||||
sim_debug (SIM_VID_DBG_KEY, vid_dev, "vid_mouse_button() - Cursor Captured\n");
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
SDL_WM_GrabInput (SDL_GRAB_ON); /* lock cursor to window */
|
||||
SDL_ShowCursor (SDL_DISABLE); /* hide cursor */
|
||||
SDL_WarpMouse (vid_width/2, vid_height/2); /* back to center */
|
||||
SDL_PumpEvents ();
|
||||
while (SDL_PeepEvents (&dummy_event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK)) {};
|
||||
#else
|
||||
if (SDL_SetRelativeMouseMode (SDL_TRUE) < 0) /* lock cursor to window, hide cursor */
|
||||
sim_printf ("%s: vid_mouse_button(): SDL_SetRelativeMouseMode error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
SDL_WarpMouseInWindow (NULL, vid_width/2, vid_height/2);/* back to center */
|
||||
SDL_PumpEvents ();
|
||||
while (SDL_PeepEvents (&dummy_event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION)) {};
|
||||
#endif
|
||||
vid_mouse_captured = TRUE;
|
||||
}
|
||||
return;
|
||||
|
@ -1549,17 +1393,11 @@ vid_dst.h = vid_height;
|
|||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Video Update Event: \n");
|
||||
if (sim_deb)
|
||||
fflush (sim_deb);
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (SDL_BlitSurface (vid_image, NULL, vid_window, &vid_dst) < 0)
|
||||
sim_printf ("%s: vid_update(): SDL_BlitSurface error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
SDL_UpdateRects (vid_window, 1, &vid_dst);
|
||||
#else
|
||||
if (SDL_RenderClear (vid_renderer))
|
||||
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
if (SDL_RenderCopy (vid_renderer, vid_texture, NULL, NULL))
|
||||
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
SDL_RenderPresent (vid_renderer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vid_update_cursor (SDL_Cursor *cursor, t_bool visible)
|
||||
|
@ -1569,13 +1407,8 @@ if (!cursor)
|
|||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Cursor Update Event: Previously %s, Now %s, New Cursor object at: %p, Old Cursor object at: %p\n",
|
||||
SDL_ShowCursor(-1) ? "visible" : "invisible", visible ? "visible" : "invisible", cursor, vid_cursor);
|
||||
SDL_SetCursor (cursor);
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (visible)
|
||||
SDL_WarpMouse (vid_cursor_x, vid_cursor_y);/* sync position */
|
||||
#else
|
||||
if ((vid_window == SDL_GetMouseFocus ()) && visible)
|
||||
SDL_WarpMouseInWindow (NULL, vid_cursor_x, vid_cursor_y);/* sync position */
|
||||
#endif
|
||||
if ((vid_cursor != cursor) && (vid_cursor))
|
||||
SDL_FreeCursor (vid_cursor);
|
||||
vid_cursor = cursor;
|
||||
|
@ -1588,11 +1421,7 @@ void vid_warp_position (void)
|
|||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Mouse Warp Event: Warp to: (%d,%d)\n", vid_cursor_x, vid_cursor_y);
|
||||
|
||||
SDL_PumpEvents ();
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
SDL_WarpMouse (vid_cursor_x, vid_cursor_y);
|
||||
#else
|
||||
SDL_WarpMouseInWindow (NULL, vid_cursor_x, vid_cursor_y);
|
||||
#endif
|
||||
SDL_PumpEvents ();
|
||||
}
|
||||
|
||||
|
@ -1603,20 +1432,8 @@ uint32 *buf = (uint32 *)event->data2;
|
|||
|
||||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Draw Region Event: (%d,%d,%d,%d)\n", vid_dst->x, vid_dst->x, vid_dst->w, vid_dst->h);
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (1) {
|
||||
int32 i;
|
||||
uint32* pixels;
|
||||
|
||||
pixels = (uint32 *)vid_image->pixels;
|
||||
|
||||
for (i = 0; i < vid_dst->h; i++)
|
||||
memcpy (pixels + ((i + vid_dst->y) * vid_width) + vid_dst->x, buf + vid_dst->w*i, vid_dst->w*sizeof(*pixels));
|
||||
}
|
||||
#else
|
||||
if (SDL_UpdateTexture(vid_texture, vid_dst, buf, vid_dst->w*sizeof(*buf)))
|
||||
sim_printf ("%s: vid_draw() - SDL_UpdateTexture error: %s\n", sim_dname(vid_dev), SDL_GetError());
|
||||
#endif
|
||||
|
||||
free (vid_dst);
|
||||
free (buf);
|
||||
|
@ -1626,50 +1443,13 @@ event->data1 = NULL;
|
|||
int vid_video_events (void)
|
||||
{
|
||||
SDL_Event event;
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
static const char *eventtypes[] = {
|
||||
"NOEVENT", /**< Unused (do not remove) */
|
||||
"ACTIVEEVENT", /**< Application loses/gains visibility */
|
||||
"KEYDOWN", /**< Keys pressed */
|
||||
"KEYUP", /**< Keys released */
|
||||
"MOUSEMOTION", /**< Mouse moved */
|
||||
"MOUSEBUTTONDOWN", /**< Mouse button pressed */
|
||||
"MOUSEBUTTONUP", /**< Mouse button released */
|
||||
"JOYAXISMOTION", /**< Joystick axis motion */
|
||||
"JOYBALLMOTION", /**< Joystick trackball motion */
|
||||
"JOYHATMOTION", /**< Joystick hat position change */
|
||||
"JOYBUTTONDOWN", /**< Joystick button pressed */
|
||||
"JOYBUTTONUP", /**< Joystick button released */
|
||||
"QUIT", /**< User-requested quit */
|
||||
"SYSWMEVENT", /**< System specific event */
|
||||
"EVENT_RESERVEDA", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVEDB", /**< Reserved for future use.. */
|
||||
"VIDEORESIZE", /**< User resized video mode */
|
||||
"VIDEOEXPOSE", /**< Screen needs to be redrawn */
|
||||
"EVENT_RESERVED2", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVED3", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVED4", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVED5", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVED6", /**< Reserved for future use.. */
|
||||
"EVENT_RESERVED7", /**< Reserved for future use.. */
|
||||
"USEREVENT", /** Events SDL_USEREVENT(24) through SDL_MAXEVENTS-1(31) are for your use */
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
};
|
||||
#else
|
||||
static const char *eventtypes[SDL_LASTEVENT];
|
||||
#endif
|
||||
static const char *windoweventtypes[256];
|
||||
static t_bool initialized = FALSE;
|
||||
|
||||
if (!initialized) {
|
||||
initialized = TRUE;
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
|
||||
eventtypes[SDL_QUIT] = "QUIT"; /**< User-requested quit */
|
||||
|
||||
/* These application events have special meaning on iOS, see README-ios.txt for details */
|
||||
|
@ -1781,24 +1561,12 @@ if (!initialized) {
|
|||
* and should be allocated with SDL_RegisterEvents()
|
||||
*/
|
||||
eventtypes[SDL_USEREVENT] = "USEREVENT";
|
||||
#endif /* SDL_MAJOR_VERSION != 1 */
|
||||
}
|
||||
|
||||
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE, vid_dev, "vid_thread() - Starting\n");
|
||||
|
||||
memset (&vid_key_state, 0, sizeof(vid_key_state));
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
vid_window = SDL_SetVideoMode (vid_width, vid_height, 8, 0);
|
||||
|
||||
SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
if (sim_end)
|
||||
vid_image = SDL_CreateRGBSurface (SDL_SWSURFACE, vid_width, vid_height, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
|
||||
else
|
||||
vid_image = SDL_CreateRGBSurface (SDL_SWSURFACE, vid_width, vid_height, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
|
||||
|
||||
#else
|
||||
SDL_CreateWindowAndRenderer (vid_width, vid_height, SDL_WINDOW_SHOWN, &vid_window, &vid_renderer);
|
||||
|
||||
if ((vid_window == NULL) || (vid_renderer == NULL)) {
|
||||
|
@ -1831,8 +1599,6 @@ SDL_StopTextInput ();
|
|||
|
||||
vid_windowID = SDL_GetWindowID (vid_window);
|
||||
|
||||
#endif
|
||||
|
||||
if (vid_flags & SIM_VID_INPUTCAPTURED) {
|
||||
char title[150];
|
||||
|
||||
|
@ -1840,18 +1606,10 @@ if (vid_flags & SIM_VID_INPUTCAPTURED) {
|
|||
strlcpy (title, vid_title, sizeof(title));
|
||||
strlcat (title, " ReleaseKey=", sizeof(title));
|
||||
strlcat (title, vid_release_key, sizeof(title));
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
SDL_WM_SetCaption (title, title);
|
||||
#else
|
||||
SDL_SetWindowTitle (vid_window, title);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
SDL_WM_SetCaption (vid_title, sim_name);
|
||||
#else
|
||||
SDL_SetWindowTitle (vid_window, vid_title);
|
||||
#endif
|
||||
|
||||
vid_ready = TRUE;
|
||||
|
||||
|
@ -1894,7 +1652,6 @@ while (vid_active) {
|
|||
vid_controller_button (&event.cbutton);
|
||||
break;
|
||||
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
case SDL_WINDOWEVENT:
|
||||
if (event.window.windowID == vid_windowID) {
|
||||
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE|SIM_VID_DBG_CURSOR, vid_dev, "vid_thread() - Window Event: %d - %s\n", event.window.event, windoweventtypes[event.window.event]);
|
||||
|
@ -1909,7 +1666,7 @@ while (vid_active) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SDL_USEREVENT:
|
||||
/* There are 6 user events generated */
|
||||
/* EVENT_REDRAW to update the display */
|
||||
|
@ -1923,11 +1680,7 @@ while (vid_active) {
|
|||
if (event.user.code == EVENT_REDRAW) {
|
||||
vid_update ();
|
||||
event.user.code = 0; /* Mark as done */
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (0) while (SDL_PeepEvents (&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_USEREVENT))) {
|
||||
#else
|
||||
if (0) while (SDL_PeepEvents (&event, 1, SDL_GETEVENT, SDL_USEREVENT, SDL_USEREVENT)) {
|
||||
#endif
|
||||
if (event.user.code == EVENT_REDRAW) {
|
||||
/* Only do a single video update between waiting for events */
|
||||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "vid_thread() - Ignored extra REDRAW Event\n");
|
||||
|
@ -1991,13 +1744,11 @@ if (vid_cursor) {
|
|||
SDL_FreeCursor (vid_cursor);
|
||||
vid_cursor = NULL;
|
||||
}
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
SDL_DestroyTexture(vid_texture);
|
||||
vid_texture = NULL;
|
||||
SDL_DestroyRenderer(vid_renderer);
|
||||
vid_renderer = NULL;
|
||||
SDL_DestroyWindow(vid_window);
|
||||
#endif /* SDL_MAJOR_VERSION != 1 */
|
||||
vid_window = NULL;
|
||||
sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE|SIM_VID_DBG_CURSOR, vid_dev, "vid_thread() - Exiting\n");
|
||||
return 0;
|
||||
|
@ -2007,14 +1758,10 @@ int vid_thread (void *arg)
|
|||
{
|
||||
int stat;
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
_XInitThreads();
|
||||
stat = SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE);
|
||||
#else
|
||||
SDL_SetHint (SDL_HINT_RENDER_DRIVER, "software");
|
||||
|
||||
stat = SDL_Init (SDL_INIT_VIDEO);
|
||||
#endif
|
||||
|
||||
if (stat) {
|
||||
sim_printf ("SDL Video subsystem can't initialize\n");
|
||||
return 0;
|
||||
|
@ -2031,14 +1778,8 @@ const char *vid_version(void)
|
|||
static char SDLVersion[160];
|
||||
SDL_version compiled, running;
|
||||
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
const SDL_version *ver = SDL_Linked_Version();
|
||||
running.major = ver->major;
|
||||
running.minor = ver->minor;
|
||||
running.patch = ver->patch;
|
||||
#else
|
||||
SDL_GetVersion(&running);
|
||||
#endif
|
||||
|
||||
SDL_VERSION(&compiled);
|
||||
|
||||
SDLVersion[sizeof (SDLVersion) - 1] = '\0';
|
||||
|
@ -2109,28 +1850,8 @@ else {
|
|||
fprintf (st, " ");
|
||||
vid_show_release_key (st, uptr, val, desc);
|
||||
fprintf (st, "\n");
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
fprintf (st, " SDL Video Driver: %s\n", SDL_GetCurrentVideoDriver());
|
||||
#endif
|
||||
}
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
if (1) {
|
||||
char driver_name[64];
|
||||
const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
||||
|
||||
fprintf (st, " Video Driver: %s\n", SDL_VideoDriverName(driver_name, sizeof(driver_name)));
|
||||
fprintf (st, " hardware surfaces available: %s\n", info->hw_available ? "Yes" : "No");
|
||||
fprintf (st, " window manager available: %s\n", info->wm_available ? "Yes" : "No");
|
||||
fprintf (st, " hardware to hardware blits accelerated: %s\n", info->blit_hw ? "Yes" : "No");
|
||||
fprintf (st, " hardware to hardware colorkey blits accelerated: %s\n", info->blit_hw_CC ? "Yes" : "No");
|
||||
fprintf (st, " hardware to hardware alpha blits accelerated: %s\n", info->blit_hw_A ? "Yes" : "No");
|
||||
fprintf (st, " software to hardware blits accelerated: %s\n", info->blit_sw ? "Yes" : "No");
|
||||
fprintf (st, " software to hardware colorkey blits accelerated: %s\n", info->blit_sw_CC ? "Yes" : "No");
|
||||
fprintf (st, " software to hardware alpha blits accelerated: %s\n", info->blit_sw_A ? "Yes" : "No");
|
||||
fprintf (st, " color fills accelerated: %s\n", info->blit_fill ? "Yes" : "No");
|
||||
fprintf (st, " Video Memory: %dKb\n", info->video_mem);
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
|
||||
SDL_DisplayMode display;
|
||||
|
||||
|
@ -2321,7 +2042,6 @@ if (1) {
|
|||
fprintf (st, " %s = %s\n", hints[i], SDL_GetHint (hints[i]));
|
||||
}
|
||||
}
|
||||
#endif /* SDL_MAJOR_VERSION != 1 */
|
||||
#if !defined (SDL_MAIN_AVAILABLE)
|
||||
if (!vid_active)
|
||||
SDL_Quit();
|
||||
|
@ -2377,21 +2097,6 @@ if (!vid_active) {
|
|||
fullname = (char *)malloc (strlen(filename) + 5);
|
||||
if (!fullname)
|
||||
return SCPE_MEM;
|
||||
#if SDL_MAJOR_VERSION == 1
|
||||
#if defined(HAVE_LIBPNG)
|
||||
if (!match_ext (filename, "bmp")) {
|
||||
sprintf (fullname, "%s%s", filename, match_ext (filename, "png") ? "" : ".png");
|
||||
stat = SDL_SavePNG(vid_image, fullname);
|
||||
}
|
||||
else {
|
||||
sprintf (fullname, "%s", filename);
|
||||
stat = SDL_SaveBMP(vid_image, fullname);
|
||||
}
|
||||
#else
|
||||
sprintf (fullname, "%s%s", filename, match_ext (filename, "bmp") ? "" : ".bmp");
|
||||
stat = SDL_SaveBMP(vid_image, fullname);
|
||||
#endif /* defined(HAVE_LIBPNG) */
|
||||
#else /* SDL_MAJOR_VERSION != 1 */
|
||||
if (1) {
|
||||
SDL_Surface *sshot = sim_end ? SDL_CreateRGBSurface(0, vid_width, vid_height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000) :
|
||||
SDL_CreateRGBSurface(0, vid_width, vid_height, 32, 0x0000ff00, 0x000ff000, 0xff000000, 0x000000ff) ;
|
||||
|
@ -2411,7 +2116,6 @@ if (1) {
|
|||
#endif /* defined(HAVE_LIBPNG) */
|
||||
SDL_FreeSurface(sshot);
|
||||
}
|
||||
#endif
|
||||
if (stat) {
|
||||
sim_printf ("Error saving screenshot to %s: %s\n", fullname, SDL_GetError());
|
||||
free (fullname);
|
||||
|
|
Loading…
Add table
Reference in a new issue