sdl

FORK: Simple Directmedia Layer
git clone https://git.neptards.moe/neptards/sdl.git
Log | Files | Refs

SDL_pspvideo.c (8156B)


      1 /*
      2   Simple DirectMedia Layer
      3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
      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 
     22 #include "../../SDL_internal.h"
     23 
     24 #if SDL_VIDEO_DRIVER_PSP
     25 
     26 /* SDL internals */
     27 #include "../SDL_sysvideo.h"
     28 #include "SDL_version.h"
     29 #include "SDL_syswm.h"
     30 #include "SDL_loadso.h"
     31 #include "SDL_events.h"
     32 #include "../../events/SDL_mouse_c.h"
     33 #include "../../events/SDL_keyboard_c.h"
     34 
     35 
     36 
     37 /* PSP declarations */
     38 #include "SDL_pspvideo.h"
     39 #include "SDL_pspevents_c.h"
     40 #include "SDL_pspgl_c.h"
     41 
     42 /* unused
     43 static SDL_bool PSP_initialized = SDL_FALSE;
     44 */
     45 
     46 static void
     47 PSP_Destroy(SDL_VideoDevice * device)
     48 {
     49 /*    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
     50 
     51     if (device->driverdata != NULL) {
     52         device->driverdata = NULL;
     53     }
     54 }
     55 
     56 static SDL_VideoDevice *
     57 PSP_Create()
     58 {
     59     SDL_VideoDevice *device;
     60     SDL_VideoData *phdata;
     61     SDL_GLDriverData *gldata;
     62 
     63     /* Initialize SDL_VideoDevice structure */
     64     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
     65     if (device == NULL) {
     66         SDL_OutOfMemory();
     67         return NULL;
     68     }
     69 
     70     /* Initialize internal PSP specific data */
     71     phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
     72     if (phdata == NULL) {
     73         SDL_OutOfMemory();
     74         SDL_free(device);
     75         return NULL;
     76     }
     77 
     78         gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
     79     if (gldata == NULL) {
     80         SDL_OutOfMemory();
     81         SDL_free(device);
     82         SDL_free(phdata);
     83         return NULL;
     84     }
     85     device->gl_data = gldata;
     86 
     87     device->driverdata = phdata;
     88 
     89     phdata->egl_initialized = SDL_TRUE;
     90 
     91 
     92     /* Setup amount of available displays */
     93     device->num_displays = 0;
     94 
     95     /* Set device free function */
     96     device->free = PSP_Destroy;
     97 
     98     /* Setup all functions which we can handle */
     99     device->VideoInit = PSP_VideoInit;
    100     device->VideoQuit = PSP_VideoQuit;
    101     device->GetDisplayModes = PSP_GetDisplayModes;
    102     device->SetDisplayMode = PSP_SetDisplayMode;
    103     device->CreateSDLWindow = PSP_CreateWindow;
    104     device->CreateSDLWindowFrom = PSP_CreateWindowFrom;
    105     device->SetWindowTitle = PSP_SetWindowTitle;
    106     device->SetWindowIcon = PSP_SetWindowIcon;
    107     device->SetWindowPosition = PSP_SetWindowPosition;
    108     device->SetWindowSize = PSP_SetWindowSize;
    109     device->ShowWindow = PSP_ShowWindow;
    110     device->HideWindow = PSP_HideWindow;
    111     device->RaiseWindow = PSP_RaiseWindow;
    112     device->MaximizeWindow = PSP_MaximizeWindow;
    113     device->MinimizeWindow = PSP_MinimizeWindow;
    114     device->RestoreWindow = PSP_RestoreWindow;
    115     device->SetWindowGrab = PSP_SetWindowGrab;
    116     device->DestroyWindow = PSP_DestroyWindow;
    117 #if 0
    118     device->GetWindowWMInfo = PSP_GetWindowWMInfo;
    119 #endif
    120     device->GL_LoadLibrary = PSP_GL_LoadLibrary;
    121     device->GL_GetProcAddress = PSP_GL_GetProcAddress;
    122     device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
    123     device->GL_CreateContext = PSP_GL_CreateContext;
    124     device->GL_MakeCurrent = PSP_GL_MakeCurrent;
    125     device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
    126     device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
    127     device->GL_SwapWindow = PSP_GL_SwapWindow;
    128     device->GL_DeleteContext = PSP_GL_DeleteContext;
    129     device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
    130     device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
    131     device->HideScreenKeyboard = PSP_HideScreenKeyboard;
    132     device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
    133 
    134     device->PumpEvents = PSP_PumpEvents;
    135 
    136     return device;
    137 }
    138 
    139 VideoBootStrap PSP_bootstrap = {
    140     "PSP",
    141     "PSP Video Driver",
    142     PSP_Create
    143 };
    144 
    145 /*****************************************************************************/
    146 /* SDL Video and Display initialization/handling functions                   */
    147 /*****************************************************************************/
    148 int
    149 PSP_VideoInit(_THIS)
    150 {
    151     SDL_VideoDisplay display;
    152     SDL_DisplayMode current_mode;
    153 
    154     SDL_zero(current_mode);
    155 
    156     current_mode.w = 480;
    157     current_mode.h = 272;
    158 
    159     current_mode.refresh_rate = 60;
    160     /* 32 bpp for default */
    161     current_mode.format = SDL_PIXELFORMAT_ABGR8888;
    162 
    163     current_mode.driverdata = NULL;
    164 
    165     SDL_zero(display);
    166     display.desktop_mode = current_mode;
    167     display.current_mode = current_mode;
    168     display.driverdata = NULL;
    169 
    170     SDL_AddVideoDisplay(&display, SDL_FALSE);
    171 
    172     return 1;
    173 }
    174 
    175 void
    176 PSP_VideoQuit(_THIS)
    177 {
    178 
    179 }
    180 
    181 void
    182 PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    183 {
    184 
    185 }
    186 
    187 int
    188 PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
    189 {
    190     return 0;
    191 }
    192 #define EGLCHK(stmt)                            \
    193     do {                                        \
    194         EGLint err;                             \
    195                                                 \
    196         stmt;                                   \
    197         err = eglGetError();                    \
    198         if (err != EGL_SUCCESS) {               \
    199             SDL_SetError("EGL error %d", err);  \
    200             return 0;                           \
    201         }                                       \
    202     } while (0)
    203 
    204 int
    205 PSP_CreateWindow(_THIS, SDL_Window * window)
    206 {
    207     SDL_WindowData *wdata;
    208 
    209     /* Allocate window internal data */
    210     wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
    211     if (wdata == NULL) {
    212         return SDL_OutOfMemory();
    213     }
    214 
    215     /* Setup driver data for this window */
    216     window->driverdata = wdata;
    217 
    218 
    219     /* Window has been successfully created */
    220     return 0;
    221 }
    222 
    223 int
    224 PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
    225 {
    226     return SDL_Unsupported();
    227 }
    228 
    229 void
    230 PSP_SetWindowTitle(_THIS, SDL_Window * window)
    231 {
    232 }
    233 void
    234 PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
    235 {
    236 }
    237 void
    238 PSP_SetWindowPosition(_THIS, SDL_Window * window)
    239 {
    240 }
    241 void
    242 PSP_SetWindowSize(_THIS, SDL_Window * window)
    243 {
    244 }
    245 void
    246 PSP_ShowWindow(_THIS, SDL_Window * window)
    247 {
    248 }
    249 void
    250 PSP_HideWindow(_THIS, SDL_Window * window)
    251 {
    252 }
    253 void
    254 PSP_RaiseWindow(_THIS, SDL_Window * window)
    255 {
    256 }
    257 void
    258 PSP_MaximizeWindow(_THIS, SDL_Window * window)
    259 {
    260 }
    261 void
    262 PSP_MinimizeWindow(_THIS, SDL_Window * window)
    263 {
    264 }
    265 void
    266 PSP_RestoreWindow(_THIS, SDL_Window * window)
    267 {
    268 }
    269 void
    270 PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
    271 {
    272 
    273 }
    274 void
    275 PSP_DestroyWindow(_THIS, SDL_Window * window)
    276 {
    277 }
    278 
    279 /*****************************************************************************/
    280 /* SDL Window Manager function                                               */
    281 /*****************************************************************************/
    282 #if 0
    283 SDL_bool
    284 PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
    285 {
    286     if (info->version.major <= SDL_MAJOR_VERSION) {
    287         return SDL_TRUE;
    288     } else {
    289         SDL_SetError("Application not compiled with SDL %d.%d",
    290                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
    291         return SDL_FALSE;
    292     }
    293 
    294     /* Failed to get window manager information */
    295     return SDL_FALSE;
    296 }
    297 #endif
    298 
    299 
    300 /* TO Write Me */
    301 SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
    302 {
    303     return SDL_FALSE;
    304 }
    305 void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
    306 {
    307 }
    308 void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
    309 {
    310 }
    311 SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
    312 {
    313     return SDL_FALSE;
    314 }
    315 
    316 
    317 #endif /* SDL_VIDEO_DRIVER_PSP */
    318 
    319 /* vi: set ts=4 sw=4 expandtab: */