src/video/android/SDL_androidvideo.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 26 Sep 2012 20:14:37 -0700
changeset 6464 ab55284b389f
parent 6392 fa7eb111f994
child 6555 f2c03c06d987
permissions -rwxr-xr-x
Fixed bug 1573 - SDL does not support system clipboard on Android. Philipp Wiesemann 2012-08-18 14:09:47 PDT there is currently no way in SDL to interact with the system clipboard on Android. I attached a patch which tries to implement the three clipboard functions for Android. It does not add the CLIPBOARDUPDATE event because this seems to require Android API 11 or polling.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    20
*/
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    21
#include "SDL_config.h"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    23
#if SDL_VIDEO_DRIVER_ANDROID
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    24
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    25
/* Android SDL video driver implementation
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    26
*/
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    27
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    28
#include "SDL_video.h"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    29
#include "SDL_mouse.h"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    30
#include "../SDL_sysvideo.h"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    31
#include "../SDL_pixels_c.h"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    32
#include "../../events/SDL_events_c.h"
5001
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    33
#include "../../events/SDL_windowevents_c.h"
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    34
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    35
#include "SDL_androidvideo.h"
6464
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
    36
#include "SDL_androidclipboard.h"
4703
c93b44ddc63e Fixed #includes to fix naming conventions
Paul Hunkin <paul@bieh.net>
parents: 4701
diff changeset
    37
#include "SDL_androidevents.h"
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
    38
#include "SDL_androidkeyboard.h"
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    39
#include "SDL_androidwindow.h"
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    40
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    41
#define ANDROID_VID_DRIVER_NAME "Android"
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    42
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    43
/* Initialization/Query functions */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    44
static int Android_VideoInit(_THIS);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    45
static void Android_VideoQuit(_THIS);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    46
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    47
/* GL functions (SDL_androidgl.c) */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    48
extern int Android_GL_LoadLibrary(_THIS, const char *path);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    49
extern void *Android_GL_GetProcAddress(_THIS, const char *proc);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    50
extern void Android_GL_UnloadLibrary(_THIS);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    51
//extern int *Android_GL_GetVisual(_THIS, Display * display, int screen);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    52
extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    53
extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    54
                              SDL_GLContext context);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    55
extern int Android_GL_SetSwapInterval(_THIS, int interval);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    56
extern int Android_GL_GetSwapInterval(_THIS);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    57
extern void Android_GL_SwapWindow(_THIS, SDL_Window * window);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    58
extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    59
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    60
/* Android driver bootstrap functions */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    61
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    62
4981
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
    63
// These are filled in with real values in Android_SetScreenResolution on 
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
    64
// init (before SDL_main())
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    65
int Android_ScreenWidth = 0;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    66
int Android_ScreenHeight = 0;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    67
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
6330
0fa55ca2efdd Fixes #1422, restores GL context automatically under Android
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6138
diff changeset
    68
SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
4716
f2c2a33a1a38 Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents: 4713
diff changeset
    69
