Added SDL 1.3 multitouch support via SDL_FINGERDOWN/UP/MOTION events

This commit is contained in:
pelya
2010-10-12 15:47:57 +03:00
parent 5f47811d88
commit a5ff12846e
24 changed files with 83 additions and 40 deletions

View File

@@ -98,7 +98,7 @@ if [ -n "$var" ] ; then
AppUsesJoystick="$var"
fi
echo -n "\nApplication uses multitouch (y) or (n), multitouch events are passed as \n4-axis joysticks 1-5, including pressure and size ($AppUsesMultitouch): "
echo -n "\nApplication uses multitouch (y) or (n), multitouch events are passed as 4-axis joysticks 1-5, with pressure and size,\nor additionally as SDL_FINGERDOWN/UP/MOTION events in SDL 1.3, with SDL pressure = Android pressure * Andorid touchspot size ($AppUsesMultitouch): "
read var
if [ -n "$var" ] ; then
AppUsesMultitouch="$var"

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teeworlds"
android:versionCode="5202"
android:versionName="0.5.2.02"
package="de.schwardtnet.alienblaster"
android:versionCode="110011"
android:versionName="1.1.0.11 - fixed keys stuck sometimes for on-screen keyboard, fixed restoring app from background"
android:installLocation="preferExternal"
>
<application android:label="@string/app_name"

View File

@@ -1,6 +1,6 @@
# The namespace in Java file, with dots replaced with underscores
SDL_JAVA_PACKAGE_PATH := com_teeworlds
SDL_JAVA_PACKAGE_PATH := de_schwardtnet_alienblaster
# Path to shared libraries - Android 1.6 cannot load them properly, thus we have to specify absolute path here
# SDL_SHARED_LIBRARIES_PATH := /data/data/de.schwardtnet.alienblaster/lib
@@ -10,7 +10,7 @@ SDL_JAVA_PACKAGE_PATH := com_teeworlds
# Typically /sdcard/alienblaster
# Or /data/data/de.schwardtnet.alienblaster/files if you're planning to unpack data in application private folder
# Your application will just set current directory there
SDL_CURDIR_PATH := com.teeworlds
SDL_CURDIR_PATH := de.schwardtnet.alienblaster
# Android Dev Phone G1 has trackball instead of cursor keys, and
# sends trackball movement events as rapid KeyDown/KeyUp events,
@@ -21,19 +21,19 @@ SDL_TRACKBALL_KEYUP_DELAY := 1
# If the application designed for higher screen resolution enable this to get the screen
# resized in HW-accelerated way, however it eats a tiny bit of CPU
SDL_VIDEO_RENDER_RESIZE := 0
SDL_VIDEO_RENDER_RESIZE := 1
COMPILED_LIBRARIES := sdl_image xml2
COMPILED_LIBRARIES := sdl_mixer sdl_image
APPLICATION_ADDITIONAL_CFLAGS := -O2
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
APPLICATION_ADDITIONAL_LDFLAGS := -Lbin/ndk/local/armeabi -lfreetype
APPLICATION_ADDITIONAL_LDFLAGS :=
APPLICATION_SUBDIRS_BUILD :=
APPLICATION_CUSTOM_BUILD_SCRIPT :=
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=SPACE -DSDL_ANDROID_KEYCODE_1=RETURN -DSDL_ANDROID_KEYCODE_2=LEFT -DSDL_ANDROID_KEYCODE_3=RIGHT -DSDL_ANDROID_KEYCODE_4=LSHIFT -DSDL_ANDROID_KEYCODE_5=ESCAPE -DSDL_ANDROID_KEYCODE_6=RSHIFT -DSDL_ANDROID_KEYCODE_7=LSHIFT
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=RETURN -DSDL_ANDROID_KEYCODE_1=LCTRL -DSDL_ANDROID_KEYCODE_2=PAGEUP -DSDL_ANDROID_KEYCODE_3=PAGEDOWN -DSDL_ANDROID_KEYCODE_4=LCTRL
# If SDL_Mixer should link to libMAD
SDL_MIXER_USE_LIBMAD :=

