diff -rupN source-original/build-scripts/config.sub source/build-scripts/config.sub --- source-original/build-scripts/config.sub 2012-01-19 07:30:05.000000000 +0100 +++ source/build-scripts/config.sub 2018-02-26 11:41:15.584206480 +0100 @@ -1276,7 +1276,7 @@ case $os in -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -kopensolaris* \ + | -kopensolaris* | -redox* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ diff -rupN source-original/configure.in source/configure.in --- source-original/configure.in 2012-01-19 07:30:05.000000000 +0100 +++ source/configure.in 2018-02-26 11:41:15.596206742 +0100 @@ -1646,6 +1646,19 @@ AC_HELP_STRING([--enable-video-dummy], [ fi } +dnl Set up the Orbital video driver. +CheckOrbitalVideo() +{ + AC_ARG_ENABLE(video-orbital, +AC_HELP_STRING([--enable-video-orbital], [use orbital video driver [[default=yes]]]), + , enable_video_orbital=yes) + if test x$enable_video_orbital = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_ORBITAL) + SOURCES="$SOURCES $srcdir/src/video/orbital/*.c" + have_video=yes + fi +} + dnl Check to see if OpenGL support is desired AC_ARG_ENABLE(video-opengl, AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]), @@ -2325,10 +2338,11 @@ case "$host" in have_timers=yes fi ;; - *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*) + *-*-linux*|*-*-uclinux*|*-*-redox*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*) case "$host" in *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; + *-*-redox*) ARCH=redox ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;; *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;; @@ -2347,6 +2361,7 @@ case "$host" in esac CheckVisibilityHidden CheckDummyVideo + CheckOrbitalVideo CheckDiskAudio CheckDummyAudio CheckDLOPEN diff -rupN source-original/include/SDL_config.h.in source/include/SDL_config.h.in --- source-original/include/SDL_config.h.in 2012-01-19 07:30:05.000000000 +0100 +++ source/include/SDL_config.h.in 2018-02-26 11:41:15.596206742 +0100 @@ -268,6 +268,7 @@ #undef SDL_VIDEO_DRIVER_GGI #undef SDL_VIDEO_DRIVER_IPOD #undef SDL_VIDEO_DRIVER_NANOX +#undef SDL_VIDEO_DRIVER_ORBITAL #undef SDL_VIDEO_DRIVER_OS2FS #undef SDL_VIDEO_DRIVER_PHOTON #undef SDL_VIDEO_DRIVER_PICOGUI diff -rupN source-original/src/video/orbital/SDL_orbitalevents.c source/src/video/orbital/SDL_orbitalevents.c --- source-original/src/video/orbital/SDL_orbitalevents.c 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalevents.c 2018-02-26 11:45:59.446509075 +0100 @@ -0,0 +1,190 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_orbitalvideo.h" +#include "SDL_orbitalevents_c.h" +#include "SDL_orbitalscancode.h" + +#include + +static SDLKey keymap[128]; + +#define EVENT_NONE 0 +#define EVENT_KEY 1 +#define EVENT_MOUSE 2 +#define EVENT_BUTTON 3 +#define EVENT_SCROLL 4 +#define EVENT_QUIT 5 +#define EVENT_FOCUS 6 +#define EVENT_MOVE 7 +#define EVENT_RESIZE 8 +#define EVENT_SCREEN 9 + +struct Event { + int64_t code; + int64_t a; + int64_t b; +} __attribute__((packed)); + +/* Static variables so only changes are reported */ +static int64_t last_buttons = 0; + +void ORBITAL_PumpEvents(_THIS) +{ + struct Event event; + while(read(this->hidden->fd, &event, sizeof(event)) > 0){ + if ( event.code == EVENT_KEY ) { + SDL_keysym keysym; + + // TODO: Find out why NetSurf recieves NULL chars when the Unicode field is used + //keysym.unicode = event.a; + keysym.scancode = event.b & 0xFF; + keysym.sym = keymap[event.b & 0xFF]; + keysym.mod = KMOD_NONE; + if ( (event.b >> 8) & 0x01 > 0 ) { + SDL_PrivateKeyboard(SDL_PRESSED, &keysym); + } else { + SDL_PrivateKeyboard(SDL_RELEASED, &keysym); + } + } else if ( event.code == EVENT_MOUSE ) { + SDL_PrivateMouseMotion(0, 0, event.a, event.b); + //SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y); + } else if ( event.code == EVENT_BUTTON ) { + int64_t changed = event.a ^ last_buttons; + + if ( changed & 0x01 ) + SDL_PrivateMouseButton((event.a & 0x01) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); + if ( changed & 0x02 ) + SDL_PrivateMouseButton((event.a & 0x02) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); + if ( changed & 0x04 ) + SDL_PrivateMouseButton((event.a & 0x04) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); + + last_buttons = event.a; + } else if ( event.code == EVENT_SCROLL ) { + if ( event.b > 0 ) { + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); + } else if ( event.b < 0 ) { + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); + } + } else if ( event.code == EVENT_RESIZE ) { + SDL_PrivateResize(event.a, event.b); + } else if ( event.code == EVENT_QUIT ) { + SDL_PrivateQuit(); + } + } +} + +void ORBITAL_InitOSKeymap(_THIS) +{ + int i; + for ( i = 0; i < SDL_arraysize(keymap); ++i ) + keymap[i] = SDLK_UNKNOWN; + + keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; + keymap[SCANCODE_1] = SDLK_1; + keymap[SCANCODE_2] = SDLK_2; + keymap[SCANCODE_3] = SDLK_3; + keymap[SCANCODE_4] = SDLK_4; + keymap[SCANCODE_5] = SDLK_5; + keymap[SCANCODE_6] = SDLK_6; + keymap[SCANCODE_7] = SDLK_7; + keymap[SCANCODE_8] = SDLK_8; + keymap[SCANCODE_9] = SDLK_9; + keymap[SCANCODE_0] = SDLK_0; + keymap[SCANCODE_MINUS] = SDLK_MINUS; + keymap[SCANCODE_EQUAL] = SDLK_EQUALS; + keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; + keymap[SCANCODE_TAB] = SDLK_TAB; + keymap[SCANCODE_Q] = SDLK_q; + keymap[SCANCODE_W] = SDLK_w; + keymap[SCANCODE_E] = SDLK_e; + keymap[SCANCODE_R] = SDLK_r; + keymap[SCANCODE_T] = SDLK_t; + keymap[SCANCODE_Y] = SDLK_y; + keymap[SCANCODE_U] = SDLK_u; + keymap[SCANCODE_I] = SDLK_i; + keymap[SCANCODE_O] = SDLK_o; + keymap[SCANCODE_P] = SDLK_p; + keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; + keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; + keymap[SCANCODE_ENTER] = SDLK_RETURN; + keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; + keymap[SCANCODE_A] = SDLK_a; + keymap[SCANCODE_S] = SDLK_s; + keymap[SCANCODE_D] = SDLK_d; + keymap[SCANCODE_F] = SDLK_f; + keymap[SCANCODE_G] = SDLK_g; + keymap[SCANCODE_H] = SDLK_h; + keymap[SCANCODE_J] = SDLK_j; + keymap[SCANCODE_K] = SDLK_k; + keymap[SCANCODE_L] = SDLK_l; + keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; + keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; + keymap[SCANCODE_TICK] = SDLK_BACKQUOTE; + keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; + keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; + keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; + keymap[SCANCODE_Z] = SDLK_z; + keymap[SCANCODE_X] = SDLK_x; + keymap[SCANCODE_C] = SDLK_c; + keymap[SCANCODE_V] = SDLK_v; + keymap[SCANCODE_B] = SDLK_b; + keymap[SCANCODE_N] = SDLK_n; + keymap[SCANCODE_M] = SDLK_m; + keymap[SCANCODE_COMMA] = SDLK_COMMA; + keymap[SCANCODE_PERIOD] = SDLK_PERIOD; + keymap[SCANCODE_SLASH] = SDLK_SLASH; + keymap[SCANCODE_LEFTALT] = SDLK_LALT; + keymap[SCANCODE_SPACE] = SDLK_SPACE; + keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; + keymap[SCANCODE_F1] = SDLK_F1; + keymap[SCANCODE_F2] = SDLK_F2; + keymap[SCANCODE_F3] = SDLK_F3; + keymap[SCANCODE_F4] = SDLK_F4; + keymap[SCANCODE_F5] = SDLK_F5; + keymap[SCANCODE_F6] = SDLK_F6; + keymap[SCANCODE_F7] = SDLK_F7; + keymap[SCANCODE_F8] = SDLK_F8; + keymap[SCANCODE_F9] = SDLK_F9; + keymap[SCANCODE_F10] = SDLK_F10; + keymap[SCANCODE_F11] = SDLK_F11; + keymap[SCANCODE_F12] = SDLK_F12; + keymap[SCANCODE_HOME] = SDLK_HOME; + keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; + keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; + keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; + keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; + keymap[SCANCODE_END] = SDLK_END; + keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; + keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; + keymap[SCANCODE_INSERT] = SDLK_INSERT; + keymap[SCANCODE_DELETE] = SDLK_DELETE; +} + +/* end of SDL_orbitalevents.c ... */ diff -rupN source-original/src/video/orbital/SDL_orbitalevents_c.h source/src/video/orbital/SDL_orbitalevents_c.h --- source-original/src/video/orbital/SDL_orbitalevents_c.h 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalevents_c.h 2018-02-26 11:41:15.600206830 +0100 @@ -0,0 +1,32 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_orbitalvideo.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void ORBITAL_InitOSKeymap(_THIS); +extern void ORBITAL_PumpEvents(_THIS); + +/* end of SDL_orbitalevents_c.h ... */ diff -rupN source-original/src/video/orbital/SDL_orbitalmouse.c source/src/video/orbital/SDL_orbitalmouse.c --- source-original/src/video/orbital/SDL_orbitalmouse.c 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalmouse.c 2018-02-26 11:41:15.600206830 +0100 @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_orbitalmouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff -rupN source-original/src/video/orbital/SDL_orbitalmouse_c.h source/src/video/orbital/SDL_orbitalmouse_c.h --- source-original/src/video/orbital/SDL_orbitalmouse_c.h 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalmouse_c.h 2018-02-26 11:41:15.600206830 +0100 @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_orbitalvideo.h" + +/* Functions to be exported */ diff -rupN source-original/src/video/orbital/SDL_orbitalscancode.h source/src/video/orbital/SDL_orbitalscancode.h --- source-original/src/video/orbital/SDL_orbitalscancode.h 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalscancode.h 2018-02-26 11:41:15.600206830 +0100 @@ -0,0 +1,80 @@ +#define SCANCODE_A 0x1E +#define SCANCODE_B 0x30 +#define SCANCODE_C 0x2E +#define SCANCODE_D 0x20 +#define SCANCODE_E 0x12 +#define SCANCODE_F 0x21 +#define SCANCODE_G 0x22 +#define SCANCODE_H 0x23 +#define SCANCODE_I 0x17 +#define SCANCODE_J 0x24 +#define SCANCODE_K 0x25 +#define SCANCODE_L 0x26 +#define SCANCODE_M 0x32 +#define SCANCODE_N 0x31 +#define SCANCODE_O 0x18 +#define SCANCODE_P 0x19 +#define SCANCODE_Q 0x10 +#define SCANCODE_R 0x13 +#define SCANCODE_S 0x1F +#define SCANCODE_T 0x14 +#define SCANCODE_U 0x16 +#define SCANCODE_V 0x2F +#define SCANCODE_W 0x11 +#define SCANCODE_X 0x2D +#define SCANCODE_Y 0x15 +#define SCANCODE_Z 0x2C +#define SCANCODE_0 0x0B +#define SCANCODE_1 0x2 +#define SCANCODE_2 0x3 +#define SCANCODE_3 0x4 +#define SCANCODE_4 0x5 +#define SCANCODE_5 0x6 +#define SCANCODE_6 0x7 +#define SCANCODE_7 0x8 +#define SCANCODE_8 0x9 +#define SCANCODE_9 0x0A +#define SCANCODE_TICK 0x29 +#define SCANCODE_MINUS 0x0C +#define SCANCODE_EQUAL 0x0D +#define SCANCODE_BACKSLASH 0x2B +#define SCANCODE_BACKSPACE 0x0E +#define SCANCODE_SPACE 0x39 +#define SCANCODE_TAB 0x0F +#define SCANCODE_CAPSLOCK 0x3A +#define SCANCODE_LEFTSHIFT 0x2A +#define SCANCODE_LEFTCONTROL 0x1D +#define SCANCODE_LEFTALT 0x38 +#define SCANCODE_RIGHTSHIFT 0x36 +#define SCANCODE_ENTER 0x1C +#define SCANCODE_ESCAPE 0x1 +#define SCANCODE_F1 0x3B +#define SCANCODE_F2 0x3C +#define SCANCODE_F3 0x3D +#define SCANCODE_F4 0x3E +#define SCANCODE_F5 0x3F +#define SCANCODE_F6 0x40 +#define SCANCODE_F7 0x41 +#define SCANCODE_F8 0x42 +#define SCANCODE_F9 0x43 +#define SCANCODE_F10 0x44 +#define SCANCODE_F11 0x57 +#define SCANCODE_F12 0x58 +#define SCANCODE_SCROLL 0x46 +#define SCANCODE_BRACKET_LEFT 0x1A +#define SCANCODE_BRACKET_RIGHT 0x1B +#define SCANCODE_INSERT 0x52 +#define SCANCODE_HOME 0x47 +#define SCANCODE_PAGEUP 0x49 +#define SCANCODE_DELETE 0x53 +#define SCANCODE_END 0x4F +#define SCANCODE_PAGEDOWN 0x51 +#define SCANCODE_CURSORBLOCKUP 0x48 +#define SCANCODE_CURSORBLOCKLEFT 0x4B +#define SCANCODE_CURSORBLOCKDOWN 0x50 +#define SCANCODE_CURSORBLOCKRIGHT 0x4D +#define SCANCODE_SEMICOLON 0x27 +#define SCANCODE_APOSTROPHE 0x28 +#define SCANCODE_COMMA 0x33 +#define SCANCODE_PERIOD 0x34 +#define SCANCODE_SLASH 0x35 diff -rupN source-original/src/video/orbital/SDL_orbitalvideo.c source/src/video/orbital/SDL_orbitalvideo.c --- source-original/src/video/orbital/SDL_orbitalvideo.c 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalvideo.c 2018-02-26 11:50:02.769667936 +0100 @@ -0,0 +1,287 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Orbital SDL video driver implementation + * + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. + * Repurposed to ORBITAL by Jeremy Soller. + */ + +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_orbitalvideo.h" +#include "SDL_orbitalevents_c.h" +#include "SDL_orbitalmouse_c.h" + +#include +#include +#include +#include +#include + +#define ORBITALVID_DRIVER_NAME "orbital" + +/* Initialization/Query functions */ +static int ORBITAL_VideoInit(_THIS, SDL_PixelFormat *vformat); +static SDL_Rect **ORBITAL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); +static SDL_Surface *ORBITAL_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); +static int ORBITAL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); +static void ORBITAL_VideoQuit(_THIS); +static void ORBITAL_SetCaption(_THIS, const char *title, const char *icon); + +/* Hardware surface functions */ +static int ORBITAL_AllocHWSurface(_THIS, SDL_Surface *surface); +static int ORBITAL_LockHWSurface(_THIS, SDL_Surface *surface); +static void ORBITAL_UnlockHWSurface(_THIS, SDL_Surface *surface); +static void ORBITAL_FreeHWSurface(_THIS, SDL_Surface *surface); + +/* etc. */ +static void ORBITAL_UpdateRects(_THIS, int numrects, SDL_Rect *rects); + +/* ORBITAL driver bootstrap functions */ + +static int ORBITAL_Available(void) +{ + return(1); +} + +static void ORBITAL_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->hidden); + SDL_free(device); +} + +static SDL_VideoDevice *ORBITAL_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + SDL_malloc((sizeof *device->hidden)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return(0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = ORBITAL_VideoInit; + device->ListModes = ORBITAL_ListModes; + device->SetVideoMode = ORBITAL_SetVideoMode; + device->CreateYUVOverlay = NULL; + device->SetColors = ORBITAL_SetColors; + device->UpdateRects = ORBITAL_UpdateRects; + device->VideoQuit = ORBITAL_VideoQuit; + device->AllocHWSurface = ORBITAL_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = ORBITAL_LockHWSurface; + device->UnlockHWSurface = ORBITAL_UnlockHWSurface; + device->FlipHWSurface = NULL; + device->FreeHWSurface = ORBITAL_FreeHWSurface; + device->SetCaption = ORBITAL_SetCaption; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GrabInput = NULL; + device->GetWMInfo = NULL; + device->InitOSKeymap = ORBITAL_InitOSKeymap; + device->PumpEvents = ORBITAL_PumpEvents; + + device->free = ORBITAL_DeleteDevice; + + return device; +} + +VideoBootStrap ORBITAL_bootstrap = { + ORBITALVID_DRIVER_NAME, "SDL orbital video driver", + ORBITAL_Available, ORBITAL_CreateDevice +}; + + +int ORBITAL_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + fprintf(stderr, "WARNING: You are using the SDL orbital video driver!\n"); + + /* Determine the screen depth (use default 32-bit depth) */ + /* we change this during the SDL_SetVideoMode implementation... */ + vformat->BitsPerPixel = 32; + vformat->BytesPerPixel = 4; + + /* We're done! */ + return(0); +} + +SDL_Rect **ORBITAL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return (SDL_Rect **) -1; +} + +SDL_Surface *ORBITAL_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + if ( bpp != 32 ) { + SDL_SetError("Unsupported color depth - must use 32-bits per pixel"); + return(NULL); + } + + if ( this->hidden->buffer ) { + redox_funmap( this->hidden->buffer ); + this->hidden->buffer = NULL; + } + + if ( this->hidden->fd > 0 ) { + /* If the window already exists send a resize message to the display server */ + char msg[4096]; + int msg_len = snprintf(msg, 4096, "S,%d,%d", width, height); + int res = write(this->hidden->fd, msg, msg_len); + if ( res != msg_len ) { + close(this->hidden->fd); + this->hidden->fd = 0; + SDL_SetError("Couldn't write resize event"); + return(NULL); + } + } else { + /* Otherwise create a new window */ + char path[4096]; + snprintf(path, 4096, "orbital:a%s/-1/-1/%d/%d/SDL", (flags & SDL_RESIZABLE) ? "r" : "", width, height); + this->hidden->fd = open(path, O_RDWR); + if ( this->hidden->fd <= 0 ) { + this->hidden->fd = 0; + SDL_SetError("Couldn't create window for requested mode"); + return(NULL); + } + printf("%s at %d\n", path, this->hidden->fd); + } + + this->hidden->buffer = redox_fmap(this->hidden->fd, 0, width * height * (bpp / 8)); + if ( ! this->hidden->buffer ) { + close(this->hidden->fd); + this->hidden->fd = 0; + SDL_SetError("Couldn't map window for requested mode"); + return(NULL); + } + + fprintf(stderr, "Setting mode %dx%d@%d\n", width, height, bpp); + + /* Allocate the new pixel format for the screen */ + + if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { + redox_funmap(this->hidden->buffer); + this->hidden->buffer = NULL; + close(this->hidden->fd); + this->hidden->fd = 0; + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return(NULL); + } + + /* Set up the new mode framebuffer */ + current->flags = flags /*& SDL_FULLSCREEN*/; + this->hidden->w = current->w = width; + this->hidden->h = current->h = height; + current->pitch = current->w * (bpp / 8); + current->pixels = this->hidden->buffer; + + /* We're done */ + return(current); +} + +static void ORBITAL_SetCaption(_THIS, const char *title, const char *icon) +{ + if ( this->hidden->fd > 0 ) { + char msg[4096]; + int msg_len = snprintf(msg, 4096, "T,%s", title); + int res = write(this->hidden->fd, msg, msg_len); + if ( res != msg_len ) { + SDL_SetError("Couldn't set window caption (write error)"); + } + } +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int ORBITAL_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} +static void ORBITAL_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +/* We need to wait for vertical retrace on page flipped displays */ +static int ORBITAL_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void ORBITAL_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static void ORBITAL_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + fsync(this->hidden->fd); +} + +int ORBITAL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) +{ + /* do nothing of note. */ + return(1); +} + +/* Note: If we are terminated, this could be called in the middle of + another SDL video routine -- notably UpdateRects. +*/ +void ORBITAL_VideoQuit(_THIS) +{ + if ( this->hidden->buffer ) { + redox_funmap( this->hidden->buffer ); + this->hidden->buffer = NULL; + } + + if ( this->hidden->fd >= 0) { + close( this->hidden->fd ); + this->hidden->fd = 0; + } + + if (this->screen->pixels != NULL) + { + SDL_free(this->screen->pixels); + this->screen->pixels = NULL; + } +} diff -rupN source-original/src/video/orbital/SDL_orbitalvideo.h source/src/video/orbital/SDL_orbitalvideo.h --- source-original/src/video/orbital/SDL_orbitalvideo.h 1970-01-01 01:00:00.000000000 +0100 +++ source/src/video/orbital/SDL_orbitalvideo.h 2018-02-26 11:41:15.600206830 +0100 @@ -0,0 +1,41 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_orbitalvideo_h +#define _SDL_orbitalvideo_h + +#include "../SDL_sysvideo.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + + +/* Private display data */ + +struct SDL_PrivateVideoData { + int w, h; + int fd; + void *buffer; +}; + +#endif /* _SDL_orbitalvideo_h */ diff -rupN source-original/src/video/SDL_gamma.c source/src/video/SDL_gamma.c --- source-original/src/video/SDL_gamma.c 2012-01-19 07:30:06.000000000 +0100 +++ source/src/video/SDL_gamma.c 2018-02-26 11:41:15.600206830 +0100 @@ -23,9 +23,9 @@ /* Gamma correction support */ -#ifdef HAVE_MATH_H -#include /* Used for calculating gamma ramps */ -#else +//#ifdef HAVE_MATH_H +//#include /* Used for calculating gamma ramps */ +//#else /* Math routines from uClibc: http://www.uclibc.org */ #include "math_private.h" #include "e_sqrt.h" @@ -33,7 +33,7 @@ #include "e_log.h" #define pow(x, y) __ieee754_pow(x, y) #define log(x) __ieee754_log(x) -#endif +//#endif #include "SDL_sysvideo.h" @@ -94,7 +94,7 @@ int SDL_SetGamma(float red, float green, { int succeeded; SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; succeeded = -1; /* Prefer using SetGammaRamp(), as it's more flexible */ @@ -120,7 +120,7 @@ int SDL_GetGamma(float *red, float *gree { int succeeded; SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; succeeded = -1; /* Prefer using GetGammaRamp(), as it's more flexible */ @@ -145,7 +145,7 @@ int SDL_SetGammaRamp(const Uint16 *red, { int succeeded; SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; SDL_Surface *screen = SDL_PublicSurface; /* Verify the screen parameter */ @@ -177,7 +177,7 @@ int SDL_SetGammaRamp(const Uint16 *red, /* If physical palette has been set independently, use it */ if(video->physpal) pal = video->physpal; - + SDL_SetPalette(screen, SDL_PHYSPAL, pal->colors, 0, pal->ncolors); return 0; @@ -196,7 +196,7 @@ int SDL_SetGammaRamp(const Uint16 *red, int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; /* Lazily allocate the gamma table */ if ( ! video->gamma ) { diff -rupN source-original/src/video/SDL_sysvideo.h source/src/video/SDL_sysvideo.h --- source-original/src/video/SDL_sysvideo.h 2012-01-19 07:30:06.000000000 +0100 +++ source/src/video/SDL_sysvideo.h 2018-02-26 11:41:15.604206916 +0100 @@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap; #if SDL_VIDEO_DRIVER_CACA extern VideoBootStrap CACA_bootstrap; #endif +#if SDL_VIDEO_DRIVER_ORBITAL +extern VideoBootStrap ORBITAL_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff -rupN source-original/src/video/SDL_video.c source/src/video/SDL_video.c --- source-original/src/video/SDL_video.c 2012-01-19 07:30:06.000000000 +0100 +++ source/src/video/SDL_video.c 2018-02-26 11:44:58.717146828 +0100 @@ -126,6 +126,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_CACA &CACA_bootstrap, #endif +#if SDL_VIDEO_DRIVER_ORBITAL + &ORBITAL_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif @@ -217,7 +220,7 @@ int SDL_VideoInit (const char *driver_na video->offset_x = 0; video->offset_y = 0; SDL_memset(&video->info, 0, (sizeof video->info)); - + video->displayformatalphapixel = NULL; /* Set some very sane GL defaults */ @@ -240,7 +243,7 @@ int SDL_VideoInit (const char *driver_na video->gl_config.multisamplesamples = 0; video->gl_config.accelerated = -1; /* not known, don't set */ video->gl_config.swap_control = -1; /* not known, don't set */ - + /* Initialize the video subsystem */ SDL_memset(&vformat, 0, sizeof(vformat)); if ( video->VideoInit(video, &vformat) < 0 ) { @@ -397,7 +400,7 @@ int SDL_VideoModeOK (int width, int heig if ( sizes == (SDL_Rect **)0 ) { /* No sizes supported at this bit-depth */ continue; - } else + } else if (sizes == (SDL_Rect **)NEGATIVE_ONE) { /* Any size supported at this bit-depth */ supported = 1; @@ -726,7 +729,8 @@ SDL_Surface * SDL_SetVideoMode (int widt video->offset_y = 0; mode->offset = 0; SDL_SetClipRect(mode, NULL); - SDL_ClearSurface(mode); + // Causes blinking under Orbital + //SDL_ClearSurface(mode); /* Now adjust the offsets to match the desired mode */ video->offset_x = (mode->w-width)/2; @@ -788,7 +792,7 @@ SDL_Surface * SDL_SetVideoMode (int widt #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_glfuncs.h" -#undef SDL_PROC +#undef SDL_PROC } #endif /* SDL_VIDEO_OPENGL */ @@ -817,9 +821,9 @@ SDL_Surface * SDL_SetVideoMode (int widt ) { video->is_32bit = 0; SDL_VideoSurface = SDL_CreateRGBSurface( - flags, - width, - height, + flags, + width, + height, 16, 31 << 11, 63 << 5, @@ -832,10 +836,10 @@ SDL_Surface * SDL_SetVideoMode (int widt { video->is_32bit = 1; SDL_VideoSurface = SDL_CreateRGBSurface( - flags, - width, - height, - 32, + flags, + width, + height, + 32, #if SDL_BYTEORDER == SDL_LIL_ENDIAN 0x000000FF, 0x0000FF00, @@ -893,7 +897,7 @@ SDL_Surface * SDL_SetVideoMode (int widt ( ( !(flags&SDL_ANYFORMAT) && (SDL_VideoSurface->format->BitsPerPixel != bpp)) || - ( (flags&SDL_HWPALETTE) && + ( (flags&SDL_HWPALETTE) && !(SDL_VideoSurface->flags&SDL_HWPALETTE)) || /* If the surface is in hardware, video writes are visible as soon as they are performed, so we need to buffer them @@ -921,7 +925,7 @@ SDL_Surface * SDL_SetVideoMode (int widt return(SDL_PublicSurface); } -/* +/* * Convert a surface into the video pixel format. */ SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface) @@ -935,7 +939,7 @@ SDL_Surface * SDL_DisplayFormat (SDL_Sur /* Set the flags appropriate for copying to display surface */ if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw) flags = SDL_HWSURFACE; - else + else flags = SDL_SWSURFACE; #ifdef AUTORLE_DISPLAYFORMAT flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA)); @@ -1063,14 +1067,14 @@ void SDL_UpdateRects (SDL_Surface *scree SDL_LockCursor(); SDL_DrawCursor(SDL_ShadowSurface); for ( i=0; i 256 ) update.h = 256; - + this->glFlush(); - this->glTexSubImage2D( - GL_TEXTURE_2D, - 0, - 0, - 0, - update.w, - update.h, + this->glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + update.w, + update.h, this->is_32bit? GL_RGBA : GL_RGB, #ifdef GL_VERSION_1_2 this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5, #else GL_UNSIGNED_BYTE, #endif - (Uint8 *)this->screen->pixels + - this->screen->format->BytesPerPixel * update.x + + (Uint8 *)this->screen->pixels + + this->screen->format->BytesPerPixel * update.x + update.y * this->screen->pitch ); - + this->glFlush(); /* * Note the parens around the function name: - * This is because some OpenGL implementations define glTexCoord etc + * This is because some OpenGL implementations define glTexCoord etc * as macros, and we don't want them expanded here. */ this->glBegin(GL_TRIANGLE_STRIP); - (this->glTexCoord2f)( 0.0, 0.0 ); + (this->glTexCoord2f)( 0.0, 0.0 ); (this->glVertex2i)( update.x, update.y ); - (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); + (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); (this->glVertex2i)( update.x + update.w, update.y ); (this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) ); (this->glVertex2i)( update.x, update.y + update.h ); - (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); + (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); (this->glVertex2i)( update.x + update.w , update.y + update.h ); - this->glEnd(); - + this->glEnd(); + tmp.x += 256; tmp.w -= 256; } @@ -1641,7 +1645,7 @@ void SDL_GL_Lock() this->glDisable(GL_FOG); this->glDisable(GL_ALPHA_TEST); this->glDisable(GL_DEPTH_TEST); - this->glDisable(GL_SCISSOR_TEST); + this->glDisable(GL_SCISSOR_TEST); this->glDisable(GL_STENCIL_TEST); this->glDisable(GL_CULL_FACE);