Downloader working again

This commit is contained in:
Gerhard Stein
2013-10-14 18:41:47 +02:00
parent 67793f945f
commit ea4a29e4de
19 changed files with 5 additions and 1514 deletions

View File

@@ -107,7 +107,7 @@ public class MainActivity extends SDLActivity
*/
/*Log.i("SDL", "libSDL: Creating startup screen");
Log.i("SDL", "libSDL: Creating startup screen");
_layout = new LinearLayout(this);
_layout.setOrientation(LinearLayout.VERTICAL);
_layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
@@ -164,9 +164,9 @@ public class MainActivity extends SDLActivity
_ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.RIGHT));
}
setContentView(_videoLayout);*/
setContentView(_videoLayout);
/*class Callback implements Runnable
class Callback implements Runnable
{
MainActivity p;
Callback( MainActivity _p ) { p = _p; }
@@ -188,7 +188,7 @@ public class MainActivity extends SDLActivity
public MainActivity Parent;
public void run()
{
//Settings.Load(Parent); -> TODO: Still needs to be adapted to SDL2
Settings.Load(Parent);
loaded.release();
loadedLibraries.release();
}
@@ -217,7 +217,7 @@ public class MainActivity extends SDLActivity
}
}
};
(new Thread(new Callback(this))).start();*/
(new Thread(new Callback(this))).start();
}
public void setUpStatusLabel()
{

View File

@@ -1,88 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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"
#if SDL_VIDEO_DRIVER_ANDROID
/* We're going to do this by default */
#define SDL_ANDROID_BLOCK_ON_PAUSE 1
#include "SDL_androidevents.h"
#include "SDL_events.h"
void
Android_PumpEvents(_THIS)
{
static int isPaused = 0;
#if SDL_ANDROID_BLOCK_ON_PAUSE
static int isPausing = 0;
#endif
/* No polling necessary */
/*
* Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume
* When the pause semaphore is signaled, if SDL_ANDROID_BLOCK_ON_PAUSE is defined the event loop will block until the resume signal is emitted.
* When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
*/
#if SDL_ANDROID_BLOCK_ON_PAUSE
if (isPaused && !isPausing) {
if(SDL_SemWait(Android_ResumeSem) == 0) {
#else
if (isPaused) {
if(SDL_SemTryWait(Android_ResumeSem) == 0) {
#endif
isPaused = 0;
/* TODO: Should we double check if we are on the same thread as the one that made the original GL context?
* This call will go through the following chain of calls in Java:
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
* SDLActivity::createEGLContext will attempt to restore the GL context first, and if that fails it will create a new one
* If a new GL context is created, the user needs to restore the textures manually (TODO: notify the user that this happened with a message)
*/
SDL_GL_CreateContext(Android_Window);
}
}
else {
#if SDL_ANDROID_BLOCK_ON_PAUSE
if( isPausing || SDL_SemTryWait(Android_PauseSem) == 0 ) {
/* We've been signaled to pause, but before we block ourselves, we need to make sure that
SDL_WINDOWEVENT_FOCUS_LOST and SDL_WINDOWEVENT_MINIMIZED have reached the app */
if (SDL_HasEvent(SDL_WINDOWEVENT)) {
isPausing = 1;
}
else {
isPausing = 0;
isPaused = 1;
}
}
#else
if(SDL_SemTryWait(Android_PauseSem) == 0) {
/* If we fall in here, the system is/was paused */
isPaused = 1;
}
#endif
}
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,38 +0,0 @@
--- src/video/android/SDL_androidevents.c 2013-10-08 17:46:42.441362557 +0200
+++ src/video/android/SDL_androidevents.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,35 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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"
-
-#if SDL_VIDEO_DRIVER_ANDROID
-
-#include "SDL_androidevents.h"
-
-void
-Android_PumpEvents(_THIS)
-{
- /* No polling necessary */
-}
-
-#endif /* SDL_VIDEO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,27 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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: */

View File

@@ -1,30 +0,0 @@
--- src/video/android/SDL_androidevents.h 2013-10-08 17:46:42.441362557 +0200
+++ src/video/android/SDL_androidevents.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,27 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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: */

View File

@@ -1,129 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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"
#if SDL_VIDEO_DRIVER_ANDROID
/* Android SDL video driver implementation */
#include "SDL_video.h"
#include "SDL_androidvideo.h"
#include "../../core/android/SDL_android.h"
#include <android/log.h>
#include <dlfcn.h>
static void* Android_GLHandle = NULL;
/* GL functions */
int
Android_GL_LoadLibrary(_THIS, const char *path)
{
if (!Android_GLHandle) {
Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL);
if (!Android_GLHandle) {
return SDL_SetError("Could not initialize GL ES library\n");
}
}
return 0;
}
void *
Android_GL_GetProcAddress(_THIS, const char *proc)
{
/*
!!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be
!!! FIXME: busted on Android at the moment...
!!! FIXME: http://code.google.com/p/android/issues/detail?id=7681
!!! FIXME: ...so revisit this later. --ryan.
*/
return dlsym(Android_GLHandle, proc);
}
void
Android_GL_UnloadLibrary(_THIS)
{
if(Android_GLHandle) {
dlclose(Android_GLHandle);
Android_GLHandle = NULL;
}
}
SDL_GLContext
Android_GL_CreateContext(_THIS, SDL_Window * window)
{
if (!Android_JNI_CreateContext(_this->gl_config.major_version,
_this->gl_config.minor_version,
_this->gl_config.red_size,
_this->gl_config.green_size,
_this->gl_config.blue_size,
_this->gl_config.alpha_size,
_this->gl_config.buffer_size,
_this->gl_config.depth_size,
_this->gl_config.stencil_size,
_this->gl_config.multisamplebuffers,
_this->gl_config.multisamplesamples)) {
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)
{
if (context) {
Android_JNI_DeleteContext();
}
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,122 +0,0 @@
--- src/video/android/SDL_androidgl.c 2013-10-08 17:46:42.441362557 +0200
+++ src/video/android/SDL_androidgl.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,119 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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"
-
-#if SDL_VIDEO_DRIVER_ANDROID
-
-/* Android SDL video driver implementation */
-
-#include "SDL_video.h"
-
-#include "SDL_androidvideo.h"
-#include "../../core/android/SDL_android.h"
-
-#include <android/log.h>
-
-#include <dlfcn.h>
-
-static void* Android_GLHandle = NULL;
-
-/* GL functions */
-int
-Android_GL_LoadLibrary(_THIS, const char *path)
-{
- if (!Android_GLHandle) {
- Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL);
- if (!Android_GLHandle) {
- SDL_SetError("Could not initialize GL ES library\n");
- return -1;
- }
- }
- return 0;
-}
-
-void *
-Android_GL_GetProcAddress(_THIS, const char *proc)
-{
- /*
- !!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be
- !!! FIXME: busted on Android at the moment...
- !!! FIXME: http://code.google.com/p/android/issues/detail?id=7681
- !!! FIXME: ...so revisit this later. --ryan.
- */
- return dlsym(Android_GLHandle, proc);
-}
-
-void
-Android_GL_UnloadLibrary(_THIS)
-{
- if(Android_GLHandle) {
- dlclose(Android_GLHandle);
- Android_GLHandle = NULL;
- }
-}
-
-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");
-}
-
-#endif /* SDL_VIDEO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,333 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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"
#if SDL_VIDEO_DRIVER_ANDROID
#include <android/log.h>
#include "../../events/SDL_events_c.h"
#include "SDL_androidkeyboard.h"
#include "../../core/android/SDL_android.h"
void Android_InitKeyboard(void)
{
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_WWW, /* AKEYCODE_EXPLORER */
SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */
SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
SDL_SCANCODE_BACKSPACE, /* 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_SLASH, /* 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 */
SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */
SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */
SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */
SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */
SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */
SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */
SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */
SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */
SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */
SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */
SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */
SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */
SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */
SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */
SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */
SDL_SCANCODE_F1, /* AKEYCODE_F1 */
SDL_SCANCODE_F2, /* AKEYCODE_F2 */
SDL_SCANCODE_F3, /* AKEYCODE_F3 */
SDL_SCANCODE_F4, /* AKEYCODE_F4 */
SDL_SCANCODE_F5, /* AKEYCODE_F5 */
SDL_SCANCODE_F6, /* AKEYCODE_F6 */
SDL_SCANCODE_F7, /* AKEYCODE_F7 */
SDL_SCANCODE_F8, /* AKEYCODE_F8 */
SDL_SCANCODE_F9, /* AKEYCODE_F9 */
SDL_SCANCODE_F10, /* AKEYCODE_F10 */
SDL_SCANCODE_F11, /* AKEYCODE_F11 */
SDL_SCANCODE_F12, /* AKEYCODE_F12 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */
SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */
SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */
SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */
SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */
SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */
SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */
SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */
SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */
SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */
SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */
SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */
SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */
SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */
SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */
SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */
SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */
SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */
SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */
SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */
SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */
SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */
SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */
SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUHENKAN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HENKAN */
SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */
SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */
SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */
SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */
};
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));
}
SDL_bool
Android_HasScreenKeyboardSupport(_THIS)
{
return SDL_TRUE;
}
SDL_bool
Android_IsScreenKeyboardShown(_THIS, SDL_Window * window)
{
return SDL_IsTextInputActive();
}
void
Android_StartTextInput(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
Android_JNI_ShowTextInput(&videodata->textRect);
}
void
Android_StopTextInput(_THIS)
{
Android_JNI_HideTextInput();
}
void
Android_SetTextInputRect(_THIS, SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
if (!rect) {
SDL_InvalidParamError("rect");
return;
}
videodata->textRect = *rect;
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,186 +0,0 @@
--- src/video/android/SDL_androidkeyboard.c 2013-10-08 17:46:42.441362557 +0200
+++ src/video/android/SDL_androidkeyboard.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,183 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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"
-
-#if SDL_VIDEO_DRIVER_ANDROID
-
-#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));
-}
-
-#endif /* SDL_VIDEO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,36 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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(void);
extern int Android_OnKeyDown(int keycode);
extern int Android_OnKeyUp(int keycode);
extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window * window);
extern void Android_StartTextInput(_THIS);
extern void Android_StopTextInput(_THIS);
extern void Android_SetTextInputRect(_THIS, SDL_Rect *rect);
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,32 +0,0 @@
--- src/video/android/SDL_androidkeyboard.h 2013-10-08 17:46:42.441362557 +0200
+++ src/video/android/SDL_androidkeyboard.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,29 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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: */

