ngage: Remove Nokia N-Gage support.

This can be reverted if a toolchain arrives that can handle C99 features like
variables declared in the middle of a scope, but for now we literally can't
compile SDL3 for this platform.

Fixes #11243.
This commit is contained in:
Ryan C. Gordon committed 2024-12-11 13:29:43 -05:00
1 parent 3f425b6f20
commit f45ce45603
28 files changed
+4 -1743

No files matched your search

-2
View File
@@ -742,8 +742,6 @@ const char *SDL_GetPlatform(void)
return "PlayStation Portable";
#elif defined(SDL_PLATFORM_VITA)
return "PlayStation Vita";
#elif defined(SDL_PLATFORM_NGAGE)
return "Nokia N-Gage";
#elif defined(SDL_PLATFORM_3DS)
return "Nintendo 3DS";
#elif defined(__managarm__)
-2
View File
@@ -61,8 +61,6 @@
#define SDL_DYNAMIC_API 0 // Turn off for static analysis, so reports are more clear.
#elif defined(SDL_PLATFORM_VITA)
#define SDL_DYNAMIC_API 0 // vitasdk doesn't support dynamic linking
#elif defined(SDL_PLATFORM_NGAGE)
#define SDL_DYNAMIC_API 0 // The N-Gage doesn't support dynamic linking either
#elif defined(SDL_PLATFORM_3DS)
#define SDL_DYNAMIC_API 0 // devkitARM doesn't support dynamic linking
#elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN)
-77
View File
@@ -1,77 +0,0 @@
/*
based on SDL_ngage_main.c, originally for SDL 1.2 by Hannu Viitala
*/
#include "SDL_internal.h"
#ifdef SDL_PLATFORM_NGAGE
#include <e32std.h>
#include <e32def.h>
#include <e32svr.h>
#include <e32base.h>
#include <estlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <w32std.h>
#include <apgtask.h>
int SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * reserved)
{
(void)argc_; (void)argv_; (void)reserved;
// Get the clean-up stack
CTrapCleanup *cleanup = CTrapCleanup::New();
// Arrange for multi-threaded operation
SpawnPosixServerThread();
// Get args and environment
int argc = 0;
char **argv = 0;
char **envp = 0;
__crt0(argc, argv, envp);
// Start the application!
// Create stdlib
_REENT;
// Set process and thread priority and name
RThread currentThread;
RProcess thisProcess;
TParse exeName;
exeName.Set(thisProcess.FileName(), NULL, NULL);
currentThread.Rename(exeName.Name());
currentThread.SetProcessPriority(EPriorityLow);
currentThread.SetPriority(EPriorityMuchLess);
// Increase heap size
RHeap *newHeap = NULL;
RHeap *oldHeap = NULL;
TInt heapSize = 7500000;
int ret;
newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy);
if (!newHeap) {
ret = 3;
goto cleanup;
} else {
oldHeap = User::SwitchHeap(newHeap);
// Call stdlib main
SDL_SetMainReady();
ret = mainFunction(argc, argv);
}
cleanup:
_cleanup();
CloseSTDLIB();
delete cleanup;
return ret;
}
#endif // SDL_PLATFORM_NGAGE
+1 -5
View File
@@ -20,11 +20,7 @@
*/
// Do our best to make sure va_copy is working
#ifdef SDL_PLATFORM_NGAGE
#undef va_copy
#define va_copy(dst, src) dst = src
#elif defined(_MSC_VER) && _MSC_VER <= 1800
#if defined(_MSC_VER) && _MSC_VER <= 1800
// Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment
#undef va_copy
#define va_copy(dst, src) dst = src
-2
View File
@@ -38,8 +38,6 @@
#include "vita/SDL_systhread_c.h"
#elif defined(SDL_THREAD_N3DS)
#include "n3ds/SDL_systhread_c.h"
#elif defined(SDL_THREAD_NGAGE)
#include "ngage/SDL_systhread_c.h"
#else
#error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h"
-100
View File
@@ -1,100 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
// An implementation of mutexes using the Symbian API.
#include <e32std.h>
#include "SDL_systhread_c.h"
struct SDL_Mutex
{
TInt handle;
};
extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *);
static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *)
{
return ((RMutex *)aPtr1)->CreateGlobal(aName);
}
// Create a mutex
SDL_Mutex *SDL_CreateMutex(void)
{
RMutex rmutex;
TInt status = CreateUnique(NewMutex, &rmutex, NULL);
if (status != KErrNone) {
SDL_SetError("Couldn't create mutex.");
return NULL;
}
SDL_Mutex *mutex = new /*(ELeave)*/ SDL_Mutex;
mutex->handle = rmutex.Handle();
return mutex;
}
// Free the mutex
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Signal();
rmutex.Close();
delete (mutex);
mutex = NULL;
}
}
// Lock the mutex
void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
{
if (mutex) {
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Wait();
}
}
// Try to lock the mutex
#if 0
bool SDL_TryLockMutex(SDL_Mutex *mutex)
{
if (mutex) {
// Not yet implemented.
return true;
}
return true;
}
#endif
// Unlock the mutex
void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
{
if (mutex) {
RMutex rmutex;
rmutex.SetHandle(mutex->handle);
rmutex.Signal();
}
}
-157
View File
@@ -1,157 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
// An implementation of semaphores using the Symbian API.
#include <e32std.h>
struct SDL_Semaphore
{
TInt handle;
TInt count;
};
struct TInfo
{
TInfo(TInt aTime, TInt aHandle) : iTime(aTime), iHandle(aHandle), iVal(true) {}
TInt iTime;
TInt iHandle;
bool iVal;
};
extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *);
static TBool RunThread(TAny *aInfo)
{
TInfo *info = STATIC_CAST(TInfo *, aInfo);
User::After(info->iTime);
RSemaphore sema;
sema.SetHandle(info->iHandle);
sema.Signal();
info->iVal = false;
return 0;
}
static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
{
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
}
static TInt NewSema(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
{
TInt value = *((TInt *)aPtr2);
return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value);
}
static void WaitAll(SDL_Semaphore *sem)
{
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Wait();
while (sem->count < 0) {
sema.Wait();
}
}
SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
{
RSemaphore s;
TInt status = CreateUnique(NewSema, &s, &initial_value);
if (status != KErrNone) {
SDL_SetError("Couldn't create semaphore");
}
SDL_Semaphore *sem = new /*(ELeave)*/ SDL_Semaphore;
sem->handle = s.Handle();
sem->count = initial_value;
return sem;
}
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem) {
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Signal(sema.Count());
sema.Close();
delete sem;
sem = NULL;
}
}
bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
if (!sem) {
return true;
}
if (timeoutNS == 0) {
if (sem->count > 0) {
--sem->count;
return true;
}
return false;
}
if (timeoutNS == -1) { // -1 == wait indefinitely.
WaitAll(sem);
return true;
}
RThread thread;
TInfo *info = new (ELeave) TInfo((TInt)SDL_NS_TO_MS(timeoutNS), sem->handle);
TInt status = CreateUnique(NewThread, &thread, info);
if (status != KErrNone) {
return false;
}
thread.Resume();
WaitAll(sem);
if (thread.ExitType() == EExitPending) {
thread.Kill(false);
}
thread.Close();
return info->iVal;
}
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
{
if (!sem) {
SDL_InvalidParamError("sem");
return 0;
}
return sem->count;
}
int SDL_SignalSemaphore(SDL_Semaphore *sem)
{
if (!sem) {
return SDL_InvalidParamError("sem");
}
sem->count++;
RSemaphore sema;
sema.SetHandle(sem->handle);
sema.Signal();
return 0;
}
-112
View File
@@ -1,112 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_THREAD_NGAGE
// N-Gage thread management routines for SDL
#include <e32std.h>
extern "C" {
#undef NULL
#include "../SDL_systhread.h"
#include "../SDL_thread_c.h"
};
static int object_count;
static int RunThread(TAny *data)
{
SDL_RunThread((SDL_Thread *)data);
return 0;
}
static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
{
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
}
int CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *aPtr1, TAny *aPtr2)
{
TBuf<16> name;
TInt status = KErrNone;
do {
object_count++;
name.Format(_L("SDL_%x"), object_count);
status = aFunc(name, aPtr1, aPtr2);
} while (status == KErrAlreadyExists);
return status;
}
bool SDL_SYS_CreateThread(SDL_Thread *thread,
SDL_FunctionPointer pfnBeginThread,
SDL_FunctionPointer pfnEndThread)
{
RThread rthread;
TInt status = CreateUnique(NewThread, &rthread, thread);
if (status != KErrNone) {
delete (RThread *)thread->handle;
thread->handle = NULL;
return SDL_SetError("Not enough resources to create thread");
}
rthread.Resume();
thread->handle = rthread.Handle();
return true;
}
void SDL_SYS_SetupThread(const char *name)
{
return;
}
SDL_ThreadID SDL_GetCurrentThreadID(void)
{
RThread current;
TThreadId id = current.Id();
return id;
}
bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
return true;
}
void SDL_SYS_WaitThread(SDL_Thread *thread)
{
RThread t;
t.Open(thread->threadid);
if (t.ExitReason() == EExitPending) {
TRequestStatus status;
t.Logon(status);
User::WaitForRequest(status);
}
t.Close();
}
void SDL_SYS_DetachThread(SDL_Thread *thread)
{
return;
}
#endif // SDL_THREAD_NGAGE
-23
View File
@@ -1,23 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
typedef int SYS_ThreadHandle;
-59
View File
@@ -1,59 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_TIMER_NGAGE
#include <e32std.h>
#include <e32hal.h>
static TUint start_tick = 0;
#ifdef __cplusplus
extern "C" {
#endif
Uint64 SDL_GetPerformanceCounter(void)
{
// FIXME: Need to account for 32-bit wrapping
return (Uint64)User::TickCount();
}
Uint64 SDL_GetPerformanceFrequency(void)
{
return SDL_US_PER_SECOND;
}
void SDL_SYS_DelayNS(Uint64 ns)
{
const Uint64 max_delay = 0x7fffffffLL * SDL_NS_PER_US;
if (ns > max_delay) {
ns = max_delay;
}
User::After(TTimeIntervalMicroSeconds32((TInt)SDL_NS_TO_US(ns)));
}
#ifdef __cplusplus
}
#endif
#endif // SDL_TIMER_NGAGE
-1
View File
@@ -521,7 +521,6 @@ extern VideoBootStrap Wayland_bootstrap;
extern VideoBootStrap VIVANTE_bootstrap;
extern VideoBootStrap Emscripten_bootstrap;
extern VideoBootStrap OFFSCREEN_bootstrap;
extern VideoBootStrap NGAGE_bootstrap;
extern VideoBootStrap QNX_bootstrap;
extern VideoBootStrap OPENVR_bootstrap;
-3
View File
@@ -128,9 +128,6 @@ static VideoBootStrap *bootstrap[] = {
#ifdef SDL_VIDEO_DRIVER_QNX
&QNX_bootstrap,
#endif
#ifdef SDL_VIDEO_DRIVER_NGAGE
&NGAGE_bootstrap,
#endif
#ifdef SDL_VIDEO_DRIVER_OFFSCREEN
&OFFSCREEN_bootstrap,
#endif
-192
View File
@@ -1,192 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_NGAGE
/* Being a ngage driver, there's no event stream. We just define stubs for
most of the API. */
#ifdef __cplusplus
extern "C" {
#endif
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_keyboard_c.h"
#ifdef __cplusplus
}
#endif
#include "SDL_ngagevideo.h"
#include "SDL_ngageevents_c.h"
static void HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent);
void NGAGE_PumpEvents(SDL_VideoDevice *_this)
{
SDL_VideoData *data = _this->internal;
while (data->NGAGE_WsEventStatus != KRequestPending) {
data->NGAGE_WsSession.GetEvent(data->NGAGE_WsEvent);
HandleWsEvent(_this, data->NGAGE_WsEvent);
data->NGAGE_WsEventStatus = KRequestPending;
data->NGAGE_WsSession.EventReady(&data->NGAGE_WsEventStatus);
}
}
/*****************************************************************************/
// Internal
/*****************************************************************************/
#include <bautils.h>
#include <hal.h>
extern void DisableKeyBlocking(SDL_VideoDevice *_this);
extern void RedrawWindowL(SDL_VideoDevice *_this);
TBool isCursorVisible = EFalse;
static SDL_Scancode ConvertScancode(SDL_VideoDevice *_this, int key)
{
SDL_Keycode scancode;
switch (key) {
case EStdKeyBackspace: // Clear key
scancode = SDL_SCANCODE_BACKSPACE;
break;
case 0x31: // 1
scancode = SDL_SCANCODE_1;
break;
case 0x32: // 2
scancode = SDL_SCANCODE_2;
break;
case 0x33: // 3
scancode = SDL_SCANCODE_3;
break;
case 0x34: // 4
scancode = SDL_SCANCODE_4;
break;
case 0x35: // 5
scancode = SDL_SCANCODE_5;
break;
case 0x36: // 6
scancode = SDL_SCANCODE_6;
break;
case 0x37: // 7
scancode = SDL_SCANCODE_7;
break;
case 0x38: // 8
scancode = SDL_SCANCODE_8;
break;
case 0x39: // 9
scancode = SDL_SCANCODE_9;
break;
case 0x30: // 0
scancode = SDL_SCANCODE_0;
break;
case 0x2a: // Asterisk
scancode = SDL_SCANCODE_ASTERISK;
break;
case EStdKeyHash: // Hash
scancode = SDL_SCANCODE_HASH;
break;
case EStdKeyDevice0: // Left softkey
scancode = SDL_SCANCODE_SOFTLEFT;
break;
case EStdKeyDevice1: // Right softkey
scancode = SDL_SCANCODE_SOFTRIGHT;
break;
case EStdKeyApplication0: // Call softkey
scancode = SDL_SCANCODE_CALL;
break;
case EStdKeyApplication1: // End call softkey
scancode = SDL_SCANCODE_ENDCALL;
break;
case EStdKeyDevice3: // Middle softkey
scancode = SDL_SCANCODE_SELECT;
break;
case EStdKeyUpArrow: // Up arrow
scancode = SDL_SCANCODE_UP;
break;
case EStdKeyDownArrow: // Down arrow
scancode = SDL_SCANCODE_DOWN;
break;
case EStdKeyLeftArrow: // Left arrow
scancode = SDL_SCANCODE_LEFT;
break;
case EStdKeyRightArrow: // Right arrow
scancode = SDL_SCANCODE_RIGHT;
break;
default:
scancode = SDL_SCANCODE_UNKNOWN;
break;
}
return scancode;
}
static void HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent)
{
SDL_VideoData *data = _this->internal;
switch (aWsEvent.Type()) {
case EEventKeyDown: // Key events
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), true);
break;
case EEventKeyUp: // Key events
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), false);
break;
case EEventFocusGained: // SDL window got focus
data->NGAGE_IsWindowFocused = ETrue;
// Draw window background and screen buffer
DisableKeyBlocking(_this);
RedrawWindowL(_this);
break;
case EEventFocusLost: // SDL window lost focus
{
data->NGAGE_IsWindowFocused = EFalse;
RWsSession s;
s.Connect();
RWindowGroup g(s);
g.Construct(TUint32(&g), EFalse);
g.EnableReceiptOfFocus(EFalse);
RWindow w(s);
w.Construct(g, TUint32(&w));
w.SetExtent(TPoint(0, 0), data->NGAGE_WsWindow.Size());
w.SetOrdinalPosition(0);
w.Activate();
w.Close();
g.Close();
s.Close();
break;
}
case EEventModifiersChanged:
break;
default:
break;
}
}
#endif // SDL_VIDEO_DRIVER_NGAGE
-26
View File
@@ -1,26 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#include "SDL_ngagevideo.h"
extern void NGAGE_PumpEvents(SDL_VideoDevice *_this);
-380
View File
@@ -1,380 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_NGAGE
#include <SDL.h>
#include "../SDL_sysvideo.h"
#include "SDL_ngagevideo.h"
#include "SDL_ngageframebuffer_c.h"
#define NGAGE_SURFACE "NGAGE_FrameBuffer"
/* For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit
*
* TUint16 is enough, but using TUint32 so we can use better instruction
* selection on ARMI.
*/
static TUint32 NGAGE_HWPalette_256_to_Screen[256];
bool GetBpp(TDisplayMode displaymode);
void DirectUpdate(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects);
void DrawBackground(SDL_VideoDevice *_this);
void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer);
void RedrawWindowL(SDL_VideoDevice *_this);
bool SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
{
SDL_VideoData *phdata = _this->internal;
SDL_Surface *surface;
const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB4444;
int w, h;
// Free the old framebuffer surface
SDL_NGAGE_DestroyWindowFramebuffer(_this, window);
// Create a new one
SDL_GetWindowSizeInPixels(window, &w, &h);
surface = SDL_CreateSurface(w, h, surface_format);
if (!surface) {
return false;
}
// Save the info and return!
SDL_SetWindowData(window, NGAGE_SURFACE, surface);
*format = surface_format;
*pixels = surface->pixels;
*pitch = surface->pitch;
// Initialise Epoc frame buffer
TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode();
TScreenInfoV01 screenInfo;
TPckg<TScreenInfoV01> sInfo(screenInfo);
UserSvr::ScreenInfo(sInfo);
phdata->NGAGE_ScreenSize = screenInfo.iScreenSize;
phdata->NGAGE_DisplayMode = displayMode;
phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid;
phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8 *)screenInfo.iScreenAddress : NULL;
phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1;
phdata->NGAGE_BytesPerScanLine = screenInfo.iScreenSize.iWidth * phdata->NGAGE_BytesPerPixel;
phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight;
SDL_Log("Screen width %d", screenInfo.iScreenSize.iWidth);
SDL_Log("Screen height %d", screenInfo.iScreenSize.iHeight);
SDL_Log("Screen dmode %d", displayMode);
SDL_Log("Screen valid %d", screenInfo.iScreenAddressValid);
SDL_Log("Bytes per pixel %d", phdata->NGAGE_BytesPerPixel);
SDL_Log("Bytes per scan line %d", phdata->NGAGE_BytesPerScanLine);
SDL_Log("Bytes per screen %d", phdata->NGAGE_BytesPerScreen);
/* It seems that in SA1100 machines for 8bpp displays there is a 512
* palette table at the beginning of the frame buffer.
*
* In 12 bpp machines the table has 16 entries.
*/
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8) {
phdata->NGAGE_FrameBuffer += 512;
} else {
phdata->NGAGE_FrameBuffer += 32;
}
#if 0
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12) {
phdata->NGAGE_FrameBuffer += 16 * 2;
}
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16) {
phdata->NGAGE_FrameBuffer += 16 * 2;
}
#endif
// Get draw device for updating the screen
TScreenInfoV01 screenInfo2;
NGAGE_Runtime::GetScreenInfo(screenInfo2);
TRAPD(status, phdata->NGAGE_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode));
User::LeaveIfError(status);
// Activate events for me
phdata->NGAGE_WsEventStatus = KRequestPending;
phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus);
SDL_Log("SDL:WsEventStatus");
User::WaitForRequest(phdata->NGAGE_WsEventStatus);
phdata->NGAGE_RedrawEventStatus = KRequestPending;
phdata->NGAGE_WsSession.RedrawReady(&phdata->NGAGE_RedrawEventStatus);
SDL_Log("SDL:RedrawEventStatus");
User::WaitForRequest(phdata->NGAGE_RedrawEventStatus);
phdata->NGAGE_WsWindow.PointerFilter(EPointerFilterDrag, 0);
phdata->NGAGE_ScreenOffset = TPoint(0, 0);
SDL_Log("SDL:DrawBackground");
DrawBackground(_this); // Clear screen
return true;
}
bool SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects)
{
DirectUpdate(_this, numrects, (SDL_Rect *)rects);
return true;
}
void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window)
{
SDL_Surface *surface;
surface = (SDL_Surface *)SDL_SetWindowData(window, NGAGE_SURFACE, NULL);
SDL_DestroySurface(surface);
}
/*****************************************************************************/
// Runtime
/*****************************************************************************/
#include <e32svr.h>
#include <hal_data.h>
#include <hal.h>
EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01 &screenInfo2)
{
TPckg<TScreenInfoV01> sInfo2(screenInfo2);
UserSvr::ScreenInfo(sInfo2);
}
/*****************************************************************************/
// Internal
/*****************************************************************************/
bool GetBpp(TDisplayMode displaymode)
{
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);
}
void DrawBackground(SDL_VideoDevice *_this)
{
SDL_VideoData *phdata = _this->internal;
// Draw background
TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer;
// Draw black background
Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen);
}
void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer)
{
SDL_VideoData *phdata = _this->internal;
SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
TInt i;
TDisplayMode displayMode = phdata->NGAGE_DisplayMode;
const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1;
const TPoint fixedOffset = phdata->NGAGE_ScreenOffset;
const TInt screenW = screen->w;
const TInt screenH = screen->h;
const TInt sourceScanlineLength = screenW;
const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth;
// Render the rectangles in the list
for (i = 0; i < numrects; ++i) {
const SDL_Rect &currentRect = rects[i];
SDL_Rect rect2;
rect2.x = currentRect.x;
rect2.y = currentRect.y;
rect2.w = currentRect.w;
rect2.h = currentRect.h;
if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */ {
continue;
}
// All variables are measured in pixels
// Check rects validity, i.e. upper and lower bounds
TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
if (maxX < 0 || maxY < 0) /* sanity check */ {
continue;
}
// Clip from bottom
maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight - 1);
// TODO: Clip from the right side
const TInt sourceRectWidth = maxX - rect2.x + 1;
const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
const TInt sourceRectHeight = maxY - rect2.y + 1;
const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
const TUint skipValue = 1; // 1 = No skip
TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength;
switch (screen->format->bits_per_pixel) {
case 12:
{
TUint16 *bitmapLine = (TUint16 *)screen->pixels + sourceStartOffset;
TUint16 *screenMemory = screenBuffer + targetStartOffset;
if (skipValue == 1) {
for (TInt y = 0; y < sourceRectHeight; y++) {
Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
} else {
for (TInt y = 0; y < sourceRectHeight; y++) {
TUint16 *bitmapPos = bitmapLine; // 2 bytes per pixel
TUint16 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel
for (TInt x = 0; x < sourceRectWidth; x++) {
__ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapLine < ((TUint16 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapLine >= (TUint16 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = *bitmapPos;
bitmapPos += skipValue;
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
} break;
// 256 color paletted mode: 8 bpp --> 12 bpp
default:
{
if (phdata->NGAGE_BytesPerPixel <= 2) {
TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset;
TUint16 *screenMemory = screenBuffer + targetStartOffset;
for (TInt y = 0; y < sourceRectHeight; y++) {
TUint8 *bitmapPos = bitmapLine; // 1 byte per pixel
TUint16 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel
// Convert each pixel from 256 palette to 4k color values
for (TInt x = 0; x < sourceRectWidth; x++) {
__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
} else {
TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset;
TUint32 *screenMemory = reinterpret_cast<TUint32 *>(screenBuffer + targetStartOffset);
for (TInt y = 0; y < sourceRectHeight; y++) {
TUint8 *bitmapPos = bitmapLine; // 1 byte per pixel
TUint32 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel
// Convert each pixel from 256 palette to 4k color values
for (TInt x = 0; x < sourceRectWidth; x++) {
__ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32 *>(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32 *>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
}
}
}
}
void DirectUpdate(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects)
{
SDL_VideoData *phdata = _this->internal;
if (!phdata->NGAGE_IsWindowFocused) {
SDL_PauseAudio(1);
SDL_Delay(1000);
return;
}
SDL_PauseAudio(0);
TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer;
#if 0
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
// ...
} else
#endif
{
DirectDraw(_this, numrects, rects, screenBuffer);
}
for (int i = 0; i < numrects; ++i) {
TInt aAx = rects[i].x;
TInt aAy = rects[i].y;
TInt aBx = rects[i].w;
TInt aBy = rects[i].h;
TRect rect2 = TRect(aAx, aAy, aBx, aBy);
phdata->NGAGE_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only?
phdata->NGAGE_DrawDevice->Update();
}
}
void RedrawWindowL(SDL_VideoDevice *_this)
{
SDL_VideoData *phdata = _this->internal;
SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
int w = screen->w;
int h = screen->h;
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
w = screen->h;
h = screen->w;
}
if ((w < phdata->NGAGE_ScreenSize.iWidth) || (h < phdata->NGAGE_ScreenSize.iHeight)) {
DrawBackground(_this);
}
// Tell the system that something has been drawn
TRect rect = TRect(phdata->NGAGE_WsWindow.Size());
phdata->NGAGE_WsWindow.Invalidate(rect);
// Draw current buffer
SDL_Rect fullScreen;
fullScreen.x = 0;
fullScreen.y = 0;
fullScreen.w = screen->w;
fullScreen.h = screen->h;
DirectUpdate(_this, 1, &fullScreen);
}
#endif // SDL_VIDEO_DRIVER_NGAGE
-36
View File
@@ -1,36 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
extern bool SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
extern bool SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
/****************************************************************************/
// Runtime
/****************************************************************************/
class NGAGE_Runtime
{
public:
IMPORT_C static void GetScreenInfo(TScreenInfoV01 &screenInfo2);
};
-164
View File
@@ -1,164 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <stdlib.h>
#ifdef NULL
#undef NULL
#endif
#include "SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_NGAGE
#ifdef __cplusplus
extern "C" {
#endif
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#ifdef __cplusplus
}
#endif
#include "SDL_ngagevideo.h"
#include "SDL_ngagewindow.h"
#include "SDL_ngageevents_c.h"
#include "SDL_ngageframebuffer_c.h"
#define NGAGEVID_DRIVER_NAME "ngage"
// Initialization/Query functions
static bool NGAGE_VideoInit(SDL_VideoDevice *_this);
static void NGAGE_VideoQuit(SDL_VideoDevice *_this);
// NGAGE driver bootstrap functions
static void NGAGE_DeleteDevice(SDL_VideoDevice *device)
{
SDL_VideoData *phdata = device->internal;
if (phdata) {
// Free Epoc resources
// Disable events for me
if (phdata->NGAGE_WsEventStatus != KRequestPending) {
phdata->NGAGE_WsSession.EventReadyCancel();
}
if (phdata->NGAGE_RedrawEventStatus != KRequestPending) {
phdata->NGAGE_WsSession.RedrawReadyCancel();
}
free(phdata->NGAGE_DrawDevice); // This should NOT be SDL_free()
if (phdata->NGAGE_WsWindow.WsHandle()) {
phdata->NGAGE_WsWindow.Close();
}
if (phdata->NGAGE_WsWindowGroup.WsHandle()) {
phdata->NGAGE_WsWindowGroup.Close();
}
delete phdata->NGAGE_WindowGc;
phdata->NGAGE_WindowGc = NULL;
delete phdata->NGAGE_WsScreen;
phdata->NGAGE_WsScreen = NULL;
if (phdata->NGAGE_WsSession.WsHandle()) {
phdata->NGAGE_WsSession.Close();
}
SDL_free(phdata);
phdata = NULL;
}
if (device) {
SDL_free(device);
device = NULL;
}
}
static SDL_VideoDevice *NGAGE_CreateDevice(void)
{
SDL_VideoDevice *device;
SDL_VideoData *phdata;
// Initialize all variables that we clean on shutdown
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
return NULL;
}
// Initialize internal N-Gage specific data
phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
if (!phdata) {
SDL_free(device);
return NULL;
}
// General video
device->VideoInit = NGAGE_VideoInit;
device->VideoQuit = NGAGE_VideoQuit;
device->PumpEvents = NGAGE_PumpEvents;
device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer;
device->free = NGAGE_DeleteDevice;
// "Window"
device->CreateSDLWindow = NGAGE_CreateWindow;
device->DestroyWindow = NGAGE_DestroyWindow;
// N-Gage specific data
device->internal = phdata;
return device;
}
VideoBootStrap NGAGE_bootstrap = {
NGAGEVID_DRIVER_NAME, "SDL ngage video driver",
NGAGE_CreateDevice,
NULL // no ShowMessageBox implementation
};
static bool NGAGE_VideoInit(SDL_VideoDevice *_this)
{
SDL_DisplayMode mode;
// Use 12-bpp desktop mode
SDL_zero(mode);
mode.format = SDL_PIXELFORMAT_XRGB4444;
mode.w = 176;
mode.h = 208;
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
return false;
}
// We're done!
return true;
}
static void NGAGE_VideoQuit(SDL_VideoDevice *_this)
{
}
#endif // SDL_VIDEO_DRIVER_NGAGE
-65
View File
@@ -1,65 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifndef SDL_ngagevideo_h
#define SDL_ngagevideo_h
#include "../SDL_sysvideo.h"
#include <e32std.h>
#include <e32svr.h>
#include <bitdev.h>
#include <w32std.h>
#include "bitdraw.h" // CFbsDrawDevice
#define SDL_VideoDevice *_this SDL_VideoDevice *_this
struct SDL_VideoData
{
// Epoc window server info
RWsSession NGAGE_WsSession;
RWindowGroup NGAGE_WsWindowGroup;
TInt NGAGE_WsWindowGroupID;
RWindow NGAGE_WsWindow;
CWsScreenDevice *NGAGE_WsScreen;
CWindowGc *NGAGE_WindowGc;
TRequestStatus NGAGE_WsEventStatus;
TRequestStatus NGAGE_RedrawEventStatus;
TWsEvent NGAGE_WsEvent;
CFbsDrawDevice *NGAGE_DrawDevice;
TBool NGAGE_IsWindowFocused; // Not used yet
// Screen hardware frame buffer info
TBool NGAGE_HasFrameBuffer;
TInt NGAGE_BytesPerPixel;
TInt NGAGE_BytesPerScanLine;
TInt NGAGE_BytesPerScreen;
TDisplayMode NGAGE_DisplayMode;
TSize NGAGE_ScreenSize;
TUint8 *NGAGE_FrameBuffer;
TPoint NGAGE_ScreenOffset;
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
};
#endif // SDL_ngagevideo_h
-125
View File
@@ -1,125 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_NGAGE
#include "../SDL_sysvideo.h"
#include "SDL_ngagewindow.h"
const TUint32 WindowClientHandle = 9210;
void DisableKeyBlocking(SDL_VideoDevice *_this);
void ConstructWindowL(SDL_VideoDevice *_this);
bool NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
{
NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window));
if (!ngage_window) {
return false;
}
window->internal = ngage_window;
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
window->x = 0;
}
if (window->y == SDL_WINDOWPOS_UNDEFINED) {
window->y = 0;
}
ngage_window->sdl_window = window;
ConstructWindowL(_this);
return true;
}
void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
{
NGAGE_Window *ngage_window = (NGAGE_Window *)window->internal;
if (ngage_window) {
SDL_free(ngage_window);
}
window->internal = NULL;
}
/*****************************************************************************/
// Internal
/*****************************************************************************/
void DisableKeyBlocking(SDL_VideoDevice *_this)
{
SDL_VideoData *phdata = _this->internal;
TRawEvent event;
event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51);
phdata->NGAGE_WsSession.SimulateRawEvent(event);
}
void ConstructWindowL(SDL_VideoDevice *_this)
{
SDL_VideoData *phdata = _this->internal;
TInt error;
error = phdata->NGAGE_WsSession.Connect();
User::LeaveIfError(error);
phdata->NGAGE_WsScreen = new (ELeave) CWsScreenDevice(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsScreen->Construct());
User::LeaveIfError(phdata->NGAGE_WsScreen->CreateContext(phdata->NGAGE_WindowGc));
phdata->NGAGE_WsWindowGroup = RWindowGroup(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsWindowGroup.Construct(WindowClientHandle));
phdata->NGAGE_WsWindowGroup.SetOrdinalPosition(0);
RProcess thisProcess;
TParse exeName;
exeName.Set(thisProcess.FileName(), NULL, NULL);
TBuf<32> winGroupName;
winGroupName.Append(0);
winGroupName.Append(0);
winGroupName.Append(0); // UID
winGroupName.Append(0);
winGroupName.Append(exeName.Name()); // Caption
winGroupName.Append(0);
winGroupName.Append(0); // DOC name
phdata->NGAGE_WsWindowGroup.SetName(winGroupName);
phdata->NGAGE_WsWindow = RWindow(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup, WindowClientHandle - 1));
phdata->NGAGE_WsWindow.SetBackgroundColor(KRgbWhite);
phdata->NGAGE_WsWindow.Activate();
phdata->NGAGE_WsWindow.SetSize(phdata->NGAGE_WsScreen->SizeInPixels());
phdata->NGAGE_WsWindow.SetVisible(ETrue);
phdata->NGAGE_WsWindowGroupID = phdata->NGAGE_WsWindowGroup.Identifier();
phdata->NGAGE_IsWindowFocused = EFalse;
DisableKeyBlocking(_this);
}
#endif // SDL_VIDEO_DRIVER_NGAGE
-38
View File
@@ -1,38 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_ngagewindow_h
#define SDL_ngagewindow_h
#include "../SDL_sysvideo.h"
#include "SDL_ngagevideo.h"
typedef struct
{
SDL_Window *sdl_window;
} NGAGE_Window;
extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
extern void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
#endif // SDL_ngagewindow