5001
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    70
/* Currently only one window */
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    71
SDL_Window *Android_Window = NULL;
4716
f2c2a33a1a38 Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents: 4713
diff changeset
    72
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    73
static int
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    74
Android_Available(void)
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    75
{
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    76
    return 1;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    77
}
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    78
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    79
static void
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    80
Android_DeleteDevice(SDL_VideoDevice * device)
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    81
{
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    82
    SDL_free(device);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    83
}
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    84
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    85
static SDL_VideoDevice *
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    86
Android_CreateDevice(int devindex)
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    87
{
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    88
    printf("Creating video device\n");
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    89
    SDL_VideoDevice *device;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    90
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    91
    /* Initialize all variables that we clean on shutdown */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    92
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    93
    if (!device) {
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    94
        SDL_OutOfMemory();
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    95
        if (device) {
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    96
            SDL_free(device);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    97
        }
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    98
        return (0);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    99
    }
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   100
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   101
    /* Set the function pointers */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   102
    device->VideoInit = Android_VideoInit;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   103
    device->VideoQuit = Android_VideoQuit;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   104
    device->PumpEvents = Android_PumpEvents;
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
   105
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   106
    device->CreateWindow = Android_CreateWindow;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   107
    device->SetWindowTitle = Android_SetWindowTitle;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   108
    device->DestroyWindow = Android_DestroyWindow;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   109
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   110
    device->free = Android_DeleteDevice;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   111
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   112
    /* GL pointers */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   113
    device->GL_LoadLibrary = Android_GL_LoadLibrary;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   114
    device->GL_GetProcAddress = Android_GL_GetProcAddress;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   115
    device->GL_UnloadLibrary = Android_GL_UnloadLibrary;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   116
    device->GL_CreateContext = Android_GL_CreateContext;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   117
    device->GL_MakeCurrent = Android_GL_MakeCurrent;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   118
    device->GL_SetSwapInterval = Android_GL_SetSwapInterval;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   119
    device->GL_GetSwapInterval = Android_GL_GetSwapInterval;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   120
    device->GL_SwapWindow = Android_GL_SwapWindow;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   121
    device->GL_DeleteContext = Android_GL_DeleteContext;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   122
6392
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   123
    /* Screen keyboard */
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   124
    device->SDL_HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport;
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   125
    device->SDL_ShowScreenKeyboard = Android_ShowScreenKeyboard;
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   126
    device->SDL_HideScreenKeyboard = Android_HideScreenKeyboard;
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   127
    device->SDL_ToggleScreenKeyboard = Android_ToggleScreenKeyboard;
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   128
    device->SDL_IsScreenKeyboardShown = Android_IsScreenKeyboardShown;
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6330
diff changeset
   129
6464
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
   130
    /* Clipboard */
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
   131
    device->SetClipboardText = Android_SetClipboardText;
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
   132
    device->GetClipboardText = Android_GetClipboardText;
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
   133
    device->HasClipboardText = Android_HasClipboardText;
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
   134
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   135
    return device;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   136
}
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   137
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   138
VideoBootStrap Android_bootstrap = {
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   139
    ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   140
    Android_Available, Android_CreateDevice
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   141
};
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   142
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   143
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   144
int
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   145
Android_VideoInit(_THIS)
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   146
{
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   147
    SDL_DisplayMode mode;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   148
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   149
    mode.format = Android_ScreenFormat;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   150
    mode.w = Android_ScreenWidth;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   151
    mode.h = Android_ScreenHeight;
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   152
    mode.refresh_rate = 0;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   153
    mode.driverdata = NULL;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   154
    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   155
        return -1;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   156
    }
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   157
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   158
    SDL_zero(mode);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   159
    SDL_AddDisplayMode(&_this->displays[0], &mode);
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   160
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
   161
    Android_InitKeyboard();
4713
ba38983b10c2 Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents: 4707
diff changeset
   162
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   163
    /* We're done! */
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   164
    return 0;
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   165
}
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   166
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   167
void
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   168
Android_VideoQuit(_THIS)
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   169
{
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   170
}
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   171
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   172
/* This function gets called before VideoInit() */
4981
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
   173
void
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
   174
Android_SetScreenResolution(int width, int height, Uint32 format)
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
   175
{
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   176
    Android_ScreenWidth = width;
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   177
    Android_ScreenHeight = height;   
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   178
    Android_ScreenFormat = format;
5001
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
   179
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
   180
    if (Android_Window) {
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
   181
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
77df56570442 Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
   182
    }
4716
f2c2a33a1a38 Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents: 4713
diff changeset
   183
}
f2c2a33a1a38 Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents: 4713
diff changeset
   184
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   185
#endif /* SDL_VIDEO_DRIVER_ANDROID */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   186
4701
d40bb3165d2b Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
   187
/* vi: set ts=4 sw=4 expandtab: */