src/video/uikit/SDL_uikitvideo.m
author Sam Lantinga
Sat, 29 Sep 2012 17:23:40 -0700
changeset 6518 42948831d16e
parent 6516 044ce237801a
child 6616 4f272256d172
permissions -rw-r--r--
Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
slouken@2765
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@2765
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2765
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2765
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2765
    20
*/
slouken@6044
    21
#include "SDL_config.h"
slouken@6044
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_UIKIT
icculus@4443
    24
icculus@4443
    25
#import <UIKit/UIKit.h>
icculus@4443
    26
slouken@2765
    27
#include "SDL_video.h"
slouken@2765
    28
#include "SDL_mouse.h"
slouken@2765
    29
#include "../SDL_sysvideo.h"
slouken@2765
    30
#include "../SDL_pixels_c.h"
slouken@2765
    31
#include "../../events/SDL_events_c.h"
slouken@2765
    32
slouken@2765
    33
#include "SDL_uikitvideo.h"
slouken@2765
    34
#include "SDL_uikitevents.h"
slouken@6518
    35
#include "SDL_uikitmodes.h"
slouken@2765
    36
#include "SDL_uikitwindow.h"
slouken@2765
    37
#include "SDL_uikitopengles.h"
slouken@2765
    38
slouken@2765
    39
#define UIKITVID_DRIVER_NAME "uikit"
slouken@2765
    40
slouken@2765
    41
/* Initialization/Query functions */
slouken@2765
    42
static int UIKit_VideoInit(_THIS);
slouken@2765
    43
static void UIKit_VideoQuit(_THIS);
slouken@2765
    44
slouken@2765
    45
/* DUMMY driver bootstrap functions */
slouken@2765
    46
slouken@2765
    47
static int
slouken@2765
    48
UIKit_Available(void)
slouken@2765
    49
{
kees@6003
    50
    return 1;
slouken@2765
    51
}
slouken@2765
    52
slouken@2765
    53
static void UIKit_DeleteDevice(SDL_VideoDevice * device)
slouken@2765
    54
{
slouken@2765
    55
    SDL_free(device);
slouken@2765
    56
}
slouken@2765
    57
slouken@2765
    58
static SDL_VideoDevice *
slouken@2765
    59
UIKit_CreateDevice(int devindex)
slouken@2765
    60
{
slouken@2765
    61
    SDL_VideoDevice *device;
slouken@2765
    62
slouken@2765
    63
    /* Initialize all variables that we clean on shutdown */
slouken@2765
    64
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
slouken@2765
    65
    if (!device) {
slouken@2765
    66
        SDL_OutOfMemory();
slouken@2765
    67
        if (device) {
slouken@2765
    68
            SDL_free(device);
slouken@2765
    69
        }
slouken@2765
    70
        return (0);
slouken@2765
    71
    }
slouken@2765
    72
slouken@2765
    73
    /* Set the function pointers */
slouken@2765
    74
    device->VideoInit = UIKit_VideoInit;
slouken@2765
    75
    device->VideoQuit = UIKit_VideoQuit;
icculus@4443
    76
    device->GetDisplayModes = UIKit_GetDisplayModes;
slouken@2765
    77
    device->SetDisplayMode = UIKit_SetDisplayMode;
slouken@2765
    78
    device->PumpEvents = UIKit_PumpEvents;
slouken@5131
    79
    device->CreateWindow = UIKit_CreateWindow;
slouken@6379
    80
    device->ShowWindow = UIKit_ShowWindow;
slouken@6379
    81
    device->HideWindow = UIKit_HideWindow;
icculus@6419
    82
    device->RaiseWindow = UIKit_RaiseWindow;
slouken@6073
    83
    device->SetWindowFullscreen = UIKit_SetWindowFullscreen;
slouken@5131
    84
    device->DestroyWindow = UIKit_DestroyWindow;
slouken@5056
    85
    device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
kees@6001
    86
icculus@6422
    87
    /* !!! FIXME: implement SetWindowBordered */
icculus@6422
    88
slouken@6392
    89
    device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
slouken@6392
    90
    device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
slouken@6392
    91
    device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
slouken@6392
    92
    device->SDL_ToggleScreenKeyboard = UIKit_ToggleScreenKeyboard;
slouken@6392
    93
    device->SDL_IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
kees@6001
    94
slouken@5131
    95
    /* OpenGL (ES) functions */
slouken@5131
    96
    device->GL_MakeCurrent        = UIKit_GL_MakeCurrent;
slouken@5131
    97
    device->GL_SwapWindow        = UIKit_GL_SwapWindow;
slouken@5131
    98
    device->GL_CreateContext    = UIKit_GL_CreateContext;
slouken@5131
    99
    device->GL_DeleteContext    = UIKit_GL_DeleteContext;
slouken@5131
   100
    device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
slouken@5131
   101
    device->GL_LoadLibrary        = UIKit_GL_LoadLibrary;
slouken@5131
   102
    device->free = UIKit_DeleteDevice;
slouken@2765
   103
slouken@5131
   104
    device->gl_config.accelerated = 1;
slouken@5131
   105
slouken@2765
   106
    return device;
slouken@2765
   107
}
slouken@2765
   108
slouken@2765
   109
VideoBootStrap UIKIT_bootstrap = {
slouken@2765
   110
    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
slouken@2765
   111
    UIKit_Available, UIKit_CreateDevice
slouken@2765
   112
};
slouken@2765
   113
slouken@2765
   114
slouken@2765
   115
int
slouken@2765
   116
UIKit_VideoInit(_THIS)
slouken@2765
   117
{
icculus@4443
   118
    _this->gl_config.driver_loaded = 1;
slouken@2765
   119
slouken@6518
   120
    if (UIKit_InitModes(_this) < 0) {
tim@6267
   121
        return -1;
tim@6267
   122
    }
slouken@2765
   123
    return 0;
slouken@2765
   124
}
slouken@2765
   125
slouken@2765
   126
void
slouken@2765
   127
UIKit_VideoQuit(_THIS)
slouken@2765
   128
{
slouken@6518
   129
    UIKit_QuitModes(_this);
slouken@2765
   130
}
slouken@2765
   131
slouken@6044
   132
#endif /* SDL_VIDEO_DRIVER_UIKIT */
slouken@6044
   133
slouken@2765
   134
/* vi: set ts=4 sw=4 expandtab: */