View File

@@ -5,6 +5,6 @@ APP_PROJECT_PATH := $(call my-dir)/..
# sdl_image depends on png and jpeg
# sdl_ttf depends on freetype
APP_MODULES := application sdl sdl_main stlport tremor png jpeg freetype sdl_image xml2
APP_MODULES := application sdl sdl_main stlport tremor png jpeg freetype sdl_mixer sdl_image
APP_ABI := armeabi armeabi-v7a
APP_ABI := armeabi

View File

@@ -105,8 +105,19 @@ static inline void SdlCompat_ReloadSurfaceToVideoMemory(SdlCompat_AcceleratedSur
SDL_PixelFormatEnumToMasks(format, &bpp, &r, &g, &b, &a);
SDL_Surface * formatsurf = SDL_CreateRGBSurface(0, 1, 1, bpp, r, g, b, a);
SDL_Surface * converted = SDL_ConvertSurface( src, formatsurf->format, 0 );
SDL_LockSurface(converted);
// debug
/*
for( int x=0; x<converted->w; x++ )
for( int y=0; y<converted->h; y++ )
*(Sint16 *) ( ((Uint8 *)converted->pixels) + y*converted->pitch + x*2 ) = y*4;
*/
// end debug
SDL_UpdateTexture( surface->t, NULL, converted->pixels, converted->pitch );
SDL_UnlockSurface(converted);
SDL_FreeSurface(converted);
SDL_FreeSurface(formatsurf);

View File

@@ -125,6 +125,7 @@ SdlCompat_AcceleratedSurface *SurfaceDB::getSurface( string fn ) {
void SurfaceDB::reloadAllSurfacesToVideoMemory()
{
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", "Reloading all video surfaces" );
for( StringSurfaceMap::iterator it = surfaceDB.begin(); it != surfaceDB.end(); it++ )
{
SdlCompat_ReloadSurfaceToVideoMemory( it->second.first, loadSurfaceInternal( it->first, it->second.second ) );

View File

@@ -1 +1 @@
teeworlds
alienblaster

View File

@@ -1 +1 @@
../sdl/sdl-1.2
../sdl/sdl-1.3

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TeeWorlds</string>
<string name="app_name">Alien Blaster</string>
</resources>

View File

@@ -155,6 +155,8 @@
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_SYSCONF 1
#undef HAVE_SYSCTLBYNAME
#undef SDL_ALTIVEC_BLITTERS

View File

@@ -455,9 +455,6 @@ extern VideoBootStrap NDS_bootstrap;
#if SDL_VIDEO_DRIVER_PANDORA
extern VideoBootStrap PND_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_ANDROID
extern VideoBootStrap Android_bootstrap;
#endif
#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)

View File

@@ -104,9 +104,6 @@ static VideoBootStrap *bootstrap[] = {
#endif
#if SDL_VIDEO_DRIVER_PANDORA
&PND_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_ANDROID
&Android_bootstrap,
#endif
NULL
};

View File

@@ -30,12 +30,17 @@
#include "SDL_config.h"
#include "SDL_version.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_touch.h"
#include "../../events/SDL_touch_c.h"
#endif
#include "../SDL_sysvideo.h"
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "jniwrapperstuff.h"
SDLKey SDL_android_keymap[KEYCODE_LAST+1];
@@ -76,6 +81,15 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
if( isMultitouchUsed )
{
#if SDL_VERSION_ATLEAST(1,3,0)
// Use nifty SDL 1.3 multitouch API
if( action == MOUSE_MOVE )
SDL_SendTouchMotion(0, pointerId, 0, x, y, force*radius / 16);
else
SDL_SendFingerDown(0, pointerId, action == MOUSE_DOWN ? 1 : 0, x, y, force*radius / 16);
#endif
if( CurrentJoysticks[pointerId] )
{
SDL_PrivateJoystickAxis(CurrentJoysticks[pointerId+1], 0, x);
@@ -185,6 +199,24 @@ void ANDROID_InitOSKeymap()
SDLKey defaultKeymap[SDL_NUM_SCANCODES];
SDL_GetDefaultKeymap(defaultKeymap);
SDL_SetKeymap(0, defaultKeymap, SDL_NUM_SCANCODES);
SDL_Touch touch;
memset( &touch, 0, sizeof(touch) );
touch.x_min = touch.y_min = touch.pressure_min = 0.0f;
touch.pressure_max = 1000000;
touch.x_max = SDL_ANDROID_sWindowWidth;
touch.y_max = SDL_ANDROID_sWindowHeight;
// These constants are hardcoded inside SDL_touch.c, which makes no sense for me.
touch.xres = touch.yres = 32768;
touch.native_xres = touch.native_yres = 32768.0f;
touch.pressureres = 1;
touch.native_pressureres = 1.0f;
touch.id = 0;
SDL_AddTouch(&touch, "Android touch screen");
#endif
// TODO: keys are mapped rather randomly

View File

@@ -71,7 +71,7 @@ static inline SDL_scancode GetKeysym(SDL_scancode scancode, SDL_keysym *keysym)
return scancode;
}
#define SDL_SendKeyboardKey(X, Y) SDL_SendKeyboardKey(X, Y, SDL_FALSE)
//#define SDL_SendKeyboardKey(X, Y, Z) SDL_SendKeyboardKey(X, Y)
#else

View File

@@ -39,6 +39,8 @@
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "SDL_touch.h"
#include "../../events/SDL_touch_c.h"
#include "SDL_androidvideo.h"
@@ -194,6 +196,7 @@ SDL_Window * ANDROID_CurrentWindow = NULL;
int ANDROID_CreateWindow(_THIS, SDL_Window * window)
{
ANDROID_CurrentWindow = window;
SDL_SetTouchFocus(0, window);
};
void ANDROID_DestroyWindow(_THIS, SDL_Window * window)
{

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;

View File

@@ -1,6 +1,6 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change
// spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import java.util.zip.*;
import java.io.*;

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;

View File

@@ -18,7 +18,7 @@
fixed with a hammer and rasp to work with libSDL port */
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import java.io.Writer;
import java.util.ArrayList;

View File

@@ -1,14 +1,14 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount anywhere
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;
class Globals {
public static String ApplicationName = "TeeWorlds";
public static String ApplicationName = "AlienBlaster";
// Should be zip file
public static String DataDownloadUrl = "Game data is 8 Mb|http://sourceforge.net/projects/libsdl-android/files/TeeWorlds/teeworlds.zip/download";
public static String DataDownloadUrl = "Data size is 2 Mb|http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/alienblaster110_data.zip";
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
public static boolean NeedDepthBuffer = false;
@@ -17,9 +17,9 @@ class Globals {
public static boolean HorizontalOrientation = true;
// Readme text to be shown on download page
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
public static String ReadmeText = "^You can press \"Home\" now - the data will be downloaded in background^In game press \"Menu\" for secondary fire, \"Volume Up/Down\" to cycle weapons".replace("^","\n");
public static boolean AppUsesMouse = true;
public static boolean AppUsesMouse = false;
public static boolean AppNeedsArrowKeys = true;
@@ -29,9 +29,9 @@ class Globals {
public static boolean NonBlockingSwapBuffers = false;
public static int AppTouchscreenKeyboardKeysAmount = 6;
public static int AppTouchscreenKeyboardKeysAmount = 4;
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 0;
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
// Phone-specific config
// It will download app data to /sdcard/alienblaster if set to true,
@@ -50,5 +50,5 @@ class Globals {
}
class LoadLibrary {
public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_image"); };
public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); };
}

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package com.teeworlds;
package de.schwardtnet.alienblaster;
import javax.microedition.khronos.opengles.GL10;