Commit 1d7cfea7 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Merged with Kees Bakker's repo at https://bitbucket.org/keestux/sdl ...

parents eecf78dc b5692bd2
......@@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-4
target=android-5
package org.libsdl.app;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.egl.*;
......@@ -93,7 +95,8 @@ public class SDLActivity extends Activity {
public static native void onNativeResize(int x, int y, int format);
public static native void onNativeKeyDown(int keycode);
public static native void onNativeKeyUp(int keycode);
public static native void onNativeTouch(int action, float x,
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
int action, float x,
float y, float p);
public static native void onNativeAccel(float x, float y, float z);
public static native void nativeRunAudioThread();
......@@ -387,7 +390,13 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
}
EGLConfig config = configs[0];
EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, null);
int EGL_CONTEXT_CLIENT_VERSION=0x3098;
int contextAttrs[] = new int[]
{
EGL_CONTEXT_CLIENT_VERSION, majorVersion,
EGL10.EGL_NONE
};
EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, contextAttrs);
if (ctx == EGL10.EGL_NO_CONTEXT) {
Log.e("SDL", "Couldn't create context");
return false;
......@@ -423,7 +432,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
try {
EGL10 egl = (EGL10)EGLContext.getEGL();
egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
// drawing here
......@@ -459,16 +468,34 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
// Touch events
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
float x = event.getX();
float y = event.getY();
float p = event.getPressure();
// TODO: Anything else we need to pass?
SDLActivity.onNativeTouch(action, x, y, p);
return true;
}
{
final int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
// touchId, pointerId, action, x, y, pressure
int actionPointerIndex = event.getActionIndex();
int pointerFingerId = event.getPointerId(actionPointerIndex);
int action = event.getActionMasked();
float x = event.getX(actionPointerIndex);
float y = event.getY(actionPointerIndex);
float p = event.getPressure(actionPointerIndex);
if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) {
// TODO send motion to every pointer if its position has
// changed since prev event.
for (int i = 0; i < pointerCount; i++) {
pointerFingerId = event.getPointerId(i);
x = event.getX(i);
y = event.getY(i);
p = event.getPressure(i);
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
}
} else {
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
}
}
return true;
}
// Sensor events
public void enableSensor(int sensortype, boolean enabled) {
......
......@@ -939,6 +939,41 @@ CheckVisibilityHidden()
fi
}
dnl See if GCC's -Wall is supported.
CheckWarnAll()
{
AC_MSG_CHECKING(for GCC -Wall option)
have_gcc_Wall=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wall"
AC_TRY_COMPILE([
int x = 0;
],[
],[
have_gcc_Wall=yes
])
AC_MSG_RESULT($have_gcc_Wall)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_Wall = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
need_gcc_Wno_multichar=no
case "$host" in
*-*-beos* | *-*-haiku*)
need_gcc_Wno_multichar=yes
;;
esac
AC_MSG_RESULT($need_gcc_Wno_multichar)
if test x$need_gcc_Wno_multichar = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
fi
fi
}
dnl Find the X11 include and library directories
CheckX11()
......@@ -2356,6 +2391,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
;;
esac
dnl Do this on all platforms, after everything else.
CheckWarnAll
# Verify that we have all the platform specific files we need
if test x$have_joystick != xyes; then
......
......@@ -140,6 +140,9 @@
/* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 1
/* enable joystick subsystem */
#define SDL_JOYSTICK_DISABLED 0
/* Set max recognized G-force from accelerometer
See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
*/
......
......@@ -89,7 +89,6 @@ typedef struct SDL_RWops
void *fileNameRef;
void *inputStream;
void *inputStreamRef;
void *skipMethod;
void *readableByteChannel;
void *readableByteChannelRef;
void *readMethod;
......
......@@ -60,7 +60,8 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
#elif defined(__GNUC__) && defined(__arm__) && \
(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \
defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__))
defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \
defined(__ARM_ARCH_5TEJ__))
int result;
__asm__ __volatile__ (
"swp %0, %1, [%2]\n"
......@@ -81,7 +82,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory");
return (result == 0);
#elif defined(__MACOSX__)
#elif defined(__MACOSX__) || defined(__IPHONEOS__)
/* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ sub outputHeader {
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
/*
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
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
......@@ -536,7 +536,6 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
fprintf(stderr, "$resample (x${multiple}) AUDIO_${from}, ${channels} channels.\\n");
#endif
const int srcsize = cvt->len_cvt;
const int dstsize = cvt->len_cvt $lencvtop $multiple;
EOF
......
......@@ -29,6 +29,14 @@ extern "C" {
#include "../../video/android/SDL_androidtouch.h"
#include "../../video/android/SDL_androidvideo.h"
#include <android/log.h>
#define LOG_TAG "SDL_android"
//#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
//#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#define LOGI(...) do {} while (false)
#define LOGE(...) do {} while (false)
/* Impelemented in audio/android/SDL_androidaudio.c */
extern void Android_RunAudioThread();
} // C
......@@ -45,6 +53,7 @@ extern void Android_RunAudioThread();
*******************************************************************************/
static JNIEnv* mEnv = NULL;
static JNIEnv* mAudioEnv = NULL;
static JavaVM* mJavaVM;
// Main activity
static jclass mActivityClass;
......@@ -68,6 +77,14 @@ static float fLastAccelerometer[3];
// Library init
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
JNIEnv *env;
mJavaVM = vm;
LOGI("JNI_OnLoad called");
if (mJavaVM->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
LOGE("Failed to get the environment using GetEnv()");
return -1;
}
return JNI_VERSION_1_4;
}
......@@ -96,6 +113,7 @@ extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls)
!midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
}
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!");
}
// Resize
......@@ -123,9 +141,10 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
// Touch
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
JNIEnv* env, jclass jcls,
jint touch_device_id_in, jint pointer_finger_id_in,
jint action, jfloat x, jfloat y, jfloat p)
{
Android_OnTouch(action, x, y, p);
Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p);
}
// Accelerometer
......@@ -203,29 +222,48 @@ extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int chan
{
int audioBufferFrames;
int status;
JNIEnv *env;
static bool isAttached = false;
status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4);
if(status < 0) {
LOGE("callback_handler: failed to get JNI environment, assuming native thread");
status = mJavaVM->AttachCurrentThread(&env, NULL);
if(status < 0) {
LOGE("callback_handler: failed to attach current thread");
return 0;
}
isAttached = true;
}
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
audioBuffer16Bit = is16Bit;
audioBufferStereo = channelCount > 1;
audioBuffer = mEnv->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
audioBuffer = env->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
if (audioBuffer == NULL) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
return 0;
}
audioBuffer = mEnv->NewGlobalRef(audioBuffer);
audioBuffer = env->NewGlobalRef(audioBuffer);
jboolean isCopy = JNI_FALSE;
if (audioBuffer16Bit) {
audioBufferPinned = mEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer);
audioBufferPinned = env->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
audioBufferFrames = env->GetArrayLength((jshortArray)audioBuffer);
} else {
audioBufferPinned = mEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer);
audioBufferPinned = env->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer);
}
if (audioBufferStereo) {
audioBufferFrames /= 2;
}
if (isAttached) {
mJavaVM->DetachCurrentThread();
}
return audioBufferFrames;
}
......@@ -250,13 +288,31 @@ extern "C" void Android_JNI_WriteAudioBuffer()
extern "C" void Android_JNI_CloseAudioDevice()
{
mEnv->CallStaticVoidMethod(mActivityClass, midAudioQuit);
int status;
JNIEnv *env;
static bool isAttached = false;
status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4);
if(status < 0) {
LOGE("callback_handler: failed to get JNI environment, assuming native thread");
status = mJavaVM->AttachCurrentThread(&env, NULL);
if(status < 0) {
LOGE("callback_handler: failed to attach current thread");
return;
}
isAttached = true;
}
env->CallStaticVoidMethod(mActivityClass, midAudioQuit);
if (audioBuffer) {
mEnv->DeleteGlobalRef(audioBuffer);
env->DeleteGlobalRef(audioBuffer);
audioBuffer = NULL;
audioBufferPinned = NULL;
}
if (isAttached) {
mJavaVM->DetachCurrentThread();
}
}
// Test for an exception and call SDL_SetError with its detail if one occurs
......@@ -345,11 +401,6 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
ctx->hidden.androidio.inputStream = inputStream;
ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream);
// Store .skip id for seeking purposes
mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
"skip", "(J)J");
ctx->hidden.androidio.skipMethod = mid;
// Despite all the visible documentation on [Asset]InputStream claiming
// that the .available() method is not guaranteed to return the entire file
// size, comments in <sdk>/samples/<ver>/ApiDemos/src/com/example/ ...
......@@ -517,16 +568,24 @@ extern "C" long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence)
long movement = newPosition - ctx->hidden.androidio.position;
jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
jmethodID skipMethod = (jmethodID)ctx->hidden.androidio.skipMethod;
if (movement > 0) {
unsigned char buffer[1024];
// The easy case where we're seeking forwards
while (movement > 0) {
// inputStream.skip(...);
movement -= mEnv->CallLongMethod(inputStream, skipMethod, movement);
if (Android_JNI_ExceptionOccurred()) {
long amount = (long) sizeof (buffer);
if (amount > movement) {
amount = movement;
}
size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount);
if (result <= 0) {
// Failed to read/skip the required amount, so fail
return -1;
}
movement -= result;
}
} else if (movement < 0) {
// We can't seek backwards so we have to reopen the file and seek
......
......@@ -384,6 +384,8 @@ SDL_GetCPUType(void)
return SDL_CPUType;
}
#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */
static const char *
SDL_GetCPUName(void)
{
......@@ -455,6 +457,7 @@ SDL_GetCPUName(void)
}
return SDL_CPUName;
}
#endif
int
SDL_GetCPUCacheLineSize(void)
......
......@@ -390,10 +390,11 @@ int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) {
float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) {
SDL_FloatPoint points[DOLLARNPOINTS];
int numPoints = dollarNormalize(path,points);
int i;
float bestDiff = 10000;
dollarNormalize(path,points);
//PrintPath(points);
*bestTempl = -1;
for(i = 0;i < touch->numDollarTemplates;i++) {
......
......@@ -349,7 +349,6 @@ SDL_Cursor *
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
int w, int h, int hot_x, int hot_y)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Surface *surface;
SDL_Cursor *cursor;
int x, y;
......
......@@ -128,7 +128,6 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery,
char *val = NULL;
SDL_bool charge = SDL_FALSE;
SDL_bool choose = SDL_FALSE;
SDL_bool is_ac = SDL_FALSE;
int maximum = -1;
int remaining = -1;
int secs = -1;
......@@ -214,13 +213,6 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac)
char *ptr = NULL;
char *key = NULL;
char *val = NULL;
SDL_bool charge = SDL_FALSE;
SDL_bool choose = SDL_FALSE;
SDL_bool is_ac = SDL_FALSE;
int maximum = -1;
int remaining = -1;
int secs = -1;
int pct = -1;
if (!load_acpi_file(base, node, "state", state, sizeof (state))) {
return;
......
......@@ -348,8 +348,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
static void
GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
{
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
/* Rebind the context to the window area and update matrices */
SDL_CurrentContext = NULL;
......
......@@ -124,7 +124,6 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
......@@ -216,7 +215,6 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
......@@ -492,7 +490,6 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
......@@ -584,7 +581,6 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
unsigned r, g, b, a, inva;
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
......
......@@ -45,13 +45,13 @@
#define DRAW_SETPIXEL(setpixel) \
do { \
unsigned sr = r, sg = g, sb = b, sa = a; \
unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
setpixel; \
} while (0)
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
do { \
unsigned sr, sg, sb, sa; sa; \
unsigned sr, sg, sb, sa; (void) sa; \
getpixel; \
sr = DRAW_MUL(inva, sr) + r; \
sg = DRAW_MUL(inva, sg) + g; \
......@@ -61,7 +61,7 @@ do { \
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
do { \
unsigned sr, sg, sb, sa; sa; \
unsigned sr, sg, sb, sa; (void) sa; \
getpixel; \
sr += r; if (sr > 0xff) sr = 0xff; \
sg += g; if (sg > 0xff) sg = 0xff; \
......@@ -71,7 +71,7 @@ do { \
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
do { \
unsigned sr, sg, sb, sa; sa; \
unsigned sr, sg, sb, sa; (void) sa; \
getpixel; \
sr = DRAW_MUL(sr, r); \
sg = DRAW_MUL(sg, g); \
......
......@@ -66,8 +66,9 @@ int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
/* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */
const char *threadname = thread->name ? thread->name : "SDL Thread";
char name[B_OS_NAME_LENGTH];
SDL_snprintf(name, sizeof (name), "%s", thread->name);
SDL_snprintf(name, sizeof (name), "%s", threadname);
name[sizeof (name) - 1] = '\0';
/* Create the thread and go! */
......
......@@ -23,6 +23,7 @@
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/time.h>
#include "SDL_thread.h"
#include "SDL_timer.h"
......
......@@ -18,6 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include <pthread.h>
......@@ -31,6 +32,8 @@
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <unistd.h>
extern int pthread_setname_np (pthread_t __target_thread, __const char *__name) __THROW __nonnull ((2));
#endif
#include "SDL_platform.h"
......@@ -79,14 +82,16 @@ SDL_SYS_SetupThread(const char *name)
int i;
sigset_t mask;
if (name != NULL) {
#if ( (__MACOSX__ && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \
(__IPHONEOS__ && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 30200)) )
if (pthread_setname_np != NULL) { pthread_setname_np(name); }
if (pthread_setname_np != NULL) { pthread_setname_np(name); }
#elif HAVE_PTHREAD_SETNAME_NP
pthread_setname_np(pthread_self(), name);
pthread_setname_np(pthread_self(), name);
#elif HAVE_PTHREAD_SET_NAME_NP
pthread_set_name_np(pthread_self(), name);
pthread_set_name_np(pthread_self(), name);
#endif
}
/* Mask asynchronous signals for this thread */
sigemptyset(&mask);
......
......@@ -161,25 +161,27 @@ typedef struct tagTHREADNAME_INFO
void
SDL_SYS_SetupThread(const char *name)
{
#if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */
#ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */
/* This magic tells the debugger to name a thread if it's listening. */
THREADNAME_INFO inf;
inf.dwType = 0x1000;
inf.szName = name;
inf.dwThreadID = (DWORD) -1;
inf.dwFlags = 0;
__try
{
RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf);
if (name != NULL) {
#if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */
#ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */
/* This magic tells the debugger to name a thread if it's listening. */
THREADNAME_INFO inf;
inf.dwType = 0x1000;
inf.szName = name;
inf.dwThreadID = (DWORD) -1;
inf.dwFlags = 0;
__try
{
RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf);
}
__except(EXCEPTION_CONTINUE_EXECUTION)
{
/* The program itself should ignore this bogus exception. */
}
#endif
#endif
}
__except(EXCEPTION_CONTINUE_EXECUTION)
{
/* The program itself should ignore this bogus exception. */
}
#endif
#endif
}
SDL_threadID
......
......@@ -29,26 +29,43 @@
#include <android/log.h>
#include <dlfcn.h>
static void* Android_GLHandle = NULL;
/* GL functions */
int
Android_GL_LoadLibrary(_THIS, const char *path)
{
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_LoadLibrary\n");
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)
{
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetProcAddress\n");
return 0;
/*
!!! 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)
{
__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n");
if(Android_GLHandle) {
dlclose(Android_GLHandle);
Android_GLHandle = NULL;
}
}
SDL_GLContext
......
......@@ -24,6 +24,7 @@
#include "SDL_events.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
#include "SDL_androidtouch.h"
......@@ -33,27 +34,55 @@
#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 action, float x, float y, float p)
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__);
}
}
if ((action != ACTION_CANCEL) && (action != ACTION_OUTSIDE)) {
SDL_SetMouseFocus(Android_Window);
SDL_SendMouseMotion(Android_Window, 0, (int)x, (int)y);
switch(action) {
fingerId = (SDL_FingerID)pointer_finger_id_in;
switch (action) {
case ACTION_DOWN:
SDL_SendMouseButton(Android_Window, SDL_PRESSED, SDL_BUTTON_LEFT);
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:
SDL_SendMouseButton(Android_Window, SDL_RELEASED, SDL_BUTTON_LEFT);
case ACTION_POINTER_1_UP:
SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
break;
}
} else {
SDL_SetMouseFocus(NULL);
}
default:
break;
}
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -22,6 +22,6 @@
#include "SDL_androidvideo.h"
extern void Android_OnTouch(int action, float x, float y, float p);
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: */
......@@ -176,7 +176,8 @@ UIKit_AddDisplay(UIScreen *uiscreen, UIScreenMode *uimode, int w, int h)
mode.h = h;
mode.refresh_rate = 0;
[uimode retain];
[uimode retain]; // once for the desktop_mode
[uimode retain]; // once for the current_mode
mode.driverdata = uimode;
SDL_zero(display);
......@@ -248,13 +249,14 @@ UIKit_VideoQuit(_THIS)
UIScreen *uiscreen = (UIScreen *) display->driverdata;
[uiscreen release];
display->driverdata = NULL;
[((UIScreenMode *) display->desktop_mode.driverdata) release];
display->desktop_mode.driverdata = NULL;
[((UIScreenMode *) display->current_mode.driverdata) release];
display->current_mode.driverdata = NULL;
for (j = 0; j < display->num_display_modes; j++) {
SDL_DisplayMode *mode = &display->display_modes[j];
UIScreenMode *uimode = (UIScreenMode *) mode->driverdata;
if (uimode) {
[uimode release];
mode->driverdata = NULL;
}
[((UIScreenMode *) mode->driverdata) release];
mode->driverdata = NULL;
}
}
}
......
......@@ -151,8 +151,13 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
if (bestmode) {
UIScreenMode *uimode = (UIScreenMode *) bestmode->driverdata;
[uiscreen setCurrentMode:uimode];
display->desktop_mode = *bestmode;
// desktop_mode doesn't change here (the higher level will
// use it to set all the screens back to their defaults
// upon window destruction, SDL_Quit(), etc.
[((UIScreenMode *) display->current_mode.driverdata) release];
display->current_mode = *bestmode;
[((UIScreenMode *) display->current_mode.driverdata) retain];
}
}
}
......
......@@ -88,6 +88,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
data->mouse_pressed = SDL_FALSE;
data->videodata = videodata;
window->driverdata = data;
/* Associate the data with the window */
if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
ReleaseDC(hwnd, data->hdc);
......@@ -183,7 +185,6 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
}
/* All done! */
window->driverdata = data;
return 0;
}
......
......@@ -234,7 +234,6 @@ X11_DispatchEvent(_THIS)
case KeyPress:{
KeyCode keycode = xevent.xkey.keycode;
KeySym keysym = NoSymbol;
SDL_Scancode scancode;
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
Status status = 0;
......@@ -243,7 +242,7 @@ X11_DispatchEvent(_THIS)
#endif
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
#if 1
if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) {
int min_keycode, max_keycode;
XDisplayKeycodes(display, &min_keycode, &max_keycode);
keysym = XKeycodeToKeysym(display, keycode, 0);
......@@ -522,6 +521,11 @@ X11_Pending(Display * display)
return (0);
}
/* !!! FIXME: this should be exposed in a header, or something. */
int SDL_GetNumTouch(void);
void
X11_PumpEvents(_THIS)
{
......@@ -545,7 +549,6 @@ X11_PumpEvents(_THIS)
#ifdef SDL_INPUT_LINUXEV
/* Process Touch events - TODO When X gets touch support, use that instead*/
int i = 0,rd;
char name[256];
struct input_event ev[64];
int size = sizeof (struct input_event);
......
......@@ -183,7 +183,10 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects,
rect->x, rect->y, rect->w, rect->h);
}
}
XSync(display, False);
return 0;
}
void
......
......@@ -136,7 +136,7 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
/* Code below assumes ARGB pixel format */
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
rfg = gfg = bfg = rbg = gbg = bbg = fgBits = 0;
rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0;
for (y = 0; y < surface->h; ++y) {
ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch);
for (x = 0; x < surface->w; ++x) {
......
......@@ -19,8 +19,8 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
#include "SDL_assert.h"
/* GLX implementation of SDL OpenGL support */
......@@ -388,8 +388,10 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
XVisualInfo *vinfo;
/* 64 seems nice. */
int attribs[64];
int i = X11_GL_GetAttributes(_this,display,screen,attribs,64);
const int max_attrs = 64;
int attribs[max_attrs];
const int i = X11_GL_GetAttributes(_this,display,screen,attribs,max_attrs);
SDL_assert(i <= max_attrs);
vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
if (!vinfo) {
......
......@@ -26,6 +26,7 @@
#include "SDL_x11video.h"
#include "SDL_x11shape.h"
#include "SDL_x11window.h"
#include "../SDL_shape_internals.h"
SDL_Window*
X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
......
......@@ -178,17 +178,17 @@ SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return)
/* XCursor support */
#if SDL_VIDEO_DRIVER_X11_XCURSOR
SDL_X11_MODULE(XCURSOR)
SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),)
SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return)
SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),)
SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),)
SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return)
#endif
/* Xinerama support */
#if SDL_VIDEO_DRIVER_X11_XINERAMA
SDL_X11_MODULE(XINERAMA)
SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),)
SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),)
SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),)
SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),return)
SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),return)
#endif
/* XInput support for multiple mice, tablets, etc. */
......@@ -229,12 +229,12 @@ SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
SDL_X11_MODULE(XVIDMODE)
SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),)
SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),)
SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),)
SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),)
SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),)
SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),)
SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),return)
SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),return)
SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),return)
SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),return)
SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),return)
#endif
/* *INDENT-ON* */
......
......@@ -39,7 +39,6 @@ X11_InitTouch(_THIS)
FILE *fd;
fd = fopen("/proc/bus/input/devices","r");
char c;
int i = 0;
int tsfd;
char line[256];
......@@ -111,7 +110,7 @@ X11_InitTouch(_THIS)
}
}
close(fd);
fclose(fd);
#endif
}
......
......@@ -86,31 +86,6 @@ X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3])
return count;
}
static void
X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *displaydata =
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
XWindowAttributes attr;
XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr);
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* The bounds when this window is visible is the fullscreen mode */
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
attr.width = fullscreen_mode.w;
attr.height = fullscreen_mode.h;
}
}
if (w) {
*w = attr.width;
}
if (h) {
*h = attr.height;
}
}
static int
SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
{
......@@ -320,7 +295,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
xattr.border_pixel = 0;
if (visual->class == DirectColor) {
Status status;
XColor *colorcells;
int i;
int ncolors;
......@@ -757,7 +731,6 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;
int x, y;
XMoveWindow(display, data->xwindow, window->x, window->y);
XFlush(display);
......@@ -952,7 +925,7 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
int ncolors;
int rmask, gmask, bmask;
int rshift, gshift, bshift;
int i, j;
int i;
if (visual->class != DirectColor) {
SDL_SetError("Window doesn't have DirectColor visual");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment