src/video/psp/SDL_pspvideo.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 May 2015 06:27:46 -0700
changeset 9619 b94b6d0bff0f
parent 9325 4f7a9123393a
child 9998 f67cf37e9cd4
permissions -rw-r--r--
Updated the copyright year to 2015
kimonline@7009
     1
/*
kimonline@7009
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
kimonline@7009
     4
kimonline@7009
     5
  This software is provided 'as-is', without any express or implied
kimonline@7009
     6
  warranty.  In no event will the authors be held liable for any damages
kimonline@7009
     7
  arising from the use of this software.
kimonline@7009
     8
kimonline@7009
     9
  Permission is granted to anyone to use this software for any purpose,
kimonline@7009
    10
  including commercial applications, and to alter it and redistribute it
kimonline@7009
    11
  freely, subject to the following restrictions:
kimonline@7009
    12
kimonline@7009
    13
  1. The origin of this software must not be misrepresented; you must not
kimonline@7009
    14
     claim that you wrote the original software. If you use this software
kimonline@7009
    15
     in a product, an acknowledgment in the product documentation would be
kimonline@7009
    16
     appreciated but is not required.
kimonline@7009
    17
  2. Altered source versions must be plainly marked as such, and must not be
kimonline@7009
    18
     misrepresented as being the original software.
kimonline@7009
    19
  3. This notice may not be removed or altered from any source distribution.
kimonline@7009
    20
*/
kimonline@7009
    21
icculus@8093
    22
#include "../../SDL_internal.h"
kimonline@7009
    23
kimonline@7009
    24
#if SDL_VIDEO_DRIVER_PSP
kimonline@7009
    25
kimonline@7009
    26
/* SDL internals */
kimonline@7009
    27
#include "../SDL_sysvideo.h"
kimonline@7009
    28
#include "SDL_version.h"
kimonline@7009
    29
#include "SDL_syswm.h"
kimonline@7009
    30
#include "SDL_loadso.h"
kimonline@7009
    31
#include "SDL_events.h"
kimonline@7009
    32
#include "../../events/SDL_mouse_c.h"
kimonline@7009
    33
#include "../../events/SDL_keyboard_c.h"
kimonline@7009
    34
kimonline@7009
    35
kimonline@7009
    36
kimonline@7009
    37
/* PSP declarations */
kimonline@7009
    38
#include "SDL_pspvideo.h"
kimonline@7009
    39
#include "SDL_pspevents_c.h"
kimonline@7009
    40
#include "SDL_pspgl_c.h"
kimonline@7009
    41
kimonline@7009
    42
/* unused
kimonline@7009
    43
static SDL_bool PSP_initialized = SDL_FALSE;
kimonline@7009
    44
*/
kimonline@7009
    45
static int
kimonline@7009
    46
PSP_Available(void)
kimonline@7009
    47
{
kimonline@7009
    48
    return 1;
kimonline@7009
    49
}
kimonline@7009
    50
kimonline@7009
    51
static void
kimonline@7009
    52
