os2: integrate the port into main tree.

This commit is contained in:
Ozkan Sezer 2020-10-14 23:01:06 +03:00
parent 20db1471e5
commit d27238751f
13 changed files with 104 additions and 8 deletions

View File

@ -12,6 +12,7 @@ LNKFILE = $(LIBNAME).lnk
INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
INCPATH+= -Iinclude INCPATH+= -Iinclude
INCPATH+= -I"src/core/os2" -I"src/core/os2/geniconv"
LIBM = libm.lib LIBM = libm.lib
LIBS = mmpm2.lib libuls.lib libconv.lib $(LIBM) LIBS = mmpm2.lib libuls.lib libconv.lib $(LIBM)
@ -26,6 +27,12 @@ CFLAGS+= $(INCPATH)
# building SDL itself (for DECLSPEC): # building SDL itself (for DECLSPEC):
CFLAGS+= -DBUILD_SDL CFLAGS+= -DBUILD_SDL
# Debug options:
# - debug messages from OS/2 related code to stdout:
#CFLAGS+= -DOS2DEBUG
# - debug messages from OS/2 code via SDL_LogDebug():
#CFLAGS+= -DOS2DEBUG=2
MSRCS= e_atan2.c e_exp.c e_fmod.c e_log10.c e_log.c e_pow.c e_rem_pio2.c e_sqrt.c & MSRCS= e_atan2.c e_exp.c e_fmod.c e_log10.c e_log.c e_pow.c e_rem_pio2.c e_sqrt.c &
k_cos.c k_rem_pio2.c k_sin.c k_tan.c & k_cos.c k_rem_pio2.c k_sin.c k_tan.c &
s_atan.c s_copysign.c s_cos.c s_fabs.c s_floor.c s_scalbn.c s_sin.c s_tan.c s_atan.c s_copysign.c s_cos.c s_fabs.c s_floor.c s_scalbn.c s_sin.c s_tan.c
@ -58,6 +65,11 @@ SRCS+= SDL_dummysensor.c
SRCS+= SDL_locale.c SDL_syslocale.c SRCS+= SDL_locale.c SDL_syslocale.c
SRCS+= SDL_url.c SDL_sysurl.c SRCS+= SDL_url.c SDL_sysurl.c
SRCS+= SDL_os2.c geniconv.c os2cp.c os2iconv.c sys2utf8.c
SRCS+= SDL_os2audio.c
SRCS+= SDL_os2video.c SDL_os2util.c SDL_os2dive.c SDL_os2vman.c &
SDL_os2mouse.c SDL_os2messagebox.c
SRCS+= SDL_dynapi.c SRCS+= SDL_dynapi.c
OBJS = $(SRCS:.c=.obj) OBJS = $(SRCS:.c=.obj)
@ -68,7 +80,7 @@ MOBJS= $(MSRCS:.c=.obj)
.c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/atomic;./src/audio/disk; .c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/atomic;./src/audio/disk;
.c: ./src/haptic/dummy;./src/joystick/dummy;./src/audio/dummy;./src/video/dummy;./src/sensor/dummy; .c: ./src/haptic/dummy;./src/joystick/dummy;./src/audio/dummy;./src/video/dummy;./src/sensor/dummy;
.c: ./src/loadso/dummy;./src/filesystem/dummy;./src/timer/dummy;./src/thread/generic; .c: ./src/core/os2;./src/core/os2/geniconv;./src/audio/os2;./src/loadso/os2;./src/filesystem/os2;./src/thread/os2;./src/timer/os2;./src/video/os2;
.c: ./src/locale/;./src/locale/unix;./src/misc;./src/misc/dummy; .c: ./src/locale/;./src/locale/unix;./src/misc;./src/misc/dummy;
all: $(DLLFILE) $(LIBFILE) .symbolic all: $(DLLFILE) $(LIBFILE) .symbolic
@ -84,6 +96,9 @@ $(LIBFILE): $(DLLFILE)
.c.obj: .c.obj:
wcc386 $(CFLAGS) -fo=$^@ $< wcc386 $(CFLAGS) -fo=$^@ $<
SDL_syscond.obj: "src/thread/generic/SDL_syscond.c"
wcc386 $(CFLAGS) -fo=$^@ $<
SDL_cpuinfo.obj: SDL_cpuinfo.c SDL_cpuinfo.obj: SDL_cpuinfo.c
wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $< wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<

View File

@ -27,6 +27,7 @@
#define SDL_AUDIO_DRIVER_DUMMY 1 #define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_OS2 1
#define SDL_POWER_DISABLED 1 #define SDL_POWER_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1 #define SDL_JOYSTICK_DISABLED 1
@ -34,6 +35,7 @@
#define SDL_SENSOR_DUMMY 1 #define SDL_SENSOR_DUMMY 1
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_OS2 1
/* Enable OpenGL support */ /* Enable OpenGL support */
/* #undef SDL_VIDEO_OPENGL */ /* #undef SDL_VIDEO_OPENGL */
@ -41,10 +43,10 @@
/* Enable Vulkan support */ /* Enable Vulkan support */
/* #undef SDL_VIDEO_VULKAN */ /* #undef SDL_VIDEO_VULKAN */
#define SDL_LOADSO_DISABLED 1 #define SDL_THREAD_OS2 1
#define SDL_THREADS_DISABLED 1 #define SDL_LOADSO_OS2 1
#define SDL_TIMERS_DISABLED 1 #define SDL_TIMER_OS2 1
#define SDL_FILESYSTEM_DUMMY 1 #define SDL_FILESYSTEM_OS2 1
/* Enable assembly routines */ /* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1 #define SDL_ASSEMBLY_ROUTINES 1

View File

@ -106,6 +106,11 @@ typedef void *EGLSurface;
#if defined(SDL_VIDEO_DRIVER_VIVANTE) #if defined(SDL_VIDEO_DRIVER_VIVANTE)
#include "SDL_egl.h" #include "SDL_egl.h"
#endif #endif
#if defined(SDL_VIDEO_DRIVER_OS2)
#define INCL_WIN
#include <os2.h>
#endif
#endif /* SDL_PROTOTYPES_ONLY */ #endif /* SDL_PROTOTYPES_ONLY */
@ -186,6 +191,16 @@ struct SDL_SysWMmsg
int dummy; int dummy;
/* No Vivante window events yet */ /* No Vivante window events yet */
} vivante; } vivante;
#endif
#if defined(SDL_VIDEO_DRIVER_OS2)
struct
{
BOOL fFrame; /**< TRUE if hwnd is a frame window */
HWND hwnd; /**< The window receiving the message */
ULONG msg; /**< The message identifier */
MPARAM mp1; /**< The first first message parameter */
MPARAM mp2; /**< The second first message parameter */
} os2;
#endif #endif
/* Can't have an empty union */ /* Can't have an empty union */
int dummy; int dummy;
@ -280,6 +295,14 @@ struct SDL_SysWMinfo
} android; } android;
#endif #endif
#if defined(SDL_VIDEO_DRIVER_OS2)
struct
{
HWND hwnd; /**< The window handle */
HWND hwndFrame; /**< The frame window handle */
} os2;
#endif
#if defined(SDL_VIDEO_DRIVER_VIVANTE) #if defined(SDL_VIDEO_DRIVER_VIVANTE)
struct struct
{ {

View File

@ -27,6 +27,12 @@
#elif !defined(__WINRT__) #elif !defined(__WINRT__)
#include <unistd.h> /* For _exit(), etc. */ #include <unistd.h> /* For _exit(), etc. */
#endif #endif
#if defined(__OS2__)
#include "core/os2/SDL_os2.h"
#endif
#if SDL_THREAD_OS2
#include "thread/os2/SDL_systls_c.h"
#endif
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
#include <emscripten.h> #include <emscripten.h>
@ -159,6 +165,10 @@ SDL_InitSubSystem(Uint32 flags)
flags |= SDL_INIT_EVENTS; flags |= SDL_INIT_EVENTS;
} }
#if SDL_THREAD_OS2
SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */
#endif
#if SDL_VIDEO_DRIVER_WINDOWS #if SDL_VIDEO_DRIVER_WINDOWS
if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
if (SDL_HelperWindowCreate() < 0) { if (SDL_HelperWindowCreate() < 0) {
@ -294,6 +304,13 @@ SDL_Init(Uint32 flags)
void void
SDL_QuitSubSystem(Uint32 flags) SDL_QuitSubSystem(Uint32 flags)
{ {
#if SDL_THREAD_OS2
SDL_OS2TLSFree(); /* thread/os2/SDL_systls.c */
#endif
#if defined(__OS2__)
SDL_OS2Quit();
#endif
/* Shut down requested initialized subsystems */ /* Shut down requested initialized subsystems */
#if !SDL_SENSOR_DISABLED #if !SDL_SENSOR_DISABLED
if ((flags & SDL_INIT_SENSOR)) { if ((flags & SDL_INIT_SENSOR)) {

View File

@ -104,6 +104,9 @@ static const AudioBootStrap *const bootstrap[] = {
#if SDL_AUDIO_DRIVER_JACK #if SDL_AUDIO_DRIVER_JACK
&JACK_bootstrap, &JACK_bootstrap,
#endif #endif
#if SDL_AUDIO_DRIVER_OS2
&OS2AUDIO_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_DISK #if SDL_AUDIO_DRIVER_DISK
&DISKAUDIO_bootstrap, &DISKAUDIO_bootstrap,
#endif #endif

View File

@ -207,6 +207,7 @@ extern AudioBootStrap openslES_bootstrap;
extern AudioBootStrap ANDROIDAUDIO_bootstrap; extern AudioBootStrap ANDROIDAUDIO_bootstrap;
extern AudioBootStrap PSPAUDIO_bootstrap; extern AudioBootStrap PSPAUDIO_bootstrap;
extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap;
extern AudioBootStrap OS2AUDIO_bootstrap;
#endif /* SDL_sysaudio_h_ */ #endif /* SDL_sysaudio_h_ */

View File

@ -32,6 +32,10 @@
#ifdef __WIN32__ #ifdef __WIN32__
#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() #include "../core/windows/SDL_windows.h" // For GetDoubleClickTime()
#endif #endif
#if defined(__OS2__)
#define INCL_WIN
#include <os2.h>
#endif
/* #define DEBUG_MOUSE */ /* #define DEBUG_MOUSE */
@ -54,6 +58,8 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol
} else { } else {
#ifdef __WIN32__ #ifdef __WIN32__
mouse->double_click_time = GetDoubleClickTime(); mouse->double_click_time = GetDoubleClickTime();
#elif defined(__OS2__)
mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME);
#else #else
mouse->double_click_time = 500; mouse->double_click_time = 500;
#endif #endif

View File

@ -36,6 +36,8 @@
#include "psp/SDL_systhread_c.h" #include "psp/SDL_systhread_c.h"
#elif SDL_THREAD_STDCPP #elif SDL_THREAD_STDCPP
#include "stdcpp/SDL_systhread_c.h" #include "stdcpp/SDL_systhread_c.h"
#elif SDL_THREAD_OS2
#include "os2/SDL_systhread_c.h"
#else #else
#error Need thread implementation for this platform #error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h" #include "generic/SDL_systhread_c.h"

View File

@ -436,6 +436,8 @@ extern VideoBootStrap VIVANTE_bootstrap;
extern VideoBootStrap Emscripten_bootstrap; extern VideoBootStrap Emscripten_bootstrap;
extern VideoBootStrap QNX_bootstrap; extern VideoBootStrap QNX_bootstrap;
extern VideoBootStrap OFFSCREEN_bootstrap; extern VideoBootStrap OFFSCREEN_bootstrap;
extern VideoBootStrap OS2DIVE_bootstrap;
extern VideoBootStrap OS2VMAN_bootstrap;
extern SDL_VideoDevice *SDL_GetVideoDevice(void); extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);

View File

@ -112,6 +112,10 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_OFFSCREEN #if SDL_VIDEO_DRIVER_OFFSCREEN
&OFFSCREEN_bootstrap, &OFFSCREEN_bootstrap,
#endif #endif
#if SDL_VIDEO_DRIVER_OS2
&OS2DIVE_bootstrap,
&OS2VMAN_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DUMMY #if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap, &DUMMY_bootstrap,
#endif #endif
@ -3926,9 +3930,11 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
#if SDL_VIDEO_DRIVER_HAIKU #if SDL_VIDEO_DRIVER_HAIKU
#include "haiku/SDL_bmessagebox.h" #include "haiku/SDL_bmessagebox.h"
#endif #endif
#if SDL_VIDEO_DRIVER_OS2
#include "os2/SDL_os2messagebox.h"
#endif
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
{ {
SDL_SysWMinfo info; SDL_SysWMinfo info;
@ -4027,6 +4033,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) { HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0; retval = 0;
} }
#endif
#if SDL_VIDEO_DRIVER_OS2
if (retval == -1 &&
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_OS2) &&
OS2_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif #endif
if (retval == -1) { if (retval == -1) {
SDL_SetError("No message system available"); SDL_SetError("No message system available");

View File

@ -13,7 +13,7 @@ TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe &
testviewport.exe testwm2.exe torturethread.exe checkkeys.exe & testviewport.exe testwm2.exe torturethread.exe checkkeys.exe &
controllermap.exe testhaptic.exe testqsort.exe testresample.exe & controllermap.exe testhaptic.exe testqsort.exe testresample.exe &
testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.exe & testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.exe &
testyuv.exe testgl2.exe testvulkan.exe testautomation.exe testyuv.exe testgl2.exe testvulkan.exe testnative.exe testautomation.exe
# SDL2test.lib sources (../src/test) # SDL2test.lib sources (../src/test)
@ -69,6 +69,10 @@ testautomation.exe: $(TAOBJS)
@%make $(TESTLIB) @%make $(TESTLIB)
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
testnative.exe: testnative.obj testnativeos2.obj
@%make $(TESTLIB)
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj
@%make $(TESTLIB) @%make $(TESTLIB)
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@

View File

@ -31,6 +31,9 @@ static NativeWindowFactory *factories[] = {
#endif #endif
#ifdef TEST_NATIVE_COCOA #ifdef TEST_NATIVE_COCOA
&CocoaWindowFactory, &CocoaWindowFactory,
#endif
#ifdef TEST_NATIVE_OS2
&OS2WindowFactory,
#endif #endif
NULL NULL
}; };

View File

@ -44,3 +44,8 @@ extern NativeWindowFactory X11WindowFactory;
#define TEST_NATIVE_COCOA #define TEST_NATIVE_COCOA
extern NativeWindowFactory CocoaWindowFactory; extern NativeWindowFactory CocoaWindowFactory;
#endif #endif
#ifdef SDL_VIDEO_DRIVER_OS2
#define TEST_NATIVE_OS2
extern NativeWindowFactory OS2WindowFactory;
#endif