os2: integrate the port into main tree.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
diff --git a/Makefile.os2 b/Makefile.os2
index b23be13..68eece1 100644
--- a/Makefile.os2
+++ b/Makefile.os2
@@ -12,6 +12,7 @@ LNKFILE = $(LIBNAME).lnk
INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
INCPATH+= -Iinclude
+INCPATH+= -I"src/core/os2" -I"src/core/os2/geniconv"
LIBM = libm.lib
LIBS = mmpm2.lib libuls.lib libconv.lib $(LIBM)
@@ -26,6 +27,12 @@ CFLAGS+= $(INCPATH)
# building SDL itself (for DECLSPEC):
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 &
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
@@ -58,6 +65,11 @@ SRCS+= SDL_dummysensor.c
SRCS+= SDL_locale.c SDL_syslocale.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
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/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;
all: $(DLLFILE) $(LIBFILE) .symbolic
@@ -84,6 +96,9 @@ $(LIBFILE): $(DLLFILE)
.c.obj:
wcc386 $(CFLAGS) -fo=$^@ $<
+SDL_syscond.obj: "src/thread/generic/SDL_syscond.c"
+ wcc386 $(CFLAGS) -fo=$^@ $<
+
SDL_cpuinfo.obj: SDL_cpuinfo.c
wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h
index eedf79c..ea483b6 100644
--- a/include/SDL_config_os2.h
+++ b/include/SDL_config_os2.h
@@ -27,6 +27,7 @@
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_OS2 1
#define SDL_POWER_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1
@@ -34,6 +35,7 @@
#define SDL_SENSOR_DUMMY 1
#define SDL_VIDEO_DRIVER_DUMMY 1
+#define SDL_VIDEO_DRIVER_OS2 1
/* Enable OpenGL support */
/* #undef SDL_VIDEO_OPENGL */
@@ -41,10 +43,10 @@
/* Enable Vulkan support */
/* #undef SDL_VIDEO_VULKAN */
-#define SDL_LOADSO_DISABLED 1
-#define SDL_THREADS_DISABLED 1
-#define SDL_TIMERS_DISABLED 1
-#define SDL_FILESYSTEM_DUMMY 1
+#define SDL_THREAD_OS2 1
+#define SDL_LOADSO_OS2 1
+#define SDL_TIMER_OS2 1
+#define SDL_FILESYSTEM_OS2 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h
index e877b2a..f0e9675 100644
--- a/include/SDL_syswm.h
+++ b/include/SDL_syswm.h
@@ -106,6 +106,11 @@ typedef void *EGLSurface;
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
#include "SDL_egl.h"
#endif
+
+#if defined(SDL_VIDEO_DRIVER_OS2)
+#define INCL_WIN
+#include <os2.h>
+#endif
#endif /* SDL_PROTOTYPES_ONLY */
@@ -187,6 +192,16 @@ struct SDL_SysWMmsg
/* No Vivante window events yet */
} 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
/* Can't have an empty union */
int dummy;
} msg;
@@ -280,6 +295,14 @@ struct SDL_SysWMinfo
} android;
#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)
struct
{
diff --git a/src/SDL.c b/src/SDL.c
index 680ed2e..02e131b 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -27,6 +27,12 @@
#elif !defined(__WINRT__)
#include <unistd.h> /* For _exit(), etc. */
#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__)
#include <emscripten.h>
@@ -159,6 +165,10 @@ SDL_InitSubSystem(Uint32 flags)
flags |= SDL_INIT_EVENTS;
}
+#if SDL_THREAD_OS2
+ SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */
+#endif
+
#if SDL_VIDEO_DRIVER_WINDOWS
if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
if (SDL_HelperWindowCreate() < 0) {
@@ -294,6 +304,13 @@ SDL_Init(Uint32 flags)
void
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 */
#if !SDL_SENSOR_DISABLED
if ((flags & SDL_INIT_SENSOR)) {
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 3137493..bacee6c 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -104,6 +104,9 @@ static const AudioBootStrap *const bootstrap[] = {
#if SDL_AUDIO_DRIVER_JACK
&JACK_bootstrap,
#endif
+#if SDL_AUDIO_DRIVER_OS2
+ &OS2AUDIO_bootstrap,
+#endif
#if SDL_AUDIO_DRIVER_DISK
&DISKAUDIO_bootstrap,
#endif
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index 7359adc..350a6d0 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -207,6 +207,7 @@ extern AudioBootStrap openslES_bootstrap;
extern AudioBootStrap ANDROIDAUDIO_bootstrap;
extern AudioBootStrap PSPAUDIO_bootstrap;
extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap;
+extern AudioBootStrap OS2AUDIO_bootstrap;
#endif /* SDL_sysaudio_h_ */
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 03bae6b..50065e4 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -32,6 +32,10 @@
#ifdef __WIN32__
#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime()
#endif
+#if defined(__OS2__)
+#define INCL_WIN
+#include <os2.h>
+#endif
/* #define DEBUG_MOUSE */
@@ -54,6 +58,8 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol
} else {
#ifdef __WIN32__
mouse->double_click_time = GetDoubleClickTime();
+#elif defined(__OS2__)
+ mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME);
#else
mouse->double_click_time = 500;
#endif
diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h
index ac0071e..c82b59e 100644
--- a/src/thread/SDL_thread_c.h
+++ b/src/thread/SDL_thread_c.h
@@ -36,6 +36,8 @@
#include "psp/SDL_systhread_c.h"
#elif SDL_THREAD_STDCPP
#include "stdcpp/SDL_systhread_c.h"
+#elif SDL_THREAD_OS2
+#include "os2/SDL_systhread_c.h"
#else
#error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h"
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 81322b3..0567035 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -436,6 +436,8 @@ extern VideoBootStrap VIVANTE_bootstrap;
extern VideoBootStrap Emscripten_bootstrap;
extern VideoBootStrap QNX_bootstrap;
extern VideoBootStrap OFFSCREEN_bootstrap;
+extern VideoBootStrap OS2DIVE_bootstrap;
+extern VideoBootStrap OS2VMAN_bootstrap;
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 3f89c43..36d42ce 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -112,6 +112,10 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_OFFSCREEN
&OFFSCREEN_bootstrap,
#endif
+#if SDL_VIDEO_DRIVER_OS2
+ &OS2DIVE_bootstrap,
+ &OS2VMAN_bootstrap,
+#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
#endif
@@ -3926,9 +3930,11 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
#if SDL_VIDEO_DRIVER_HAIKU
#include "haiku/SDL_bmessagebox.h"
#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
+#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
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
{
SDL_SysWMinfo info;
@@ -4028,6 +4034,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
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
if (retval == -1) {
SDL_SetError("No message system available");
}
diff --git a/test/Makefile.os2 b/test/Makefile.os2
index f9ec898..7676369 100644
--- a/test/Makefile.os2
+++ b/test/Makefile.os2
@@ -13,7 +13,7 @@ TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe &
testviewport.exe testwm2.exe torturethread.exe checkkeys.exe &
controllermap.exe testhaptic.exe testqsort.exe testresample.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)
@@ -69,6 +69,10 @@ testautomation.exe: $(TAOBJS)
@%make $(TESTLIB)
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
@%make $(TESTLIB)
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
diff --git a/test/testnative.c b/test/testnative.c
index 353262b..675c8f4 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -32,6 +32,9 @@ static NativeWindowFactory *factories[] = {
#ifdef TEST_NATIVE_COCOA
&CocoaWindowFactory,
#endif
+#ifdef TEST_NATIVE_OS2
+ &OS2WindowFactory,
+#endif
NULL
};
static NativeWindowFactory *factory = NULL;
diff --git a/test/testnative.h b/test/testnative.h
index 428d607..d7b40fb 100644
--- a/test/testnative.h
+++ b/test/testnative.h
@@ -44,3 +44,8 @@ extern NativeWindowFactory X11WindowFactory;
#define TEST_NATIVE_COCOA
extern NativeWindowFactory CocoaWindowFactory;
#endif
+
+#ifdef SDL_VIDEO_DRIVER_OS2
+#define TEST_NATIVE_OS2
+extern NativeWindowFactory OS2WindowFactory;
+#endif