View File

@@ -1,113 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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"
#if SDL_VIDEO_DRIVER_ANDROID
#include <android/log.h>
#include "SDL_events.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
#include "SDL_log.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
/* The following two are deprecated but it seems they are still emitted (instead the corresponding ACTION_UP/DOWN) as of Android 3.2 */
#define ACTION_POINTER_1_DOWN 5
#define ACTION_POINTER_1_UP 6
static SDL_FingerID leftFingerDown = 0;
static void Android_GetWindowCoordinates(float x, float y,
int *window_x, int *window_y)
{
int window_w, window_h;
SDL_GetWindowSize(Android_Window, &window_w, &window_h);
*window_x = (int)(x * window_w);
*window_y = (int)(y * window_h);
}
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
{
SDL_TouchID touchDeviceId = 0;
SDL_FingerID fingerId = 0;
int window_x, window_y;
if (!Android_Window) {
return;
}
touchDeviceId = (SDL_TouchID)touch_device_id_in;
if (SDL_AddTouch(touchDeviceId, "") < 0) {
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
}
fingerId = (SDL_FingerID)pointer_finger_id_in;
switch (action) {
case ACTION_DOWN:
case ACTION_POINTER_1_DOWN:
if (!leftFingerDown) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
/* send mouse down event */
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
leftFingerDown = fingerId;
}
SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
break;
case ACTION_MOVE:
if (!leftFingerDown) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
}
SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
break;
case ACTION_UP:
case ACTION_POINTER_1_UP:
if (fingerId == leftFingerDown) {
/* send mouse up */
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
leftFingerDown = 0;
}
SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
break;
default:
break;
}
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,95 +0,0 @@
--- src/video/android/SDL_androidtouch.c 2013-10-08 17:46:42.444695923 +0200
+++ src/video/android/SDL_androidtouch.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,92 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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"
-
-#if SDL_VIDEO_DRIVER_ANDROID
-
-#include <android/log.h>
-
-#include "SDL_events.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_touch_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
-// The following two are deprecated but it seems they are still emitted (instead the corresponding ACTION_UP/DOWN) as of Android 3.2
-#define ACTION_POINTER_1_DOWN 5
-#define ACTION_POINTER_1_UP 6
-
-void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
-{
- SDL_TouchID touchDeviceId = 0;
- SDL_FingerID fingerId = 0;
-
- if (!Android_Window) {
- return;
- }
-
- touchDeviceId = (SDL_TouchID)touch_device_id_in;
- if (!SDL_GetTouch(touchDeviceId)) {
- SDL_Touch touch;
- memset( &touch, 0, sizeof(touch) );
- touch.id = touchDeviceId;
- touch.x_min = 0.0f;
- touch.x_max = (float)Android_ScreenWidth;
- touch.native_xres = touch.x_max - touch.x_min;
- touch.y_min = 0.0f;
- touch.y_max = (float)Android_ScreenHeight;
- touch.native_yres = touch.y_max - touch.y_min;
- touch.pressure_min = 0.0f;
- touch.pressure_max = 1.0f;
- touch.native_pressureres = touch.pressure_max - touch.pressure_min;
- if (SDL_AddTouch(&touch, "") < 0) {
- SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
- }
- }
-
-
- fingerId = (SDL_FingerID)pointer_finger_id_in;
- switch (action) {
- case ACTION_DOWN:
- case ACTION_POINTER_1_DOWN:
- SDL_SendFingerDown(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
- break;
- case ACTION_MOVE:
- SDL_SendTouchMotion(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
- break;
- case ACTION_UP:
- case ACTION_POINTER_1_UP:
- SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
- break;
- default:
- break;
- }
-}
-
-#endif /* SDL_VIDEO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,27 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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 touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p);
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,30 +0,0 @@
--- src/video/android/SDL_androidtouch.h 2013-10-08 17:46:42.444695923 +0200
+++ src/video/android/SDL_androidtouch.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,27 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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 touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p);
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,83 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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"
#if SDL_VIDEO_DRIVER_ANDROID
#include "../SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#include "SDL_androidvideo.h"
#include "SDL_androidwindow.h"
#include "../../core/android/SDL_android.h"
int
Android_CreateWindow(_THIS, SDL_Window * window)
{
if (Android_Window) {
return SDL_SetError("Android only supports one window");
}
Android_Window = window;
Android_PauseSem = SDL_CreateSemaphore(0);
Android_ResumeSem = SDL_CreateSemaphore(0);
/* 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_HIDDEN;
window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
/* One window, it always has focus */
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
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;
if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem);
if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem);
Android_PauseSem = NULL;
Android_ResumeSem = NULL;
}
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,73 +0,0 @@
--- src/video/android/SDL_androidwindow.c 2013-10-08 17:46:42.444695923 +0200
+++ src/video/android/SDL_androidwindow.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,70 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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"
-
-#if SDL_VIDEO_DRIVER_ANDROID
-
-#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_HIDDEN;
- 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;
- }
-}
-
-#endif /* SDL_VIDEO_DRIVER_ANDROID */
-
-/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,32 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 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: */

View File

@@ -1,35 +0,0 @@
--- src/video/android/SDL_androidwindow.h 2013-10-08 17:46:42.444695923 +0200
+++ src/video/android/SDL_androidwindow.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 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: */