A bit of cleanup in the Android driver
This commit is contained in:
parent
74b33811bd
commit
a410db1ae6
8 changed files with 97 additions and 89 deletions
|
@ -159,12 +159,6 @@ public class SDLActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "events/SDL_events_c.h"
|
||||||
|
#include "video/android/SDL_androidkeyboard.h"
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
This file links the Java side of Android with libsdl
|
This file links the Java side of Android with libsdl
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -44,12 +49,8 @@ jmethodID midFlipBuffers;
|
||||||
jmethodID midEnableFeature;
|
jmethodID midEnableFeature;
|
||||||
jmethodID midUpdateAudio;
|
jmethodID midUpdateAudio;
|
||||||
|
|
||||||
extern "C" int Android_OnKeyDown(int keycode);
|
|
||||||
extern "C" int Android_OnKeyUp(int keycode);
|
|
||||||
extern "C" void Android_SetScreenResolution(int width, int height);
|
extern "C" void Android_SetScreenResolution(int width, int height);
|
||||||
extern "C" void Android_OnResize(int width, int height, int format);
|
|
||||||
extern "C" int SDL_SendQuit();
|
extern "C" int SDL_SendQuit();
|
||||||
extern "C" void Android_EnableFeature(int featureid, bool enabled);
|
|
||||||
|
|
||||||
//If we're not the active app, don't try to render
|
//If we're not the active app, don't try to render
|
||||||
bool bRenderingEnabled = false;
|
bool bRenderingEnabled = false;
|
||||||
|
@ -102,22 +103,22 @@ extern "C" void SDL_Android_Init(JNIEnv* env)
|
||||||
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(JNIEnv* env,
|
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(JNIEnv* env,
|
||||||
jobject obj, jint keycode)
|
jobject obj, jint keycode)
|
||||||
{
|
{
|
||||||
int r = Android_OnKeyDown(keycode);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
__android_log_print(ANDROID_LOG_INFO, "SDL",
|
__android_log_print(ANDROID_LOG_INFO, "SDL",
|
||||||
"SDL: native key down %d, %d\n", keycode, r);
|
"SDL: native key down %d\n", keycode);
|
||||||
#endif
|
#endif
|
||||||
|
Android_OnKeyDown(keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyup
|
// Keyup
|
||||||
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(JNIEnv* env,
|
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(JNIEnv* env,
|
||||||
jobject obj, jint keycode)
|
jobject obj, jint keycode)
|
||||||
{
|
{
|
||||||
int r = Android_OnKeyUp(keycode);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
__android_log_print(ANDROID_LOG_INFO, "SDL",
|
__android_log_print(ANDROID_LOG_INFO, "SDL",
|
||||||
"SDL: native key up %d, %d\n", keycode, r);
|
"SDL: native key up %d\n", keycode);
|
||||||
#endif
|
#endif
|
||||||
|
Android_OnKeyUp(keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Touch
|
// Touch
|
||||||
|
@ -158,7 +159,7 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
|
||||||
JNIEnv* env, jobject obj, jint width,
|
JNIEnv* env, jobject obj, jint width,
|
||||||
jint height, jint format)
|
jint height, jint format)
|
||||||
{
|
{
|
||||||
Android_OnResize(width, height, format);
|
/* FIXME: What is the relationship between this and the window? */
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
|
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
|
||||||
|
@ -228,4 +229,3 @@ extern "C" void Android_UpdateAudioBuffer(unsigned char *buf, int len)
|
||||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: invoked\n");
|
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: invoked\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,58 +21,12 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
/* Being a null driver, there's no event stream. We just define stubs for
|
|
||||||
most of the API. */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "../../events/SDL_sysevents.h"
|
|
||||||
#include "../../events/SDL_events_c.h"
|
|
||||||
|
|
||||||
#include "SDL_androidevents.h"
|
#include "SDL_androidevents.h"
|
||||||
|
|
||||||
void Android_InitEvents()
|
|
||||||
{
|
|
||||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
|
||||||
|
|
||||||
/* Add default scancode to key mapping */
|
|
||||||
SDL_GetDefaultKeymap(keymap);
|
|
||||||
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Android_PumpEvents(_THIS)
|
Android_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
|
/* No polling necessary */
|
||||||
//scanKeys();
|
|
||||||
/* TODO: defer click-age */
|
|
||||||
/*
|
|
||||||
if (keysDown() & KEY_TOUCH) {
|
|
||||||
SDL_SendMouseButton(0, SDL_PRESSED, 0);
|
|
||||||
} else if (keysUp() & KEY_TOUCH) {
|
|
||||||
SDL_SendMouseButton(0, SDL_RELEASED, 0);
|
|
||||||
}
|
|
||||||
if (keysHeld() & KEY_TOUCH) {
|
|
||||||
touchPosition t = touchReadXY();
|
|
||||||
SDL_SendMouseMotion(0, 0, t.px, t.py, 1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Android_OnResize(int width, int height, int format){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
Android_OnKeyDown(int keycode){
|
|
||||||
return SDL_SendKeyboardKey(SDL_PRESSED, (SDL_scancode)keycode);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
Android_OnKeyUp(int keycode){
|
|
||||||
return SDL_SendKeyboardKey(SDL_RELEASED, (SDL_scancode)keycode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -24,6 +24,5 @@
|
||||||
#include "SDL_androidvideo.h"
|
#include "SDL_androidvideo.h"
|
||||||
|
|
||||||
extern void Android_PumpEvents(_THIS);
|
extern void Android_PumpEvents(_THIS);
|
||||||
extern void Android_InitEvents();
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -21,17 +21,11 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
/* Android SDL video driver implementation
|
/* Android SDL video driver implementation */
|
||||||
*/
|
|
||||||
|
|
||||||
#include "SDL_video.h"
|
#include "SDL_video.h"
|
||||||
#include "SDL_mouse.h"
|
|
||||||
#include "../SDL_sysvideo.h"
|
|
||||||
#include "../SDL_pixels_c.h"
|
|
||||||
#include "../../events/SDL_events_c.h"
|
|
||||||
|
|
||||||
#include "SDL_androidvideo.h"
|
#include "SDL_androidvideo.h"
|
||||||
#include "SDL_androidevents.h"
|
|
||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
|
@ -58,13 +52,6 @@ void Android_GL_UnloadLibrary(_THIS){
|
||||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
|
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
int *Android_GL_GetVisual(_THIS, Display * display, int screen){
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "SDL","[STUB] GL_GetVisual\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
|
SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
|
||||||
Android_CreateContext();
|
Android_CreateContext();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
52
src/video/android/SDL_androidkeyboard.c
Normal file
52
src/video/android/SDL_androidkeyboard.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
SDL - Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2010 Sam Lantinga
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Sam Lantinga
|
||||||
|
slouken@libsdl.org
|
||||||
|
*/
|
||||||
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
|
||||||
|
#include "SDL_androidkeyboard.h"
|
||||||
|
|
||||||
|
|
||||||
|
void Android_InitKeyboard()
|
||||||
|
{
|
||||||
|
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||||
|
|
||||||
|
/* Add default scancode to key mapping */
|
||||||
|
SDL_GetDefaultKeymap(keymap);
|
||||||
|
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Android_OnKeyDown(int keycode)
|
||||||
|
{
|
||||||
|
/* FIXME: Need conversion from Android keycode to SDL scancode */
|
||||||
|
return SDL_SendKeyboardKey(SDL_PRESSED, (SDL_scancode)keycode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Android_OnKeyUp(int keycode)
|
||||||
|
{
|
||||||
|
/* FIXME: Need conversion from Android keycode to SDL scancode */
|
||||||
|
return SDL_SendKeyboardKey(SDL_RELEASED, (SDL_scancode)keycode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
30
src/video/android/SDL_androidkeyboard.h
Normal file
30
src/video/android/SDL_androidkeyboard.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
SDL - Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2010 Sam Lantinga
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Sam Lantinga
|
||||||
|
slouken@libsdl.org
|
||||||
|
*/
|
||||||
|
#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: */
|
|
@ -32,12 +32,12 @@
|
||||||
|
|
||||||
#include "SDL_androidvideo.h"
|
#include "SDL_androidvideo.h"
|
||||||
#include "SDL_androidevents.h"
|
#include "SDL_androidevents.h"
|
||||||
|
#include "SDL_androidkeyboard.h"
|
||||||
|
|
||||||
#define ANDROID_VID_DRIVER_NAME "Android"
|
#define ANDROID_VID_DRIVER_NAME "Android"
|
||||||
|
|
||||||
/* Initialization/Query functions */
|
/* Initialization/Query functions */
|
||||||
static int Android_VideoInit(_THIS);
|
static int Android_VideoInit(_THIS);
|
||||||
static int Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
|
||||||
static void Android_VideoQuit(_THIS);
|
static void Android_VideoQuit(_THIS);
|
||||||
|
|
||||||
/* GL functions (SDL_androidgl.c) */
|
/* GL functions (SDL_androidgl.c) */
|
||||||
|
@ -93,7 +93,6 @@ Android_CreateDevice(int devindex)
|
||||||
/* Set the function pointers */
|
/* Set the function pointers */
|
||||||
device->VideoInit = Android_VideoInit;
|
device->VideoInit = Android_VideoInit;
|
||||||
device->VideoQuit = Android_VideoQuit;
|
device->VideoQuit = Android_VideoQuit;
|
||||||
device->SetDisplayMode = Android_SetDisplayMode;
|
|
||||||
device->PumpEvents = Android_PumpEvents;
|
device->PumpEvents = Android_PumpEvents;
|
||||||
|
|
||||||
device->free = Android_DeleteDevice;
|
device->free = Android_DeleteDevice;
|
||||||
|
@ -136,18 +135,12 @@ Android_VideoInit(_THIS)
|
||||||
SDL_zero(mode);
|
SDL_zero(mode);
|
||||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||||
|
|
||||||
Android_InitEvents();
|
Android_InitKeyboard();
|
||||||
|
|
||||||
/* We're done! */
|
/* We're done! */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Android_VideoQuit(_THIS)
|
Android_VideoQuit(_THIS)
|
||||||
{
|
{
|
||||||
|
@ -160,5 +153,4 @@ void Android_SetScreenResolution(int width, int height){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue