Atlas - SDL_ngagevideo.c
Home / ext / SDL / src / video / ngage Lines: 1 | Size: 4689 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#include "../SDL_sysvideo.h" 22 23#ifdef SDL_VIDEO_DRIVER_NGAGE 24 25#include "SDL_ngagevideo.h" 26 27#define NGAGE_VIDEO_DRIVER_NAME "N-Gage" 28 29static void NGAGE_DeleteDevice(SDL_VideoDevice *device); 30static bool NGAGE_VideoInit(SDL_VideoDevice *device); 31static void NGAGE_VideoQuit(SDL_VideoDevice *device); 32 33static bool NGAGE_GetDisplayBounds(SDL_VideoDevice *device, SDL_VideoDisplay *display, SDL_Rect *rect); 34static bool NGAGE_GetDisplayModes(SDL_VideoDevice *device, SDL_VideoDisplay *display); 35 36static void NGAGE_PumpEvents(SDL_VideoDevice *device); 37 38static bool NGAGE_SuspendScreenSaver(SDL_VideoDevice *device); 39 40static SDL_VideoDevice *NGAGE_CreateDevice(void) 41{ 42 SDL_VideoDevice *device; 43 SDL_VideoData *phdata; 44 45 // Initialize all variables that we clean on shutdown. 46 device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); 47 if (!device) { 48 SDL_OutOfMemory(); 49 return (SDL_VideoDevice *)0; 50 } 51 52 // Initialize internal N-Gage specific data. 53 phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); 54 if (!phdata) { 55 SDL_OutOfMemory(); 56 SDL_free(device); 57 return (SDL_VideoDevice *)0; 58 } 59 60 device->internal = phdata; 61 62 device->name = "Nokia N-Gage"; 63 64 device->VideoInit = NGAGE_VideoInit; 65 device->VideoQuit = NGAGE_VideoQuit; 66 67 device->GetDisplayBounds = NGAGE_GetDisplayBounds; 68 device->GetDisplayModes = NGAGE_GetDisplayModes; 69 70 device->PumpEvents = NGAGE_PumpEvents; 71 72 device->SuspendScreenSaver = NGAGE_SuspendScreenSaver; 73 74 device->free = NGAGE_DeleteDevice; 75 76 device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY; 77 78 return device; 79} 80 81VideoBootStrap NGAGE_bootstrap = { 82 NGAGE_VIDEO_DRIVER_NAME, 83 "N-Gage Video Driver", 84 NGAGE_CreateDevice, 85 0 86}; 87 88static void NGAGE_DeleteDevice(SDL_VideoDevice *device) 89{ 90 SDL_free(device->internal); 91 SDL_free(device); 92} 93 94static bool NGAGE_VideoInit(SDL_VideoDevice *device) 95{ 96 SDL_VideoData *phdata = (SDL_VideoData *)device->internal; 97 98 if (!phdata) { 99 return false; 100 } 101 102 SDL_zero(phdata->mode); 103 SDL_zero(phdata->display); 104 105 phdata->mode.w = 176; 106 phdata->mode.h = 208; 107 phdata->mode.refresh_rate = 60.0f; 108 phdata->mode.format = SDL_PIXELFORMAT_XRGB4444; 109 110 phdata->display.name = "N-Gage"; 111 phdata->display.desktop_mode = phdata->mode; 112 113 if (SDL_AddVideoDisplay(&phdata->display, false) == 0) { 114 return false; 115 } 116 117 return true; 118} 119 120static void NGAGE_VideoQuit(SDL_VideoDevice *device) 121{ 122 SDL_VideoData *phdata = (SDL_VideoData *)device->internal; 123 124 if (phdata) { 125 SDL_zero(phdata->mode); 126 SDL_zero(phdata->display); 127 } 128} 129 130static bool NGAGE_GetDisplayBounds(SDL_VideoDevice *device, SDL_VideoDisplay *display, SDL_Rect *rect) 131{ 132 if (!display) { 133 return false; 134 } 135 136 rect->x = 0; 137 rect->y = 0; 138 rect->w = display->current_mode->w; 139 rect->h = display->current_mode->h; 140 141 return true; 142} 143 144static bool NGAGE_GetDisplayModes(SDL_VideoDevice *device, SDL_VideoDisplay *display) 145{ 146 SDL_VideoData *phdata = (SDL_VideoData *)device->internal; 147 SDL_DisplayMode mode; 148 149 SDL_zero(mode); 150 mode.w = phdata->mode.w; 151 mode.h = phdata->mode.h; 152 mode.refresh_rate = phdata->mode.refresh_rate; 153 mode.format = phdata->mode.format; 154 155 if (!SDL_AddFullscreenDisplayMode(display, &mode)) { 156 return false; 157 } 158 159 return true; 160} 161 162#include "../../render/ngage/SDL_render_ngage_c.h" 163 164static void NGAGE_PumpEvents(SDL_VideoDevice *device) 165{ 166 NGAGE_PumpEventsInternal(); 167} 168 169static bool NGAGE_SuspendScreenSaver(SDL_VideoDevice *device) 170{ 171 NGAGE_SuspendScreenSaverInternal(device->suspend_screensaver); 172 return true; 173} 174 175#endif // SDL_VIDEO_DRIVER_NGAGE 176[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.