PSP_Destroy(SDL_VideoDevice * device)
kimonline@7009
    53
{
slouken@7191
    54
/*    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
kimonline@7009
    55
kimonline@7009
    56
    if (device->driverdata != NULL) {
kimonline@7009
    57
        device->driverdata = NULL;
kimonline@7009
    58
    }
kimonline@7009
    59
}
kimonline@7009
    60
kimonline@7009
    61
static SDL_VideoDevice *
kimonline@7009
    62
PSP_Create()
kimonline@7009
    63
{
kimonline@7009
    64
    SDL_VideoDevice *device;
kimonline@7009
    65
    SDL_VideoData *phdata;
kimonline@7009
    66
    SDL_GLDriverData *gldata;
kimonline@7009
    67
    int status;
kimonline@7009
    68
philipp@9325
    69
    /* Check if PSP could be initialized */
kimonline@7009
    70
    status = PSP_Available();
kimonline@7009
    71
    if (status == 0) {
kimonline@7009
    72
        /* PSP could not be used */
kimonline@7009
    73
        return NULL;
kimonline@7009
    74
    }
kimonline@7009
    75
kimonline@7009
    76
    /* Initialize SDL_VideoDevice structure */
kimonline@7009
    77
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
kimonline@7009
    78
    if (device == NULL) {
kimonline@7009
    79
        SDL_OutOfMemory();
kimonline@7009
    80
        return NULL;
kimonline@7009
    81
    }
kimonline@7009
    82
philipp@9325
    83
    /* Initialize internal PSP specific data */
kimonline@7009
    84
    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
kimonline@7009
    85
    if (phdata == NULL) {
kimonline@7009
    86
        SDL_OutOfMemory();
kimonline@7009
    87
        SDL_free(device);
kimonline@7009
    88
        return NULL;
kimonline@7009
    89
    }
slouken@7191
    90
slouken@7191
    91
        gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
kimonline@7009
    92
    if (gldata == NULL) {
kimonline@7009
    93
        SDL_OutOfMemory();
kimonline@7009
    94
        SDL_free(device);
kimonline@7009
    95
        return NULL;
slouken@7191
    96
    }
kimonline@7009
    97
    device->gl_data = gldata;
slouken@7191
    98
kimonline@7009
    99
    device->driverdata = phdata;
kimonline@7009
   100
kimonline@7009
   101
    phdata->egl_initialized = SDL_TRUE;
kimonline@7009
   102
kimonline@7009
   103
kimonline@7009
   104
    /* Setup amount of available displays and current display */
kimonline@7009
   105
    device->num_displays = 0;
kimonline@7009
   106
kimonline@7009
   107
    /* Set device free function */
kimonline@7009
   108
    device->free = PSP_Destroy;
kimonline@7009
   109
kimonline@7009
   110
    /* Setup all functions which we can handle */
kimonline@7009
   111
    device->VideoInit = PSP_VideoInit;
kimonline@7009
   112
    device->VideoQuit = PSP_VideoQuit;
kimonline@7009
   113
    device->GetDisplayModes = PSP_GetDisplayModes;
kimonline@7009
   114
    device->SetDisplayMode = PSP_SetDisplayMode;
kimonline@7009
   115
    device->CreateWindow = PSP_CreateWindow;
kimonline@7009
   116
    device->CreateWindowFrom = PSP_CreateWindowFrom;
kimonline@7009
   117
    device->SetWindowTitle = PSP_SetWindowTitle;
kimonline@7009
   118
    device->SetWindowIcon = PSP_SetWindowIcon;
kimonline@7009
   119
    device->SetWindowPosition = PSP_SetWindowPosition;
kimonline@7009
   120
    device->SetWindowSize = PSP_SetWindowSize;
kimonline@7009
   121
    device->ShowWindow = PSP_ShowWindow;
kimonline@7009
   122
    device->HideWindow = PSP_HideWindow;
kimonline@7009
   123
    device->RaiseWindow = PSP_RaiseWindow;
kimonline@7009
   124
    device->MaximizeWindow = PSP_MaximizeWindow;
kimonline@7009
   125
    device->MinimizeWindow = PSP_MinimizeWindow;
kimonline@7009
   126
    device->RestoreWindow = PSP_RestoreWindow;
kimonline@7009
   127
    device->SetWindowGrab = PSP_SetWindowGrab;
kimonline@7009
   128
    device->DestroyWindow = PSP_DestroyWindow;
kimonline@7009
   129
    device->GetWindowWMInfo = PSP_GetWindowWMInfo;
kimonline@7009
   130
    device->GL_LoadLibrary = PSP_GL_LoadLibrary;
kimonline@7009
   131
    device->GL_GetProcAddress = PSP_GL_GetProcAddress;
kimonline@7009
   132
    device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
kimonline@7009
   133
    device->GL_CreateContext = PSP_GL_CreateContext;
kimonline@7009
   134
    device->GL_MakeCurrent = PSP_GL_MakeCurrent;
kimonline@7009
   135
    device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
kimonline@7009
   136
    device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
kimonline@7009
   137
    device->GL_SwapWindow = PSP_GL_SwapWindow;
kimonline@7009
   138
    device->GL_DeleteContext = PSP_GL_DeleteContext;
slouken@7191
   139
    device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
slouken@7191
   140
    device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
slouken@7191
   141
    device->HideScreenKeyboard = PSP_HideScreenKeyboard;
slouken@7191
   142
    device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
slouken@7191
   143
kimonline@7009
   144
    device->PumpEvents = PSP_PumpEvents;
kimonline@7009
   145
kimonline@7009
   146
    return device;
kimonline@7009
   147
}
kimonline@7009
   148
kimonline@7009
   149
VideoBootStrap PSP_bootstrap = {
kimonline@7009
   150
    "PSP",
kimonline@7009
   151
    "PSP Video Driver",
kimonline@7009
   152
    PSP_Available,
kimonline@7009
   153
    PSP_Create
kimonline@7009
   154
};
kimonline@7009
   155
kimonline@7009
   156
/*****************************************************************************/
kimonline@7009
   157
/* SDL Video and Display initialization/handling functions                   */
kimonline@7009
   158
/*****************************************************************************/
kimonline@7009
   159
int
kimonline@7009
   160
PSP_VideoInit(_THIS)
kimonline@7009
   161
{
kimonline@7009
   162
    SDL_VideoDisplay display;
kimonline@7009
   163
    SDL_DisplayMode current_mode;
kimonline@7009
   164
kimonline@7009
   165
    SDL_zero(current_mode);
slouken@7191
   166
kimonline@7009
   167
    current_mode.w = 480;
kimonline@7009
   168
    current_mode.h = 272;
slouken@7191
   169
kimonline@7009
   170
    current_mode.refresh_rate = 60;
slouken@7191
   171
    /* 32 bpp for default */
kimonline@7009
   172
    current_mode.format = SDL_PIXELFORMAT_ABGR8888;
slouken@7191
   173
kimonline@7009
   174
    current_mode.driverdata = NULL;
kimonline@7009
   175
kimonline@7009
   176
    SDL_zero(display);
kimonline@7009
   177
    display.desktop_mode = current_mode;
kimonline@7009
   178
    display.current_mode = current_mode;
kimonline@7009
   179
    display.driverdata = NULL;
kimonline@7009
   180
kimonline@7009
   181
    SDL_AddVideoDisplay(&display);
kimonline@7009
   182
kimonline@7009
   183
    return 1;
kimonline@7009
   184
}
kimonline@7009
   185
kimonline@7009
   186
void
kimonline@7009
   187
PSP_VideoQuit(_THIS)
kimonline@7009
   188
{
kimonline@7009
   189
kimonline@7009
   190
}
kimonline@7009
   191
kimonline@7009
   192
void
kimonline@7009
   193
PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
kimonline@7009
   194
{
kimonline@7009
   195
kimonline@7009
   196
}
kimonline@7009
   197
kimonline@7009
   198
int
kimonline@7009
   199
PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
kimonline@7009
   200
{
kimonline@7009
   201
    return 0;
kimonline@7009
   202
}
slouken@7191
   203
#define EGLCHK(stmt)                            \
slouken@7191
   204
    do {                                        \
slouken@7191
   205
        EGLint err;                             \
slouken@7191
   206
                                                \
slouken@7191
   207
        stmt;                                   \
slouken@7191
   208
        err = eglGetError();                    \
slouken@7191
   209
        if (err != EGL_SUCCESS) {               \
slouken@7191
   210
            SDL_SetError("EGL error %d", err);  \
slouken@7191
   211
            return 0;                           \
slouken@7191
   212
        }                                       \
slouken@7191
   213
    } while (0)
slouken@7191
   214
kimonline@7009
   215
int
kimonline@7009
   216
PSP_CreateWindow(_THIS, SDL_Window * window)
kimonline@7009
   217
{
kimonline@7009
   218
    SDL_WindowData *wdata;
kimonline@7009
   219
kimonline@7009
   220
    /* Allocate window internal data */
kimonline@7009
   221
    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
kimonline@7009
   222
    if (wdata == NULL) {
icculus@7037
   223
        return SDL_OutOfMemory();
kimonline@7009
   224
    }
kimonline@7009
   225
kimonline@7009
   226
    /* Setup driver data for this window */
kimonline@7009
   227
    window->driverdata = wdata;
kimonline@7009
   228
kimonline@7009
   229
kimonline@7009
   230
    /* Window has been successfully created */
kimonline@7009
   231
    return 0;
kimonline@7009
   232
}
kimonline@7009
   233
