2023-06-23 22:05:47 +00:00
|
|
|
diff -Paur --no-dereference -- libSDL.upstream/configure libSDL/configure
|
|
|
|
--- libSDL.upstream/configure
|
|
|
|
+++ libSDL/configure
|
|
|
|
@@ -19338,7 +19338,7 @@
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
- #include <dispd.h>
|
|
|
|
+ #include <display.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
@@ -19362,8 +19362,8 @@
|
|
|
|
|
|
|
|
SOURCES="$SOURCES $srcdir/src/video/sortix/*.c"
|
|
|
|
have_video=yes
|
|
|
|
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldispd"
|
|
|
|
- SDL_LIBS="$SDL_LIBS -ldispd"
|
|
|
|
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldisplay"
|
|
|
|
+ SDL_LIBS="$SDL_LIBS -ldisplay"
|
|
|
|
fi
|
|
|
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for display support" >&5
|
|
|
|
$as_echo_n "checking for display support... " >&6; }
|
2022-06-13 20:29:53 +00:00
|
|
|
diff -Paur --no-dereference -- libSDL.upstream/make.sortix libSDL/make.sortix
|
|
|
|
--- libSDL.upstream/make.sortix
|
|
|
|
+++ libSDL/make.sortix
|
|
|
|
@@ -0,0 +1,8 @@
|
|
|
|
+#!/bin/sh
|
|
|
|
+set -e
|
|
|
|
+
|
|
|
|
+"$MAKE" "$@"
|
|
|
|
+
|
|
|
|
+if [ "$1" = "install" ]; then
|
|
|
|
+rm -fv "$DESTDIR/$EXEC_PREFIX/bin/sdl-config"
|
|
|
|
+fi
|
2023-06-23 22:05:47 +00:00
|
|
|
diff -Paur --no-dereference -- libSDL.upstream/sdl.pc libSDL/sdl.pc
|
|
|
|
--- libSDL.upstream/sdl.pc
|
|
|
|
+++ libSDL/sdl.pc
|
|
|
|
@@ -10,6 +10,6 @@
|
|
|
|
Version: 1.2.15
|
|
|
|
Requires:
|
|
|
|
Conflicts:
|
|
|
|
-Libs: -L${libdir} -lSDL -ldispd -ldisplay
|
|
|
|
-Libs.private: -lSDL -ldispd -ldisplay -liconv -lm -ldispd -ldisplay
|
|
|
|
-Cflags: -I${includedir}/SDL
|
|
|
|
+Libs: -L${libdir} -lSDL -ldisplay -ldisplay
|
|
|
|
+Libs.private: -lSDL -ldisplay -ldisplay -liconv -lm -ldisplay -ldisplay
|
|
|
|
+Cflags: -I${includedir}/SDL -D_GNU_SOURCE=1
|
|
|
|
diff -Paur --no-dereference -- libSDL.upstream/src/video/sortix/SDL_dispd.c libSDL/src/video/sortix/SDL_dispd.c
|
|
|
|
--- libSDL.upstream/src/video/sortix/SDL_dispd.c
|
|
|
|
+++ libSDL/src/video/sortix/SDL_dispd.c
|
|
|
|
@@ -28,14 +28,11 @@
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
-#include <dispd.h>
|
|
|
|
-#if __has_include(<display.h>)
|
|
|
|
-#define DISPLAY
|
|
|
|
-#include <display.h>
|
|
|
|
-#endif
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
+#include <display.h>
|
|
|
|
+
|
|
|
|
#include "SDL_video.h"
|
|
|
|
#include "../SDL_sysvideo.h"
|
|
|
|
#include "../../events/SDL_sysevents.h"
|
|
|
|
@@ -64,30 +61,12 @@
|
|
|
|
|
|
|
|
static void DispD_DeleteDevice(SDL_VideoDevice *device)
|
|
|
|
{
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
if ( device->hidden->connection ) {
|
|
|
|
display_destroy_window(device->hidden->connection,
|
|
|
|
device->hidden->window_id);
|
|
|
|
display_disconnect(device->hidden->connection);
|
|
|
|
device->hidden->connection = NULL;
|
|
|
|
}
|
|
|
|
-#endif
|
|
|
|
- if ( device->hidden->fbinfo ) {
|
|
|
|
- dispd_finish_render(device->hidden->fbinfo);
|
|
|
|
- device->hidden->fbinfo = NULL;
|
|
|
|
- }
|
|
|
|
- if ( device->hidden->window ) {
|
|
|
|
- dispd_destroy_window(device->hidden->window);
|
|
|
|
- device->hidden->window = NULL;
|
|
|
|
- }
|
|
|
|
- if ( device->hidden->session ) {
|
|
|
|
- dispd_detach_session(device->hidden->session);
|
|
|
|
- device->hidden->session = NULL;
|
|
|
|
- }
|
|
|
|
- if ( 0 < device->hidden->tty_fd ) {
|
|
|
|
- close(device->hidden->tty_fd);
|
|
|
|
- device->hidden->tty_fd = -1;
|
|
|
|
- }
|
|
|
|
SDL_free(device->hidden);
|
|
|
|
SDL_free(device);
|
|
|
|
}
|
|
|
|
@@ -112,68 +91,20 @@
|
|
|
|
}
|
|
|
|
SDL_memset(device->hidden, 0, (sizeof *device->hidden));
|
|
|
|
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( (device->hidden->connection = display_connect_default()) ) {
|
|
|
|
- device->hidden->disconnected = 0;
|
|
|
|
- device->hidden->window_id = 0;
|
|
|
|
- device->hidden->window_width = 0;
|
|
|
|
- device->hidden->window_height = 0;
|
|
|
|
- display_create_window(device->hidden->connection,
|
|
|
|
- device->hidden->window_id);
|
|
|
|
- } else {
|
|
|
|
-#endif
|
|
|
|
- static int has_initialized_dispd = 0;
|
|
|
|
- if ( !has_initialized_dispd ) {
|
|
|
|
- if ( !dispd_initialize(NULL, NULL) ) {
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
- has_initialized_dispd = 1;
|
|
|
|
- }
|
|
|
|
- if ( (device->hidden->tty_fd = open("/dev/tty", O_RDONLY)) < 0 ) {
|
|
|
|
- DispD_DeleteDevice(device);
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( (device->hidden->session = dispd_attach_default_session()) == NULL ) {
|
|
|
|
- DispD_DeleteDevice(device);
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( !(dispd_session_setup_game_rgba(device->hidden->session)) ) {
|
|
|
|
- DispD_DeleteDevice(device);
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
+ if ( !(device->hidden->connection = display_connect_default()) ) {
|
|
|
|
+ return(0);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if ( (device->hidden->window =
|
|
|
|
- dispd_create_window_game_rgba(device->hidden->session)) == NULL ) {
|
|
|
|
- DispD_DeleteDevice(device);
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
+ device->hidden->disconnected = 0;
|
|
|
|
+ device->hidden->window_id = 0;
|
|
|
|
+ device->hidden->window_width = 0;
|
|
|
|
+ device->hidden->window_height = 0;
|
|
|
|
+ display_create_window(device->hidden->connection,
|
|
|
|
+ device->hidden->window_id);
|
|
|
|
|
|
|
|
- if ( (device->hidden->fbinfo =
|
|
|
|
- dispd_begin_render(device->hidden->window)) == NULL ) {
|
|
|
|
- DispD_DeleteDevice(device);
|
|
|
|
- return(0);
|
|
|
|
- }
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
+ device->hidden->current_mode.w = 800;
|
|
|
|
+ device->hidden->current_mode.h = 600;
|
|
|
|
|
|
|
|
- device->hidden->current_mode.x = 0;
|
|
|
|
- device->hidden->current_mode.y = 0;
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( device->hidden->connection ) {
|
|
|
|
- device->hidden->current_mode.w = 800;
|
|
|
|
- device->hidden->current_mode.h = 600;
|
|
|
|
- } else {
|
|
|
|
-#endif
|
|
|
|
- device->hidden->current_mode.w =
|
|
|
|
- dispd_get_framebuffer_width(device->hidden->fbinfo);
|
|
|
|
- device->hidden->current_mode.h =
|
|
|
|
- dispd_get_framebuffer_height(device->hidden->fbinfo);
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
device->hidden->mode_list[0] = &device->hidden->current_mode;
|
|
|
|
device->hidden->mode_list[1] = NULL;
|
|
|
|
|
|
|
|
@@ -217,13 +148,8 @@
|
|
|
|
SDL_Rect **DispD_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
|
|
|
{
|
|
|
|
// TODO: Return NULL if the format isn't 32-bit supported.
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( this->hidden->connection ) {
|
|
|
|
- // TODO: qemu seems to pick too little a resolution due to this.
|
|
|
|
- return((SDL_Rect **)-1);
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
- return(this->hidden->mode_list);
|
|
|
|
+ // TODO: qemu seems to pick too little a resolution due to this.
|
|
|
|
+ return((SDL_Rect **)-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Surface *DispD_SetVideoMode(_THIS, SDL_Surface *current,
|
|
|
|
@@ -234,28 +160,16 @@
|
|
|
|
|
|
|
|
bpp = 32;
|
|
|
|
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( this->hidden->connection ) {
|
|
|
|
- current->flags = SDL_RESIZABLE;
|
|
|
|
- size_t size = (size_t)width * (size_t)width * (bpp / 8);
|
|
|
|
- data = SDL_malloc(size);
|
|
|
|
- if ( !data )
|
|
|
|
- return(NULL);
|
|
|
|
- this->hidden->window_width = width;
|
|
|
|
- this->hidden->window_height = height;
|
|
|
|
- display_resize_window(this->hidden->connection,
|
|
|
|
- this->hidden->window_id, width, height);
|
|
|
|
- pitch = (size_t) width * (bpp / 8);
|
|
|
|
- } else {
|
|
|
|
-#endif
|
|
|
|
- data = dispd_get_framebuffer_data(this->hidden->fbinfo);
|
|
|
|
- width = dispd_get_framebuffer_width(this->hidden->fbinfo);
|
|
|
|
- height = dispd_get_framebuffer_height(this->hidden->fbinfo);
|
|
|
|
- pitch = dispd_get_framebuffer_pitch(this->hidden->fbinfo);
|
|
|
|
- current->flags = SDL_FULLSCREEN;
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
+ current->flags = SDL_RESIZABLE;
|
|
|
|
+ size_t size = (size_t)width * (size_t)width * (bpp / 8);
|
|
|
|
+ data = SDL_malloc(size);
|
|
|
|
+ if ( !data )
|
|
|
|
+ return(NULL);
|
|
|
|
+ this->hidden->window_width = width;
|
|
|
|
+ this->hidden->window_height = height;
|
|
|
|
+ display_resize_window(this->hidden->connection,
|
|
|
|
+ this->hidden->window_id, width, height);
|
|
|
|
+ pitch = (size_t) width * (bpp / 8);
|
|
|
|
|
|
|
|
int y;
|
|
|
|
for ( y = 0; y < height; y++ )
|
|
|
|
@@ -270,7 +184,7 @@
|
|
|
|
assert(current->format);
|
|
|
|
assert(current->format->BitsPerPixel == 32);
|
|
|
|
current->pitch = pitch;
|
|
|
|
- // TODO: Memory leak of old buffer?
|
|
|
|
+ free(current->pixels);
|
|
|
|
current->pixels = data;
|
|
|
|
current->w = width;
|
|
|
|
current->h = height;
|
|
|
|
@@ -291,12 +205,8 @@
|
|
|
|
|
|
|
|
static void DispD_SetCaption(_THIS, const char *title, const char *icon)
|
|
|
|
{
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( this->hidden->connection) {
|
|
|
|
- display_title_window(this->hidden->connection,
|
|
|
|
- this->hidden->window_id, title);
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
+ display_title_window(this->hidden->connection,
|
|
|
|
+ this->hidden->window_id, title);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We need to wait for vertical retrace on page flipped displays */
|
|
|
|
@@ -312,26 +222,13 @@
|
|
|
|
|
|
|
|
static void DispD_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
|
|
|
{
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( this->hidden->connection) {
|
|
|
|
- for ( size_t i = 3; i < (size_t)SDL_VideoSurface->w * (size_t)SDL_VideoSurface->h * 4; i += 4 )
|
|
|
|
- ((unsigned char*)SDL_VideoSurface->pixels)[i] = 255;
|
|
|
|
- display_render_window(this->hidden->connection, this->hidden->window_id,
|
|
|
|
- 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h,
|
|
|
|
- SDL_VideoSurface->pixels);
|
|
|
|
- display_show_window(this->hidden->connection, this->hidden->window_id);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
- uint8_t* old_data = dispd_get_framebuffer_data(this->hidden->fbinfo);
|
|
|
|
- if ( !dispd_finish_render(this->hidden->fbinfo) ) {
|
|
|
|
- abort();
|
|
|
|
- }
|
|
|
|
- if ( !(this->hidden->fbinfo = dispd_begin_render(this->hidden->window)) ) {
|
|
|
|
- abort();
|
|
|
|
- }
|
|
|
|
- uint8_t* new_data = dispd_get_framebuffer_data(this->hidden->fbinfo);
|
|
|
|
- assert(old_data == new_data);
|
|
|
|
+ size_t size = (size_t)SDL_VideoSurface->w * (size_t)SDL_VideoSurface->h * 4;
|
|
|
|
+ for ( size_t i = 3; i < size; i += 4 )
|
|
|
|
+ ((unsigned char*)SDL_VideoSurface->pixels)[i] = 255;
|
|
|
|
+ display_render_window(this->hidden->connection, this->hidden->window_id,
|
|
|
|
+ 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h,
|
|
|
|
+ SDL_VideoSurface->pixels);
|
|
|
|
+ display_show_window(this->hidden->connection, this->hidden->window_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DispD_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
|
|
|
@@ -345,6 +242,7 @@
|
|
|
|
*/
|
|
|
|
void DispD_VideoQuit(_THIS)
|
|
|
|
{
|
|
|
|
+ free(this->screen->pixels);
|
|
|
|
this->screen->pixels = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -424,7 +322,6 @@
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
static void on_disconnect(void* ctx)
|
|
|
|
{
|
|
|
|
struct SDL_PrivateVideoData* hidden = (struct SDL_PrivateVideoData*) ctx;
|
|
|
|
@@ -463,48 +360,19 @@
|
|
|
|
keysym.unicode = 0;
|
|
|
|
SDL_PrivateKeyboard(kbkey < 0 ? SDL_RELEASED : SDL_PRESSED, &keysym);
|
|
|
|
}
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
void DispD_PumpEvents(_THIS)
|
|
|
|
{
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
- if ( this->hidden->connection) {
|
|
|
|
- struct display_event_handlers handlers;
|
|
|
|
- memset(&handlers, 0, sizeof(handlers));
|
|
|
|
- handlers.context = this->hidden;
|
|
|
|
- handlers.disconnect_handler = on_disconnect;
|
|
|
|
- handlers.quit_handler = on_quit;
|
|
|
|
- handlers.resize_handler = on_resize;
|
|
|
|
- handlers.keyboard_handler = on_keyboard;
|
|
|
|
- while ( !this->hidden->disconnected ) {
|
|
|
|
- if ( display_poll_event(this->hidden->connection, &handlers) < 0 )
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
- // Read the keyboard input from the user.
|
|
|
|
- const unsigned termmode = TERMMODE_KBKEY
|
|
|
|
- | TERMMODE_UNICODE
|
|
|
|
- | TERMMODE_SIGNAL
|
|
|
|
- | TERMMODE_NONBLOCK;
|
|
|
|
- if ( settermmode(0, termmode) ) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- uint32_t codepoint;
|
|
|
|
- ssize_t numbytes;
|
|
|
|
- while ( 0 < (numbytes = read(0, &codepoint, sizeof(codepoint))) )
|
|
|
|
- {
|
|
|
|
- int kbkey = KBKEY_DECODE(codepoint);
|
|
|
|
- int abskbkey = kbkey < 0 ? -kbkey : kbkey;
|
|
|
|
- int key = TranslateKey(abskbkey);
|
|
|
|
- SDL_keysym keysym;
|
|
|
|
- keysym.scancode = abskbkey;
|
|
|
|
- keysym.sym = key;
|
|
|
|
- keysym.mod = 0;
|
|
|
|
- keysym.unicode = 0;
|
|
|
|
- SDL_PrivateKeyboard(kbkey < 0 ? SDL_RELEASED : SDL_PRESSED, &keysym);
|
|
|
|
+ struct display_event_handlers handlers;
|
|
|
|
+ memset(&handlers, 0, sizeof(handlers));
|
|
|
|
+ handlers.context = this->hidden;
|
|
|
|
+ handlers.disconnect_handler = on_disconnect;
|
|
|
|
+ handlers.quit_handler = on_quit;
|
|
|
|
+ handlers.resize_handler = on_resize;
|
|
|
|
+ handlers.keyboard_handler = on_keyboard;
|
|
|
|
+ while ( !this->hidden->disconnected ) {
|
|
|
|
+ if ( display_poll_event(this->hidden->connection, &handlers) < 0 )
|
|
|
|
+ break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
diff -Paur --no-dereference -- libSDL.upstream/src/video/sortix/SDL_dispd.h libSDL/src/video/sortix/SDL_dispd.h
|
|
|
|
--- libSDL.upstream/src/video/sortix/SDL_dispd.h
|
|
|
|
+++ libSDL/src/video/sortix/SDL_dispd.h
|
|
|
|
@@ -33,19 +33,13 @@
|
|
|
|
/* Private display data */
|
|
|
|
|
|
|
|
struct SDL_PrivateVideoData {
|
|
|
|
-#ifdef DISPLAY
|
|
|
|
struct display_connection *connection;
|
|
|
|
uint32_t window_id;
|
|
|
|
uint32_t window_width;
|
|
|
|
uint32_t window_height;
|
|
|
|
int disconnected;
|
|
|
|
-#endif
|
|
|
|
- struct dispd_session *session;
|
|
|
|
- struct dispd_window *window;
|
|
|
|
- struct dispd_framebuffer *fbinfo;
|
|
|
|
SDL_Rect current_mode;
|
|
|
|
SDL_Rect *mode_list[2];
|
|
|
|
- int tty_fd;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _SDL_nullvideo_h */
|