- Added SDL, libjpeg and libpng
- Added Android project and Java files
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_androidevents.h"
|
||||
|
||||
void
|
||||
Android_PumpEvents(_THIS)
|
||||
{
|
||||
/* No polling necessary */
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern void Android_PumpEvents(_THIS);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Android SDL video driver implementation */
|
||||
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
|
||||
/* GL functions */
|
||||
int
|
||||
Android_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_LoadLibrary\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
Android_GL_GetProcAddress(_THIS, const char *proc)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetProcAddress\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Android_GL_UnloadLibrary(_THIS)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
Android_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
if (!Android_JNI_CreateContext(_this->gl_config.major_version,
|
||||
_this->gl_config.minor_version)) {
|
||||
SDL_SetError("Couldn't create OpenGL context - see Android log for details");
|
||||
return NULL;
|
||||
}
|
||||
return (SDL_GLContext)1;
|
||||
}
|
||||
|
||||
int
|
||||
Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
/* There's only one context, nothing to do... */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Android_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SetSwapInterval\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Android_GL_GetSwapInterval(_THIS)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetSwapInterval\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Android_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
Android_JNI_SwapWindow();
|
||||
}
|
||||
|
||||
void
|
||||
Android_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_DeleteContext\n");
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_androidkeyboard.h"
|
||||
|
||||
|
||||
void Android_InitKeyboard()
|
||||
{
|
||||
SDL_Keycode keymap[SDL_NUM_SCANCODES];
|
||||
|
||||
/* Add default scancode to key mapping */
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
||||
}
|
||||
|
||||
static SDL_Scancode Android_Keycodes[] = {
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
|
||||
SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
|
||||
SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
|
||||
SDL_SCANCODE_0, /* AKEYCODE_0 */
|
||||
SDL_SCANCODE_1, /* AKEYCODE_1 */
|
||||
SDL_SCANCODE_2, /* AKEYCODE_2 */
|
||||
SDL_SCANCODE_3, /* AKEYCODE_3 */
|
||||
SDL_SCANCODE_4, /* AKEYCODE_4 */
|
||||
SDL_SCANCODE_5, /* AKEYCODE_5 */
|
||||
SDL_SCANCODE_6, /* AKEYCODE_6 */
|
||||
SDL_SCANCODE_7, /* AKEYCODE_7 */
|
||||
SDL_SCANCODE_8, /* AKEYCODE_8 */
|
||||
SDL_SCANCODE_9, /* AKEYCODE_9 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */
|
||||
SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */
|
||||
SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */
|
||||
SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */
|
||||
SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */
|
||||
SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */
|
||||
SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */
|
||||
SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */
|
||||
SDL_SCANCODE_POWER, /* AKEYCODE_POWER */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */
|
||||
SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */
|
||||
SDL_SCANCODE_A, /* AKEYCODE_A */
|
||||
SDL_SCANCODE_B, /* AKEYCODE_B */
|
||||
SDL_SCANCODE_C, /* AKEYCODE_C */
|
||||
SDL_SCANCODE_D, /* AKEYCODE_D */
|
||||
SDL_SCANCODE_E, /* AKEYCODE_E */
|
||||
SDL_SCANCODE_F, /* AKEYCODE_F */
|
||||
SDL_SCANCODE_G, /* AKEYCODE_G */
|
||||
SDL_SCANCODE_H, /* AKEYCODE_H */
|
||||
SDL_SCANCODE_I, /* AKEYCODE_I */
|
||||
SDL_SCANCODE_J, /* AKEYCODE_J */
|
||||
SDL_SCANCODE_K, /* AKEYCODE_K */
|
||||
SDL_SCANCODE_L, /* AKEYCODE_L */
|
||||
SDL_SCANCODE_M, /* AKEYCODE_M */
|
||||
SDL_SCANCODE_N, /* AKEYCODE_N */
|
||||
SDL_SCANCODE_O, /* AKEYCODE_O */
|
||||
SDL_SCANCODE_P, /* AKEYCODE_P */
|
||||
SDL_SCANCODE_Q, /* AKEYCODE_Q */
|
||||
SDL_SCANCODE_R, /* AKEYCODE_R */
|
||||
SDL_SCANCODE_S, /* AKEYCODE_S */
|
||||
SDL_SCANCODE_T, /* AKEYCODE_T */
|
||||
SDL_SCANCODE_U, /* AKEYCODE_U */
|
||||
SDL_SCANCODE_V, /* AKEYCODE_V */
|
||||
SDL_SCANCODE_W, /* AKEYCODE_W */
|
||||
SDL_SCANCODE_X, /* AKEYCODE_X */
|
||||
SDL_SCANCODE_Y, /* AKEYCODE_Y */
|
||||
SDL_SCANCODE_Z, /* AKEYCODE_Z */
|
||||
SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */
|
||||
SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */
|
||||
SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */
|
||||
SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */
|
||||
SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */
|
||||
SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */
|
||||
SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
|
||||
SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */
|
||||
SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
|
||||
SDL_SCANCODE_DELETE, /* AKEYCODE_DEL */
|
||||
SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
|
||||
SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
|
||||
SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
|
||||
SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */
|
||||
SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */
|
||||
SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
|
||||
SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
|
||||
SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */
|
||||
SDL_SCANCODE_MENU, /* AKEYCODE_MENU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */
|
||||
SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */
|
||||
SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */
|
||||
SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */
|
||||
SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */
|
||||
SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_REWIND */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_FAST_FORWARD */
|
||||
SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */
|
||||
SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */
|
||||
SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
|
||||
};
|
||||
|
||||
static SDL_Scancode
|
||||
TranslateKeycode(int keycode)
|
||||
{
|
||||
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
|
||||
|
||||
if (keycode < SDL_arraysize(Android_Keycodes)) {
|
||||
scancode = Android_Keycodes[keycode];
|
||||
}
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode);
|
||||
}
|
||||
return scancode;
|
||||
}
|
||||
|
||||
int
|
||||
Android_OnKeyDown(int keycode)
|
||||
{
|
||||
return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode));
|
||||
}
|
||||
|
||||
int
|
||||
Android_OnKeyUp(int keycode)
|
||||
{
|
||||
return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern void Android_InitKeyboard();
|
||||
extern int Android_OnKeyDown(int keycode);
|
||||
extern int Android_OnKeyUp(int keycode);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include "SDL_androidtouch.h"
|
||||
|
||||
|
||||
#define ACTION_DOWN 0
|
||||
#define ACTION_UP 1
|
||||
#define ACTION_MOVE 2
|
||||
#define ACTION_CANCEL 3
|
||||
#define ACTION_OUTSIDE 4
|
||||
|
||||
void Android_OnTouch(int action, float x, float y, float p)
|
||||
{
|
||||
if (!Android_Window) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((action != ACTION_CANCEL) && (action != ACTION_OUTSIDE)) {
|
||||
SDL_SetMouseFocus(Android_Window);
|
||||
SDL_SendMouseMotion(Android_Window, 0, (int)x, (int)y);
|
||||
switch(action) {
|
||||
case ACTION_DOWN:
|
||||
SDL_SendMouseButton(Android_Window, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
case ACTION_UP:
|
||||
SDL_SendMouseButton(Android_Window, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern void Android_OnTouch(int action, float x, float y, float p);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Android SDL video driver implementation
|
||||
*/
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_windowevents_c.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "SDL_androidevents.h"
|
||||
#include "SDL_androidkeyboard.h"
|
||||
#include "SDL_androidwindow.h"
|
||||
|
||||
#define ANDROID_VID_DRIVER_NAME "Android"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int Android_VideoInit(_THIS);
|
||||
static void Android_VideoQuit(_THIS);
|
||||
|
||||
/* GL functions (SDL_androidgl.c) */
|
||||
extern int Android_GL_LoadLibrary(_THIS, const char *path);
|
||||
extern void *Android_GL_GetProcAddress(_THIS, const char *proc);
|
||||
extern void Android_GL_UnloadLibrary(_THIS);
|
||||
//extern int *Android_GL_GetVisual(_THIS, Display * display, int screen);
|
||||
extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
|
||||
SDL_GLContext context);
|
||||
extern int Android_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int Android_GL_GetSwapInterval(_THIS);
|
||||
extern void Android_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
/* Android driver bootstrap functions */
|
||||
|
||||
|
||||
// These are filled in with real values in Android_SetScreenResolution on
|
||||
// init (before SDL_main())
|
||||
int Android_ScreenWidth = 0;
|
||||
int Android_ScreenHeight = 0;
|
||||
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
|
||||
/* Currently only one window */
|
||||
SDL_Window *Android_Window = NULL;
|
||||
|
||||
static int
|
||||
Android_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
Android_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
Android_CreateDevice(int devindex)
|
||||
{
|
||||
printf("Creating video device\n");
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
if (device) {
|
||||
SDL_free(device);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Android_VideoInit;
|
||||
device->VideoQuit = Android_VideoQuit;
|
||||
device->PumpEvents = Android_PumpEvents;
|
||||
|
||||
device->CreateWindow = Android_CreateWindow;
|
||||
device->SetWindowTitle = Android_SetWindowTitle;
|
||||
device->DestroyWindow = Android_DestroyWindow;
|
||||
|
||||
device->free = Android_DeleteDevice;
|
||||
|
||||
/* GL pointers */
|
||||
device->GL_LoadLibrary = Android_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = Android_GL_GetProcAddress;
|
||||
device->GL_UnloadLibrary = Android_GL_UnloadLibrary;
|
||||
device->GL_CreateContext = Android_GL_CreateContext;
|
||||
device->GL_MakeCurrent = Android_GL_MakeCurrent;
|
||||
device->GL_SetSwapInterval = Android_GL_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = Android_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = Android_GL_SwapWindow;
|
||||
device->GL_DeleteContext = Android_GL_DeleteContext;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap Android_bootstrap = {
|
||||
ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
|
||||
Android_Available, Android_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
Android_VideoInit(_THIS)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
mode.format = Android_ScreenFormat;
|
||||
mode.w = Android_ScreenWidth;
|
||||
mode.h = Android_ScreenHeight;
|
||||
mode.refresh_rate = 0;
|
||||
mode.driverdata = NULL;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_zero(mode);
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
|
||||
Android_InitKeyboard();
|
||||
|
||||
/* We're done! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Android_VideoQuit(_THIS)
|
||||
{
|
||||
}
|
||||
|
||||
/* This function gets called before VideoInit() */
|
||||
void
|
||||
Android_SetScreenResolution(int width, int height, Uint32 format)
|
||||
{
|
||||
Android_ScreenWidth = width;
|
||||
Android_ScreenHeight = height;
|
||||
Android_ScreenFormat = format;
|
||||
|
||||
if (Android_Window) {
|
||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_androidvideo_h
|
||||
#define _SDL_androidvideo_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* Called by the JNI layer when the screen changes size or format */
|
||||
extern void Android_SetScreenResolution(int width, int height, Uint32 format);
|
||||
|
||||
/* Private display data */
|
||||
|
||||
extern int Android_ScreenWidth;
|
||||
extern int Android_ScreenHeight;
|
||||
extern Uint32 Android_ScreenFormat;
|
||||
extern SDL_Window *Android_Window;
|
||||
|
||||
#endif /* _SDL_androidvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "SDL_androidwindow.h"
|
||||
|
||||
int
|
||||
Android_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
if (Android_Window) {
|
||||
SDL_SetError("Android only supports one window");
|
||||
return -1;
|
||||
}
|
||||
Android_Window = window;
|
||||
|
||||
/* Adjust the window data to match the screen */
|
||||
window->x = 0;
|
||||
window->y = 0;
|
||||
window->w = Android_ScreenWidth;
|
||||
window->h = Android_ScreenHeight;
|
||||
|
||||
window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */
|
||||
window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */
|
||||
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Android_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
Android_JNI_SetActivityTitle(window->title);
|
||||
}
|
||||
|
||||
void
|
||||
Android_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
if (window == Android_Window) {
|
||||
Android_Window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_androidwindow_h
|
||||
#define _SDL_androidwindow_h
|
||||
|
||||
extern int Android_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern void Android_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
extern void Android_DestroyWindow(_THIS, SDL_Window * window);
|
||||
|
||||
#endif /* _SDL_androidwindow_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
Reference in New Issue
Block a user