Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merged with Kees Bakker's repo at https://bitbucket.org/keestux/sdl ...
  • Loading branch information
icculus committed Oct 18, 2011
2 parents 54c49f0 + 88852ca commit ee1323a
Show file tree
Hide file tree
Showing 34 changed files with 310 additions and 351 deletions.
2 changes: 1 addition & 1 deletion android-project/default.properties
Expand Up @@ -8,4 +8,4 @@
# project structure.

# Project target.
target=android-4
target=android-5
53 changes: 40 additions & 13 deletions android-project/src/org/libsdl/app/SDLActivity.java
@@ -1,6 +1,8 @@
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.*;

Expand Down Expand Up @@ -93,7 +95,8 @@ void sendCommand(int command, Object data) {
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();
Expand Down Expand Up @@ -387,7 +390,13 @@ public boolean initEGL(int majorVersion, int minorVersion) {
}
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;
Expand Down Expand Up @@ -423,7 +432,7 @@ public void flipEGL() {
try {
EGL10 egl = (EGL10)EGLContext.getEGL();

egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);

// drawing here

Expand Down Expand Up @@ -459,16 +468,34 @@ else if (event.getAction() == KeyEvent.ACTION_UP) {

// 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) {
Expand Down
38 changes: 38 additions & 0 deletions configure.in
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions include/SDL_config_iphoneos.h
Expand Up @@ -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
*/
Expand Down
1 change: 0 additions & 1 deletion include/SDL_rwops.h
Expand Up @@ -89,7 +89,6 @@ typedef struct SDL_RWops
void *fileNameRef;
void *inputStream;
void *inputStreamRef;
void *skipMethod;
void *readableByteChannel;
void *readableByteChannelRef;
void *readMethod;
Expand Down
5 changes: 3 additions & 2 deletions src/atomic/SDL_spinlock.c
Expand Up @@ -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"
Expand All @@ -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);

Expand Down

0 comments on commit ee1323a

Please sign in to comment.