1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java Wed Jan 12 13:52:27 2011 -0800
1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java Wed Jan 12 13:52:41 2011 -0800
1.3 @@ -158,12 +158,6 @@
1.4 }
1.5 }
1.6 }
1.7 -
1.8 -
1.9 -
1.10 -
1.11 -
1.12 -
1.13
1.14 }
1.15
2.1 --- a/src/SDL_android.cpp Wed Jan 12 13:52:27 2011 -0800
2.2 +++ b/src/SDL_android.cpp Wed Jan 12 13:52:41 2011 -0800
2.3 @@ -21,6 +21,11 @@
2.4 */
2.5 #include "SDL_config.h"
2.6
2.7 +extern "C" {
2.8 +#include "events/SDL_events_c.h"
2.9 +#include "video/android/SDL_androidkeyboard.h"
2.10 +}
2.11 +
2.12 /*******************************************************************************
2.13 This file links the Java side of Android with libsdl
2.14 *******************************************************************************/
2.15 @@ -44,12 +49,8 @@
2.16 jmethodID midEnableFeature;
2.17 jmethodID midUpdateAudio;
2.18
2.19 -extern "C" int Android_OnKeyDown(int keycode);
2.20 -extern "C" int Android_OnKeyUp(int keycode);
2.21 extern "C" void Android_SetScreenResolution(int width, int height);
2.22 -extern "C" void Android_OnResize(int width, int height, int format);
2.23 extern "C" int SDL_SendQuit();
2.24 -extern "C" void Android_EnableFeature(int featureid, bool enabled);
2.25
2.26 //If we're not the active app, don't try to render
2.27 bool bRenderingEnabled = false;
2.28 @@ -102,22 +103,22 @@
2.29 extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(JNIEnv* env,
2.30 jobject obj, jint keycode)
2.31 {
2.32 - int r = Android_OnKeyDown(keycode);
2.33 #ifdef DEBUG
2.34 __android_log_print(ANDROID_LOG_INFO, "SDL",
2.35 - "SDL: native key down %d, %d\n", keycode, r);
2.36 + "SDL: native key down %d\n", keycode);
2.37 #endif
2.38 + Android_OnKeyDown(keycode);
2.39 }
2.40
2.41 // Keyup
2.42 extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(JNIEnv* env,
2.43 jobject obj, jint keycode)
2.44 {
2.45 - int r = Android_OnKeyUp(keycode);
2.46 #ifdef DEBUG
2.47 __android_log_print(ANDROID_LOG_INFO, "SDL",
2.48 - "SDL: native key up %d, %d\n", keycode, r);
2.49 + "SDL: native key up %d\n", keycode);
2.50 #endif
2.51 + Android_OnKeyUp(keycode);
2.52 }
2.53
2.54 // Touch
2.55 @@ -158,7 +159,7 @@
2.56 JNIEnv* env, jobject obj, jint width,
2.57 jint height, jint format)
2.58 {
2.59 - Android_OnResize(width, height, format);
2.60 + /* FIXME: What is the relationship between this and the window? */
2.61 }
2.62
2.63 extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
2.64 @@ -228,4 +229,3 @@
2.65 __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: invoked\n");
2.66
2.67 }
2.68 -
3.1 --- a/src/video/android/SDL_androidevents.c Wed Jan 12 13:52:27 2011 -0800
3.2 +++ b/src/video/android/SDL_androidevents.c Wed Jan 12 13:52:41 2011 -0800
3.3 @@ -21,58 +21,12 @@
3.4 */
3.5 #include "SDL_config.h"
3.6
3.7 -/* Being a null driver, there's no event stream. We just define stubs for
3.8 - most of the API. */
3.9 -
3.10 -#include <stdio.h>
3.11 -#include <stdlib.h>
3.12 -
3.13 -#include "../../events/SDL_sysevents.h"
3.14 -#include "../../events/SDL_events_c.h"
3.15 -
3.16 #include "SDL_androidevents.h"
3.17
3.18 -void Android_InitEvents()
3.19 -{
3.20 - SDLKey keymap[SDL_NUM_SCANCODES];
3.21 -
3.22 - /* Add default scancode to key mapping */
3.23 - SDL_GetDefaultKeymap(keymap);
3.24 - SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
3.25 -}
3.26 -
3.27 void
3.28 Android_PumpEvents(_THIS)
3.29 {
3.30 -
3.31 - //scanKeys();
3.32 - /* TODO: defer click-age */
3.33 - /*
3.34 - if (keysDown() & KEY_TOUCH) {
3.35 - SDL_SendMouseButton(0, SDL_PRESSED, 0);
3.36 - } else if (keysUp() & KEY_TOUCH) {
3.37 - SDL_SendMouseButton(0, SDL_RELEASED, 0);
3.38 - }
3.39 - if (keysHeld() & KEY_TOUCH) {
3.40 - touchPosition t = touchReadXY();
3.41 - SDL_SendMouseMotion(0, 0, t.px, t.py, 1);
3.42 - }
3.43 - */
3.44 -}
3.45 -
3.46 -
3.47 -void Android_OnResize(int width, int height, int format){
3.48 -
3.49 -}
3.50 -
3.51 -int
3.52 -Android_OnKeyDown(int keycode){
3.53 - return SDL_SendKeyboardKey(SDL_PRESSED, (SDL_scancode)keycode);
3.54 -}
3.55 -
3.56 -int
3.57 -Android_OnKeyUp(int keycode){
3.58 - return SDL_SendKeyboardKey(SDL_RELEASED, (SDL_scancode)keycode);
3.59 + /* No polling necessary */
3.60 }
3.61
3.62 /* vi: set ts=4 sw=4 expandtab: */
4.1 --- a/src/video/android/SDL_androidevents.h Wed Jan 12 13:52:27 2011 -0800
4.2 +++ b/src/video/android/SDL_androidevents.h Wed Jan 12 13:52:41 2011 -0800
4.3 @@ -24,6 +24,5 @@
4.4 #include "SDL_androidvideo.h"
4.5
4.6 extern void Android_PumpEvents(_THIS);
4.7 -extern void Android_InitEvents();
4.8
4.9 /* vi: set ts=4 sw=4 expandtab: */
5.1 --- a/src/video/android/SDL_androidgl.c Wed Jan 12 13:52:27 2011 -0800
5.2 +++ b/src/video/android/SDL_androidgl.c Wed Jan 12 13:52:41 2011 -0800
5.3 @@ -21,17 +21,11 @@
5.4 */
5.5 #include "SDL_config.h"
5.6
5.7 -/* Android SDL video driver implementation
5.8 -*/
5.9 +/* Android SDL video driver implementation */
5.10
5.11 #include "SDL_video.h"
5.12 -#include "SDL_mouse.h"
5.13 -#include "../SDL_sysvideo.h"
5.14 -#include "../SDL_pixels_c.h"
5.15 -#include "../../events/SDL_events_c.h"
5.16
5.17 #include "SDL_androidvideo.h"
5.18 -#include "SDL_androidevents.h"
5.19
5.20 #include <android/log.h>
5.21
5.22 @@ -58,13 +52,6 @@
5.23 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
5.24 }
5.25
5.26 -/*
5.27 -int *Android_GL_GetVisual(_THIS, Display * display, int screen){
5.28 - __android_log_print(ANDROID_LOG_INFO, "SDL","[STUB] GL_GetVisual\n");
5.29 - return 0;
5.30 -}
5.31 -*/
5.32 -
5.33 SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
5.34 Android_CreateContext();
5.35 return 1;
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/src/video/android/SDL_androidkeyboard.c Wed Jan 12 13:52:41 2011 -0800
6.3 @@ -0,0 +1,52 @@
6.4 +/*
6.5 + SDL - Simple DirectMedia Layer
6.6 + Copyright (C) 1997-2010 Sam Lantinga
6.7 +
6.8 + This library is free software; you can redistribute it and/or
6.9 + modify it under the terms of the GNU Lesser General Public
6.10 + License as published by the Free Software Foundation; either
6.11 + version 2.1 of the License, or (at your option) any later version.
6.12 +
6.13 + This library is distributed in the hope that it will be useful,
6.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
6.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6.16 + Lesser General Public License for more details.
6.17 +
6.18 + You should have received a copy of the GNU Lesser General Public
6.19 + License along with this library; if not, write to the Free Software
6.20 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6.21 +
6.22 + Sam Lantinga
6.23 + slouken@libsdl.org
6.24 +*/
6.25 +#include "SDL_config.h"
6.26 +
6.27 +#include "../../events/SDL_events_c.h"
6.28 +
6.29 +#include "SDL_androidkeyboard.h"
6.30 +
6.31 +
6.32 +void Android_InitKeyboard()
6.33 +{
6.34 + SDLKey keymap[SDL_NUM_SCANCODES];
6.35 +
6.36 + /* Add default scancode to key mapping */
6.37 + SDL_GetDefaultKeymap(keymap);
6.38 + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
6.39 +}
6.40 +
6.41 +int
6.42 +Android_OnKeyDown(int keycode)
6.43 +{
6.44 + /* FIXME: Need conversion from Android keycode to SDL scancode */
6.45 + return SDL_SendKeyboardKey(SDL_PRESSED, (SDL_scancode)keycode);
6.46 +}
6.47 +
6.48 +int
6.49 +Android_OnKeyUp(int keycode)
6.50 +{
6.51 + /* FIXME: Need conversion from Android keycode to SDL scancode */
6.52 + return SDL_SendKeyboardKey(SDL_RELEASED, (SDL_scancode)keycode);
6.53 +}
6.54 +
6.55 +/* vi: set ts=4 sw=4 expandtab: */
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/src/video/android/SDL_androidkeyboard.h Wed Jan 12 13:52:41 2011 -0800
7.3 @@ -0,0 +1,30 @@
7.4 +/*
7.5 + SDL - Simple DirectMedia Layer
7.6 + Copyright (C) 1997-2010 Sam Lantinga
7.7 +
7.8 + This library is free software; you can redistribute it and/or
7.9 + modify it under the terms of the GNU Lesser General Public
7.10 + License as published by the Free Software Foundation; either
7.11 + version 2.1 of the License, or (at your option) any later version.
7.12 +
7.13 + This library is distributed in the hope that it will be useful,
7.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
7.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7.16 + Lesser General Public License for more details.
7.17 +
7.18 + You should have received a copy of the GNU Lesser General Public
7.19 + License along with this library; if not, write to the Free Software
7.20 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7.21 +
7.22 + Sam Lantinga
7.23 + slouken@libsdl.org
7.24 +*/
7.25 +#include "SDL_config.h"
7.26 +
7.27 +#include "SDL_androidvideo.h"
7.28 +
7.29 +extern void Android_InitKeyboard();
7.30 +extern int Android_OnKeyDown(int keycode);
7.31 +extern int Android_OnKeyUp(int keycode);
7.32 +
7.33 +/* vi: set ts=4 sw=4 expandtab: */
8.1 --- a/src/video/android/SDL_androidvideo.c Wed Jan 12 13:52:27 2011 -0800
8.2 +++ b/src/video/android/SDL_androidvideo.c Wed Jan 12 13:52:41 2011 -0800
8.3 @@ -32,12 +32,12 @@
8.4
8.5 #include "SDL_androidvideo.h"
8.6 #include "SDL_androidevents.h"
8.7 +#include "SDL_androidkeyboard.h"
8.8
8.9 #define ANDROID_VID_DRIVER_NAME "Android"
8.10
8.11 /* Initialization/Query functions */
8.12 static int Android_VideoInit(_THIS);
8.13 -static int Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
8.14 static void Android_VideoQuit(_THIS);
8.15
8.16 /* GL functions (SDL_androidgl.c) */
8.17 @@ -93,9 +93,8 @@
8.18 /* Set the function pointers */
8.19 device->VideoInit = Android_VideoInit;
8.20 device->VideoQuit = Android_VideoQuit;
8.21 - device->SetDisplayMode = Android_SetDisplayMode;
8.22 device->PumpEvents = Android_PumpEvents;
8.23 -
8.24 +
8.25 device->free = Android_DeleteDevice;
8.26
8.27 /* GL pointers */
8.28 @@ -136,18 +135,12 @@
8.29 SDL_zero(mode);
8.30 SDL_AddDisplayMode(&_this->displays[0], &mode);
8.31
8.32 - Android_InitEvents();
8.33 + Android_InitKeyboard();
8.34
8.35 /* We're done! */
8.36 return 0;
8.37 }
8.38
8.39 -static int
8.40 -Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
8.41 -{
8.42 - return 0;
8.43 -}
8.44 -
8.45 void
8.46 Android_VideoQuit(_THIS)
8.47 {
8.48 @@ -160,5 +153,4 @@
8.49 }
8.50
8.51
8.52 -
8.53 /* vi: set ts=4 sw=4 expandtab: */