Fixed accelerometer reverting X and Y coordinates
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
CHANGE_APP_SETTINGS_VERSION=11
|
CHANGE_APP_SETTINGS_VERSION=12
|
||||||
AUTO=
|
AUTO=
|
||||||
|
|
||||||
if [ "X$1" = "X-a" ]; then
|
if [ "X$1" = "X-a" ]; then
|
||||||
@@ -46,7 +46,7 @@ fi
|
|||||||
echo -n "\nSpecify path to download application data in zip archive in the form 'Description|URL|MirrorURL|...'"
|
echo -n "\nSpecify path to download application data in zip archive in the form 'Description|URL|MirrorURL|...'"
|
||||||
echo -n "\nYou may specify additional paths to optional game content delimited by newlines (empty line to finish)"
|
echo -n "\nYou may specify additional paths to optional game content delimited by newlines (empty line to finish)"
|
||||||
echo -n "\nIf the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as-is to game dir and not unzipped"
|
echo -n "\nIf the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as-is to game dir and not unzipped"
|
||||||
echo -n "\nIf the URL does not contain 'http://' it is treated as file in 'project/assets' dir, which is bundled in .apk file\n\n"
|
echo -n "\nIf the URL does not contain 'http://' it is treated as file in 'project/jni/application/src/AndroidData' dir\n\n"
|
||||||
echo -n "`echo $AppDataDownloadUrl | tr '^' '\\n'`"
|
echo -n "`echo $AppDataDownloadUrl | tr '^' '\\n'`"
|
||||||
echo
|
echo
|
||||||
AppDataDownloadUrl1=""
|
AppDataDownloadUrl1=""
|
||||||
@@ -103,6 +103,12 @@ if [ -n "$var" ] ; then
|
|||||||
AppUsesJoystick="$var"
|
AppUsesJoystick="$var"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -n "\nApplication will handle joystick center and sensitivity itself, \nSDL will send raw accelerometer data and won't show 'Accelerometer sensitivity' dialog (y) or (n) ($AppHandlesJoystickSensitivity): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
AppHandlesJoystickSensitivity="$var"
|
||||||
|
fi
|
||||||
|
|
||||||
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): "
|
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
|
read var
|
||||||
if [ -n "$var" ] ; then
|
if [ -n "$var" ] ; then
|
||||||
@@ -117,7 +123,7 @@ if [ -n "$var" ] ; then
|
|||||||
NonBlockingSwapBuffers="$var"
|
NonBlockingSwapBuffers="$var"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "\nPrevent device from going to suspend mode while application is running (y/n) ($InhibitSuspend): "
|
echo -n "\nPrevent device from going to sleep while application is running (y) or (n) - this setting is\napplied automatically if you're using accelerometer, but may be useful for video players etc ($InhibitSuspend): "
|
||||||
read var
|
read var
|
||||||
if [ -n "$var" ] ; then
|
if [ -n "$var" ] ; then
|
||||||
InhibitSuspend="$var"
|
InhibitSuspend="$var"
|
||||||
@@ -239,6 +245,7 @@ echo NeedDepthBuffer=$NeedDepthBuffer >> AndroidAppSettings.cfg
|
|||||||
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
||||||
echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg
|
echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg
|
||||||
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
|
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
|
||||||
|
echo AppHandlesJoystickSensitivity=$AppHandlesJoystickSensitivity >> AndroidAppSettings.cfg
|
||||||
echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg
|
echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg
|
||||||
echo NonBlockingSwapBuffers=$NonBlockingSwapBuffers >> AndroidAppSettings.cfg
|
echo NonBlockingSwapBuffers=$NonBlockingSwapBuffers >> AndroidAppSettings.cfg
|
||||||
echo RedefinedKeys=\"$RedefinedKeys\" >> AndroidAppSettings.cfg
|
echo RedefinedKeys=\"$RedefinedKeys\" >> AndroidAppSettings.cfg
|
||||||
@@ -315,6 +322,12 @@ else
|
|||||||
AppUsesJoystick=false
|
AppUsesJoystick=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$AppHandlesJoystickSensitivity" = "y" ] ; then
|
||||||
|
AppHandlesJoystickSensitivity=true
|
||||||
|
else
|
||||||
|
AppHandlesJoystickSensitivity=false
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$AppUsesMultitouch" = "y" ] ; then
|
if [ "$AppUsesMultitouch" = "y" ] ; then
|
||||||
AppUsesMultitouch=true
|
AppUsesMultitouch=true
|
||||||
else
|
else
|
||||||
@@ -385,6 +398,7 @@ cat project/src/Globals.java | \
|
|||||||
sed "s/public static boolean AppUsesMouse = .*;/public static boolean AppUsesMouse = $AppUsesMouse;/" | \
|
sed "s/public static boolean AppUsesMouse = .*;/public static boolean AppUsesMouse = $AppUsesMouse;/" | \
|
||||||
sed "s/public static boolean AppNeedsArrowKeys = .*;/public static boolean AppNeedsArrowKeys = $AppNeedsArrowKeys;/" | \
|
sed "s/public static boolean AppNeedsArrowKeys = .*;/public static boolean AppNeedsArrowKeys = $AppNeedsArrowKeys;/" | \
|
||||||
sed "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" | \
|
sed "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" | \
|
||||||
|
sed "s/public static boolean AppHandlesJoystickSensitivity = .*;/public static boolean AppHandlesJoystickSensitivity = $AppHandlesJoystickSensitivity;/" | \
|
||||||
sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \
|
sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \
|
||||||
sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \
|
sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \
|
||||||
sed "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" | \
|
sed "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" | \
|
||||||
@@ -449,4 +463,10 @@ for LIB in freetype intl jpeg png lua mad stlport tremor xerces xml2; do
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm -f project/assets/*
|
||||||
|
if [ -d "project/jni/application/src/AndroidData" ] ; then
|
||||||
|
echo Copying asset files
|
||||||
|
cp project/jni/application/src/AndroidData/* project/assets/
|
||||||
|
fi
|
||||||
|
|
||||||
echo Done
|
echo Done
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ void updateOrientation ( float accX, float accY, float accZ )
|
|||||||
if( SDL_ANDROID_isJoystickUsed && SDL_ANDROID_CurrentJoysticks[0] ) // TODO: mutex for that stuff?
|
if( SDL_ANDROID_isJoystickUsed && SDL_ANDROID_CurrentJoysticks[0] ) // TODO: mutex for that stuff?
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): sending joystick event");
|
__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): sending joystick event");
|
||||||
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accX - midX) * joystickSensitivity))));
|
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accX - midX) * joystickSensitivity))));
|
||||||
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accY - midY) * joystickSensitivity))));
|
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accY - midY) * joystickSensitivity))));
|
||||||
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accZ - midZ) * joystickSensitivity))));
|
SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accZ - midZ) * joystickSensitivity))));
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||||
package org.enigmagame.enigma;
|
package de.schwardtnet.alienblaster;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -48,10 +48,7 @@ class AccelerometerReader implements SensorEventListener {
|
|||||||
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
|
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
|
||||||
{
|
{
|
||||||
if( Globals.HorizontalOrientation )
|
if( Globals.HorizontalOrientation )
|
||||||
// TODO: it feels better for me to use tilt as X value instead of intuitive horizontal phone orientation
|
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||||
// because then I can hold device comfortably, we need another user-configurable option for that
|
|
||||||
// nativeOrientation(event.values[1], -event.values[2], event.values[0]); // Comfortable setting
|
|
||||||
nativeAccelerometer(-event.values[1], -event.values[0], event.values[2]); // Intuitive setting
|
|
||||||
else
|
else
|
||||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user