kimonline@7009
   234
int
kimonline@7009
   235
PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
kimonline@7009
   236
{
kimonline@7009
   237
    return -1;
kimonline@7009
   238
}
kimonline@7009
   239
kimonline@7009
   240
void
kimonline@7009
   241
PSP_SetWindowTitle(_THIS, SDL_Window * window)
kimonline@7009
   242
{
kimonline@7009
   243
}
kimonline@7009
   244
void
kimonline@7009
   245
PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
kimonline@7009
   246
{
kimonline@7009
   247
}
kimonline@7009
   248
void
kimonline@7009
   249
PSP_SetWindowPosition(_THIS, SDL_Window * window)
kimonline@7009
   250
{
kimonline@7009
   251
}
kimonline@7009
   252
void
kimonline@7009
   253
PSP_SetWindowSize(_THIS, SDL_Window * window)
kimonline@7009
   254
{
kimonline@7009
   255
}
kimonline@7009
   256
void
kimonline@7009
   257
PSP_ShowWindow(_THIS, SDL_Window * window)
kimonline@7009
   258
{
kimonline@7009
   259
}
kimonline@7009
   260
void
kimonline@7009
   261
PSP_HideWindow(_THIS, SDL_Window * window)
kimonline@7009
   262
{
kimonline@7009
   263
}
kimonline@7009
   264
void
kimonline@7009
   265
PSP_RaiseWindow(_THIS, SDL_Window * window)
kimonline@7009
   266
{
kimonline@7009
   267
}
kimonline@7009
   268
void
kimonline@7009
   269
PSP_MaximizeWindow(_THIS, SDL_Window * window)
kimonline@7009
   270
{
kimonline@7009
   271
}
kimonline@7009
   272
void
kimonline@7009
   273
PSP_MinimizeWindow(_THIS, SDL_Window * window)
kimonline@7009
   274
{
kimonline@7009
   275
}
kimonline@7009
   276
void
kimonline@7009
   277
PSP_RestoreWindow(_THIS, SDL_Window * window)
kimonline@7009
   278
{
kimonline@7009
   279
}
kimonline@7009
   280
void
kimonline@7009
   281
PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
kimonline@7009
   282
{
kimonline@7009
   283
kimonline@7009
   284
}
kimonline@7009
   285
void
kimonline@7009
   286
PSP_DestroyWindow(_THIS, SDL_Window * window)
kimonline@7009
   287
{
kimonline@7009
   288
}
kimonline@7009
   289
kimonline@7009
   290
/*****************************************************************************/
kimonline@7009
   291
/* SDL Window Manager function                                               */
kimonline@7009
   292
/*****************************************************************************/
kimonline@7009
   293
SDL_bool
kimonline@7009
   294
PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
kimonline@7009
   295
{
kimonline@7009
   296
    if (info->version.major <= SDL_MAJOR_VERSION) {
kimonline@7009
   297
        return SDL_TRUE;
kimonline@7009
   298
    } else {
kimonline@7009
   299
        SDL_SetError("application not compiled with SDL %d.%d\n",
kimonline@7009
   300
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
kimonline@7009
   301
        return SDL_FALSE;
kimonline@7009
   302
    }
kimonline@7009
   303
kimonline@7009
   304
    /* Failed to get window manager information */
kimonline@7009
   305
    return SDL_FALSE;
kimonline@7009
   306
}
kimonline@7009
   307
kimonline@7009
   308
gabomdq@7677
   309
/* TO Write Me */
philipp@7135
   310
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
kimonline@7009
   311
{
philipp@7147
   312
    return SDL_FALSE;
kimonline@7009
   313
}
philipp@7135
   314
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
kimonline@7009
   315
{
kimonline@7009
   316
}
philipp@7135
   317
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
kimonline@7009
   318
{
kimonline@7009
   319
}
philipp@7135
   320
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
kimonline@7009
   321
{
slouken@7191
   322
    return SDL_FALSE;
kimonline@7009
   323
}
kimonline@7009
   324
kimonline@7009
   325
kimonline@7009
   326
#endif /* SDL_VIDEO_DRIVER_PSP */
kimonline@7009
   327
kimonline@7009
   328
/* vi: set ts=4 sw=4 expandtab: */