123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
- 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_sysvideo.h"
- #ifdef SDL_VIDEO_DRIVER_NGAGE
- #include "SDL_ngagevideo.h"
- #define NGAGE_VIDEO_DRIVER_NAME "N-Gage"
- static void NGAGE_DeleteDevice(SDL_VideoDevice *device);
- static bool NGAGE_VideoInit(SDL_VideoDevice *device);
- static void NGAGE_VideoQuit(SDL_VideoDevice *device);
- static bool NGAGE_GetDisplayBounds(SDL_VideoDevice *device, SDL_VideoDisplay *display, SDL_Rect *rect);
- static bool NGAGE_GetDisplayModes(SDL_VideoDevice *device, SDL_VideoDisplay *display);
- static void NGAGE_PumpEvents(SDL_VideoDevice *device);
- static bool NGAGE_SuspendScreenSaver(SDL_VideoDevice *device);
- 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) {
- SDL_OutOfMemory();
- return (SDL_VideoDevice *)0;
- }
- // Initialize internal N-Gage specific data.
- phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
- if (!phdata) {
- SDL_OutOfMemory();
- SDL_free(device);
- return (SDL_VideoDevice *)0;
- }
- device->internal = phdata;
- device->name = "Nokia N-Gage";
- device->VideoInit = NGAGE_VideoInit;
- device->VideoQuit = NGAGE_VideoQuit;
- device->GetDisplayBounds = NGAGE_GetDisplayBounds;
- device->GetDisplayModes = NGAGE_GetDisplayModes;
- device->PumpEvents = NGAGE_PumpEvents;
- device->SuspendScreenSaver = NGAGE_SuspendScreenSaver;
- device->free = NGAGE_DeleteDevice;
- device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY;
- return device;
- }
- VideoBootStrap NGAGE_bootstrap = {
- NGAGE_VIDEO_DRIVER_NAME,
- "N-Gage Video Driver",
- NGAGE_CreateDevice,
- 0
- };
- static void NGAGE_DeleteDevice(SDL_VideoDevice *device)
- {
- SDL_free(device->internal);
- SDL_free(device);
- }
- static bool NGAGE_VideoInit(SDL_VideoDevice *device)
- {
- SDL_VideoData *phdata = (SDL_VideoData *)device->internal;
- if (!phdata) {
- return false;
- }
- SDL_zero(phdata->mode);
- SDL_zero(phdata->display);
- phdata->mode.w = 176;
- phdata->mode.h = 208;
- phdata->mode.refresh_rate = 60.0f;
- phdata->mode.format = SDL_PIXELFORMAT_ARGB4444;
- phdata->display.name = "N-Gage";
- phdata->display.desktop_mode = phdata->mode;
- if (SDL_AddVideoDisplay(&phdata->display, false) == 0) {
- return false;
- }
- return true;
- }
- static void NGAGE_VideoQuit(SDL_VideoDevice *device)
- {
- SDL_VideoData *phdata = (SDL_VideoData *)device->internal;
- if (phdata) {
- SDL_zero(phdata->mode);
- SDL_zero(phdata->display);
- }
- }
- static bool NGAGE_GetDisplayBounds(SDL_VideoDevice *device, SDL_VideoDisplay *display, SDL_Rect *rect)
- {
- if (!display) {
- return false;
- }
- rect->x = 0;
- rect->y = 0;
- rect->w = display->current_mode->w;
- rect->h = display->current_mode->h;
- return true;
- }
- static bool NGAGE_GetDisplayModes(SDL_VideoDevice *device, SDL_VideoDisplay *display)
- {
- SDL_VideoData *phdata = (SDL_VideoData *)device->internal;
- SDL_DisplayMode mode;
- SDL_zero(mode);
- mode.w = phdata->mode.w;
- mode.h = phdata->mode.h;
- mode.refresh_rate = phdata->mode.refresh_rate;
- mode.format = phdata->mode.format;
- if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
- return false;
- }
- return true;
- }
- #include "../../render/ngage/SDL_render_ngage_c.h"
- static void NGAGE_PumpEvents(SDL_VideoDevice *device)
- {
- NGAGE_PumpEventsInternal();
- }
- static bool NGAGE_SuspendScreenSaver(SDL_VideoDevice *device)
- {
- NGAGE_SuspendScreenSaverInternal(device->suspend_screensaver);
- return true;
- }
- #endif // SDL_VIDEO_DRIVER_NGAGE
|