Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android
Conflicts: project/jni/application/vcmi/AndroidAppSettings.cfg project/jni/application/vcmi/Makefile
26
bugs.txt
@@ -1,5 +1,5 @@
|
|||||||
Known bugs
|
Known bugs (see also todo.txt)
|
||||||
==========
|
==============================
|
||||||
|
|
||||||
- With 4:3 screen aspect ratio the on-screen buttons are not shown on the inactive part of screen.
|
- With 4:3 screen aspect ratio the on-screen buttons are not shown on the inactive part of screen.
|
||||||
|
|
||||||
@@ -14,25 +14,3 @@ Known bugs
|
|||||||
- 32-bpp color mode does not work with SW video surface, 24-bpp and 32-bpp mode does not work with SDL_HWSURFACE.
|
- 32-bpp color mode does not work with SW video surface, 24-bpp and 32-bpp mode does not work with SDL_HWSURFACE.
|
||||||
|
|
||||||
- Option SdlVideoResizeKeepAspect has no effect
|
- Option SdlVideoResizeKeepAspect has no effect
|
||||||
|
|
||||||
Requested features
|
|
||||||
==================
|
|
||||||
|
|
||||||
- Perform a check for free space available on SD card before writing there, and write to the internal storage if SD card is unplugged.
|
|
||||||
|
|
||||||
- Split Settings.java into several files
|
|
||||||
|
|
||||||
- Show/hide screen controls with longpress on Text Edit button.
|
|
||||||
|
|
||||||
- Support of libjnigraphics (it will disable on-screen keyboard, only SW SDL screen surface supported)
|
|
||||||
|
|
||||||
- Floating on-screen joystick - initially invisible, it appears when you touch the screen,
|
|
||||||
centered on your finger, then it slides with your finger if you bump the joystick edge.
|
|
||||||
|
|
||||||
- Export phone vibrator to SDL - interface is available in SDL 1.3
|
|
||||||
|
|
||||||
- Control screen brightness with SDL_SetGamma()
|
|
||||||
|
|
||||||
- Zoom in-out whole screen in SW mode with some SDL key -
|
|
||||||
much like the "On-screen magnifying glass" feature (lazy porter's golden hammer)
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,17 @@ if [ -n "$var" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo "Touchscreen keyboard will save and restore OpenGL state before drawing itself -"
|
||||||
|
echo -n "this works reliably only on Android 4.X devices, many Andorid 2.X devices do not support glGet() (y)/(n) ($CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SdlVideoResize" -o -z "$AUTO" ]; then
|
if [ -z "$SdlVideoResize" -o -z "$AUTO" ]; then
|
||||||
@@ -295,6 +306,17 @@ if [ -n "$var" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CompatibilityHacksSlowCompatibleEventQueue" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo "Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -"
|
||||||
|
echo -n "do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) ($CompatibilityHacksSlowCompatibleEventQueue): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
CompatibilityHacksSlowCompatibleEventQueue="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$AppUsesJoystick" -o -z "$AUTO" ]; then
|
if [ -z "$AppUsesJoystick" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Application uses joystick (y) or (n), the on-screen DPAD will be used"
|
echo "Application uses joystick (y) or (n), the on-screen DPAD will be used"
|
||||||
@@ -308,7 +330,7 @@ fi
|
|||||||
|
|
||||||
if [ -z "$AppUsesAccelerometer" -o -z "$AUTO" ]; then
|
if [ -z "$AppUsesAccelerometer" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 0 axes 2-3 ($AppUsesAccelerometer): "
|
echo -n "Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 ($AppUsesAccelerometer): "
|
||||||
read var
|
read var
|
||||||
if [ -n "$var" ] ; then
|
if [ -n "$var" ] ; then
|
||||||
AppUsesAccelerometer="$var"
|
AppUsesAccelerometer="$var"
|
||||||
@@ -316,6 +338,16 @@ if [ -n "$var" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$AppUsesGyroscope" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo -n "Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 ($AppUsesGyroscope): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
AppUsesGyroscope="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$AppUsesMultitouch" -o -z "$AUTO" ]; then
|
if [ -z "$AppUsesMultitouch" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBUTTONDOWN/SDL_JOYBALLMOTION events"
|
echo "Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBUTTONDOWN/SDL_JOYBALLMOTION events"
|
||||||
@@ -425,7 +457,7 @@ if [ -n "$var" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FirstStartMenuOptionsDefault='(AppUsesMouse \&\& \! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true)'
|
FirstStartMenuOptionsDefault='(AppUsesMouse \&\& \! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true), new Settings.GyroscopeCalibration()'
|
||||||
if [ -z "$AUTO" ]; then
|
if [ -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Menu items to show at startup - this is Java code snippet, leave empty for default"
|
echo "Menu items to show at startup - this is Java code snippet, leave empty for default"
|
||||||
@@ -663,6 +695,8 @@ echo CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputE
|
|||||||
echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg
|
echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg
|
||||||
echo CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize >> AndroidAppSettings.cfg
|
echo CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize >> AndroidAppSettings.cfg
|
||||||
echo CompatibilityHacksAdditionalPreloadedSharedLibraries=\"$CompatibilityHacksAdditionalPreloadedSharedLibraries\" >> AndroidAppSettings.cfg
|
echo CompatibilityHacksAdditionalPreloadedSharedLibraries=\"$CompatibilityHacksAdditionalPreloadedSharedLibraries\" >> AndroidAppSettings.cfg
|
||||||
|
echo CompatibilityHacksSlowCompatibleEventQueue=$CompatibilityHacksSlowCompatibleEventQueue >> AndroidAppSettings.cfg
|
||||||
|
echo CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState >> AndroidAppSettings.cfg
|
||||||
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
||||||
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
||||||
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
|
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
|
||||||
@@ -671,6 +705,7 @@ echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg
|
|||||||
echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg
|
echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg
|
||||||
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
|
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
|
||||||
echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg
|
echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg
|
||||||
|
echo AppUsesGyroscope=$AppUsesGyroscope >> 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
|
||||||
@@ -690,7 +725,9 @@ echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
|
|||||||
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
|
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
|
||||||
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
|
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
|
||||||
echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
|
echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
|
||||||
|
echo AppOverlapsSystemHeaders=$AppOverlapsSystemHeaders >> AndroidAppSettings.cfg
|
||||||
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
|
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
|
||||||
|
echo AppBuildExclude=\'$AppBuildExclude\' >> AndroidAppSettings.cfg
|
||||||
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
|
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
|
||||||
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
|
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
|
||||||
echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
|
echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
|
||||||
@@ -725,9 +762,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SdlVideoResizeKeepAspect" = "y" ] ; then
|
if [ "$SdlVideoResizeKeepAspect" = "y" ] ; then
|
||||||
SdlVideoResizeKeepAspect=1
|
SdlVideoResizeKeepAspect=true
|
||||||
else
|
else
|
||||||
SdlVideoResizeKeepAspect=0
|
SdlVideoResizeKeepAspect=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$InhibitSuspend" = "y" ] ; then
|
if [ "$InhibitSuspend" = "y" ] ; then
|
||||||
@@ -790,6 +827,18 @@ else
|
|||||||
CompatibilityHacksAppIgnoresAudioBufferSize=
|
CompatibilityHacksAppIgnoresAudioBufferSize=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$CompatibilityHacksSlowCompatibleEventQueue" = "y" ]; then
|
||||||
|
CompatibilityHacksSlowCompatibleEventQueue=-DSDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE=1
|
||||||
|
else
|
||||||
|
CompatibilityHacksSlowCompatibleEventQueue=
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState" = "y" ]; then
|
||||||
|
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=-DSDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE=1
|
||||||
|
else
|
||||||
|
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$AppUsesMouse" = "y" ] ; then
|
if [ "$AppUsesMouse" = "y" ] ; then
|
||||||
AppUsesMouse=true
|
AppUsesMouse=true
|
||||||
else
|
else
|
||||||
@@ -838,6 +887,12 @@ else
|
|||||||
AppUsesAccelerometer=false
|
AppUsesAccelerometer=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$AppUsesGyroscope" = "y" ] ; then
|
||||||
|
AppUsesGyroscope=true
|
||||||
|
else
|
||||||
|
AppUsesGyroscope=false
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$AppUsesMultitouch" = "y" ] ; then
|
if [ "$AppUsesMultitouch" = "y" ] ; then
|
||||||
AppUsesMultitouch=true
|
AppUsesMultitouch=true
|
||||||
else
|
else
|
||||||
@@ -910,8 +965,8 @@ mkdir -p project/src
|
|||||||
cd project/java
|
cd project/java
|
||||||
for F in *.java; do
|
for F in *.java; do
|
||||||
echo Patching $F
|
echo Patching $F
|
||||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, edit file under project/java dir' > ../src/$F
|
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under project/java dir' > ../src/$F
|
||||||
cat $F | sed "s/package .*;/package $AppFullName;/" >> ../src/$F
|
cat $F | sed "s/package .*;/package $AppFullName;/" >> ../src/$F # | sed 's@$@ // THIS FILE IS AUTO-GENERATED@' >>
|
||||||
done
|
done
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
@@ -961,6 +1016,7 @@ cat project/src/Globals.java | \
|
|||||||
sed "s/public static boolean CompatibilityHacksStaticInit = .*;/public static boolean CompatibilityHacksStaticInit = $CompatibilityHacksStaticInit;/" | \
|
sed "s/public static boolean CompatibilityHacksStaticInit = .*;/public static boolean CompatibilityHacksStaticInit = $CompatibilityHacksStaticInit;/" | \
|
||||||
sed "s/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = .*;/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = $CompatibilityHacksTextInputEmulatesHwKeyboard;/" | \
|
sed "s/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = .*;/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = $CompatibilityHacksTextInputEmulatesHwKeyboard;/" | \
|
||||||
sed "s/public static boolean HorizontalOrientation = .*;/public static boolean HorizontalOrientation = $HorizontalOrientation;/" | \
|
sed "s/public static boolean HorizontalOrientation = .*;/public static boolean HorizontalOrientation = $HorizontalOrientation;/" | \
|
||||||
|
sed "s^public static boolean KeepAspectRatioDefaultSetting = .*^public static boolean KeepAspectRatioDefaultSetting = $SdlVideoResizeKeepAspect;^" | \
|
||||||
sed "s/public static boolean InhibitSuspend = .*;/public static boolean InhibitSuspend = $InhibitSuspend;/" | \
|
sed "s/public static boolean InhibitSuspend = .*;/public static boolean InhibitSuspend = $InhibitSuspend;/" | \
|
||||||
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 AppNeedsTwoButtonMouse = .*;/public static boolean AppNeedsTwoButtonMouse = $AppNeedsTwoButtonMouse;/" | \
|
sed "s/public static boolean AppNeedsTwoButtonMouse = .*;/public static boolean AppNeedsTwoButtonMouse = $AppNeedsTwoButtonMouse;/" | \
|
||||||
@@ -970,6 +1026,7 @@ cat project/src/Globals.java | \
|
|||||||
sed "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" | \
|
sed "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" | \
|
||||||
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 AppUsesAccelerometer = .*;/public static boolean AppUsesAccelerometer = $AppUsesAccelerometer;/" | \
|
sed "s/public static boolean AppUsesAccelerometer = .*;/public static boolean AppUsesAccelerometer = $AppUsesAccelerometer;/" | \
|
||||||
|
sed "s/public static boolean AppUsesGyroscope = .*;/public static boolean AppUsesGyroscope = $AppUsesGyroscope;/" | \
|
||||||
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 boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \
|
sed "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \
|
||||||
@@ -997,12 +1054,13 @@ cat project/jni/SettingsTemplate.mk | \
|
|||||||
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
|
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
|
||||||
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
|
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
|
||||||
sed "s^SDL_VIDEO_RENDER_RESIZE := .*^SDL_VIDEO_RENDER_RESIZE := $SdlVideoResize^" | \
|
sed "s^SDL_VIDEO_RENDER_RESIZE := .*^SDL_VIDEO_RENDER_RESIZE := $SdlVideoResize^" | \
|
||||||
sed "s^SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := .*^SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := $SdlVideoResizeKeepAspect^" | \
|
|
||||||
sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" | \
|
sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" | \
|
||||||
sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
|
sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
|
||||||
sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \
|
sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \
|
||||||
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $CompatibilityHacksPreventAudioChopping $CompatibilityHacksAppIgnoresAudioBufferSize^" | \
|
sed "s^APPLICATION_OVERLAPS_SYSTEM_HEADERS :=.*^APPLICATION_OVERLAPS_SYSTEM_HEADERS := $AppOverlapsSystemHeaders^" | \
|
||||||
|
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $CompatibilityHacksPreventAudioChopping $CompatibilityHacksAppIgnoresAudioBufferSize $CompatibilityHacksSlowCompatibleEventQueue $CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState^" | \
|
||||||
sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \
|
sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \
|
||||||
|
sed "s^APPLICATION_BUILD_EXCLUDE :=.*^APPLICATION_BUILD_EXCLUDE := $AppBuildExclude^" | \
|
||||||
sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \
|
sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \
|
||||||
sed "s^SDL_VERSION :=.*^SDL_VERSION := $LibSdlVersion^" >> \
|
sed "s^SDL_VERSION :=.*^SDL_VERSION := $LibSdlVersion^" >> \
|
||||||
project/jni/Settings.mk
|
project/jni/Settings.mk
|
||||||
@@ -1040,6 +1098,12 @@ done
|
|||||||
rm -rf project/bin/classes
|
rm -rf project/bin/classes
|
||||||
rm -rf project/bin/res
|
rm -rf project/bin/res
|
||||||
|
|
||||||
|
if which convert > /dev/null; then
|
||||||
|
convert project/res/drawable/ouya_icon.png -resize '732x412!' project/res/drawable-xhdpi/ouya_icon.png
|
||||||
|
else
|
||||||
|
echo "Install ImageMagick to auto-resize Ouya icon from icon.png"
|
||||||
|
fi
|
||||||
|
|
||||||
./copyAssets.sh || exit 1
|
./copyAssets.sh || exit 1
|
||||||
|
|
||||||
echo Done
|
echo Done
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="tv.ouya.intent.category.GAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
<!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||||
|
|||||||
@@ -41,57 +41,89 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
{
|
{
|
||||||
|
|
||||||
private SensorManager _manager = null;
|
private SensorManager _manager = null;
|
||||||
|
public boolean openedBySDL = false;
|
||||||
|
public static final GyroscopeListener gyro = new GyroscopeListener();
|
||||||
|
|
||||||
public AccelerometerReader(Activity context)
|
public AccelerometerReader(Activity context)
|
||||||
{
|
{
|
||||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stop()
|
public synchronized void stop()
|
||||||
{
|
{
|
||||||
if( _manager != null )
|
if( _manager != null )
|
||||||
{
|
{
|
||||||
|
System.out.println("libSDL: stopping accelerometer/gyroscope");
|
||||||
_manager.unregisterListener(this);
|
_manager.unregisterListener(this);
|
||||||
|
_manager.unregisterListener(gyro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void start()
|
public synchronized void start()
|
||||||
{
|
{
|
||||||
if( Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer )
|
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
|
||||||
|
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
|
||||||
{
|
{
|
||||||
if( _manager != null )
|
System.out.println("libSDL: starting accelerometer");
|
||||||
{
|
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
||||||
System.out.println("libSDL: starting accelerometer");
|
}
|
||||||
// TODO: orientation allows for 3rd axis - azimuth, but it will be way too hard to the user
|
if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
|
||||||
// if( ! _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME) )
|
{
|
||||||
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
System.out.println("libSDL: starting gyroscope");
|
||||||
}
|
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event)
|
||||||
|
{
|
||||||
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
|
if( Globals.HorizontalOrientation )
|
||||||
{
|
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||||
if( Globals.HorizontalOrientation )
|
|
||||||
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
|
||||||
else
|
|
||||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||||
|
}
|
||||||
|
public void onAccuracyChanged(Sensor s, int a)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static class GyroscopeListener implements SensorEventListener
|
||||||
|
{
|
||||||
|
public float x1, x2, xc, y1, y2, yc, z1, z2, zc;
|
||||||
|
public GyroscopeListener()
|
||||||
{
|
{
|
||||||
if( Globals.HorizontalOrientation )
|
|
||||||
nativeOrientation(event.values[1], -event.values[2], event.values[0]);
|
|
||||||
else
|
|
||||||
nativeOrientation(event.values[2], event.values[1], event.values[0]);
|
|
||||||
}
|
}
|
||||||
|
public void onSensorChanged(SensorEvent event)
|
||||||
|
{
|
||||||
|
// TODO: vertical orientation
|
||||||
|
//if( Globals.HorizontalOrientation )
|
||||||
|
if( event.values[0] < x1 || event.values[0] > x2 ||
|
||||||
|
event.values[1] < y1 || event.values[1] > y2 ||
|
||||||
|
event.values[2] < z1 || event.values[2] > z2 )
|
||||||
|
nativeGyroscope(event.values[0] - xc, event.values[1] - yc, event.values[2] - zc);
|
||||||
|
}
|
||||||
|
public void onAccuracyChanged(Sensor s, int a)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public boolean available(Activity context)
|
||||||
|
{
|
||||||
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
|
||||||
|
}
|
||||||
|
public void registerListener(Activity context, SensorEventListener l)
|
||||||
|
{
|
||||||
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
|
||||||
|
return;
|
||||||
|
manager.registerListener(l, manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
}
|
||||||
|
public void unregisterListener(Activity context,SensorEventListener l)
|
||||||
|
{
|
||||||
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
if ( manager == null )
|
||||||
|
return;
|
||||||
|
manager.unregisterListener(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void onAccuracyChanged(Sensor s, int a) {
|
private static native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||||
}
|
private static native void nativeGyroscope(float X, float Y, float Z);
|
||||||
|
|
||||||
private native void nativeAccelerometer(float accX, float accY, float accZ);
|
|
||||||
private native void nativeOrientation(float accX, float accY, float accZ);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class Globals
|
|||||||
public static boolean CompatibilityHacksStaticInit = false;
|
public static boolean CompatibilityHacksStaticInit = false;
|
||||||
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
|
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
|
||||||
public static boolean HorizontalOrientation = true;
|
public static boolean HorizontalOrientation = true;
|
||||||
|
public static boolean KeepAspectRatioDefaultSetting = false;
|
||||||
public static boolean InhibitSuspend = false;
|
public static boolean InhibitSuspend = false;
|
||||||
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
|
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
|
||||||
public static String CommandLine = "";
|
public static String CommandLine = "";
|
||||||
@@ -53,6 +54,7 @@ class Globals
|
|||||||
public static boolean AppNeedsTextInput = true;
|
public static boolean AppNeedsTextInput = true;
|
||||||
public static boolean AppUsesJoystick = false;
|
public static boolean AppUsesJoystick = false;
|
||||||
public static boolean AppUsesAccelerometer = false;
|
public static boolean AppUsesAccelerometer = false;
|
||||||
|
public static boolean AppUsesGyroscope = false;
|
||||||
public static boolean AppUsesMultitouch = false;
|
public static boolean AppUsesMultitouch = false;
|
||||||
public static boolean NonBlockingSwapBuffers = false;
|
public static boolean NonBlockingSwapBuffers = false;
|
||||||
public static boolean ResetSdlConfigForThisVersion = false;
|
public static boolean ResetSdlConfigForThisVersion = false;
|
||||||
@@ -62,7 +64,7 @@ class Globals
|
|||||||
public static int StartupMenuButtonTimeout = 3000;
|
public static int StartupMenuButtonTimeout = 3000;
|
||||||
public static int AppMinimumRAM = 0;
|
public static int AppMinimumRAM = 0;
|
||||||
public static Settings.Menu HiddenMenuOptions [] = {};
|
public static Settings.Menu HiddenMenuOptions [] = {};
|
||||||
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true) };
|
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true), new Settings.GyroscopeCalibration() };
|
||||||
public static String AdmobPublisherId = "";
|
public static String AdmobPublisherId = "";
|
||||||
public static String AdmobTestDeviceId = "";
|
public static String AdmobTestDeviceId = "";
|
||||||
public static String AdmobBannerSize = "";
|
public static String AdmobBannerSize = "";
|
||||||
@@ -96,7 +98,7 @@ class Globals
|
|||||||
public static int RelativeMouseMovementSpeed = 2;
|
public static int RelativeMouseMovementSpeed = 2;
|
||||||
public static int RelativeMouseMovementAccel = 0;
|
public static int RelativeMouseMovementAccel = 0;
|
||||||
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||||
public static boolean KeepAspectRatio = false;
|
public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
|
||||||
public static int ClickScreenPressure = 0;
|
public static int ClickScreenPressure = 0;
|
||||||
public static int ClickScreenTouchspotSize = 0;
|
public static int ClickScreenTouchspotSize = 0;
|
||||||
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
||||||
@@ -111,4 +113,6 @@ class Globals
|
|||||||
public static boolean VideoLinearFilter = true;
|
public static boolean VideoLinearFilter = true;
|
||||||
public static boolean MultiThreadedVideo = false;
|
public static boolean MultiThreadedVideo = false;
|
||||||
public static boolean BrokenLibCMessageShown = false;
|
public static boolean BrokenLibCMessageShown = false;
|
||||||
|
// Gyroscope calibration
|
||||||
|
public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import java.io.FileInputStream;
|
|||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.Set;
|
||||||
import android.text.SpannedString;
|
import android.text.SpannedString;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ import android.app.AlarmManager;
|
|||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.hardware.SensorEventListener;
|
||||||
|
import android.hardware.SensorEvent;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
|
||||||
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
||||||
class Settings
|
class Settings
|
||||||
@@ -153,6 +157,15 @@ class Settings
|
|||||||
out.writeBoolean(Globals.BrokenLibCMessageShown);
|
out.writeBoolean(Globals.BrokenLibCMessageShown);
|
||||||
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
|
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
|
||||||
out.writeInt(p.getApplicationVersion());
|
out.writeInt(p.getApplicationVersion());
|
||||||
|
out.writeFloat(Globals.gyro_x1);
|
||||||
|
out.writeFloat(Globals.gyro_x2);
|
||||||
|
out.writeFloat(Globals.gyro_xc);
|
||||||
|
out.writeFloat(Globals.gyro_y1);
|
||||||
|
out.writeFloat(Globals.gyro_y2);
|
||||||
|
out.writeFloat(Globals.gyro_yc);
|
||||||
|
out.writeFloat(Globals.gyro_z1);
|
||||||
|
out.writeFloat(Globals.gyro_z2);
|
||||||
|
out.writeFloat(Globals.gyro_zc);
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
settingsLoaded = true;
|
settingsLoaded = true;
|
||||||
@@ -299,6 +312,15 @@ class Settings
|
|||||||
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
|
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
|
||||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||||
int cfgVersion = settingsFile.readInt();
|
int cfgVersion = settingsFile.readInt();
|
||||||
|
Globals.gyro_x1 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_x2 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_xc = settingsFile.readFloat();
|
||||||
|
Globals.gyro_y1 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_y2 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_yc = settingsFile.readFloat();
|
||||||
|
Globals.gyro_z1 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_z2 = settingsFile.readFloat();
|
||||||
|
Globals.gyro_zc = settingsFile.readFloat();
|
||||||
|
|
||||||
settingsLoaded = true;
|
settingsLoaded = true;
|
||||||
|
|
||||||
@@ -530,6 +552,7 @@ class Settings
|
|||||||
new MouseConfigMainMenu(),
|
new MouseConfigMainMenu(),
|
||||||
new ArrowKeysConfig(),
|
new ArrowKeysConfig(),
|
||||||
new AccelerometerConfig(),
|
new AccelerometerConfig(),
|
||||||
|
new GyroscopeCalibration(),
|
||||||
new AudioConfig(),
|
new AudioConfig(),
|
||||||
new RemapHwKeysConfig(),
|
new RemapHwKeysConfig(),
|
||||||
new ScreenGesturesConfig(),
|
new ScreenGesturesConfig(),
|
||||||
@@ -2194,8 +2217,10 @@ class Settings
|
|||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
FrameLayout layout = null;
|
FrameLayout layout = null;
|
||||||
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
||||||
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
|
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
|
||||||
|
ImageView boundary = null;
|
||||||
|
Bitmap boundaryBmp = null;
|
||||||
int currentButton = 0;
|
int currentButton = 0;
|
||||||
int buttons[] = {
|
int buttons[] = {
|
||||||
R.drawable.dpad,
|
R.drawable.dpad,
|
||||||
@@ -2213,7 +2238,27 @@ class Settings
|
|||||||
p = _p;
|
p = _p;
|
||||||
layout = new FrameLayout(p);
|
layout = new FrameLayout(p);
|
||||||
p.getVideoLayout().addView(layout);
|
p.getVideoLayout().addView(layout);
|
||||||
|
boundary = new ImageView(p);
|
||||||
|
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
|
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
|
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
|
||||||
|
boundary.setImageBitmap(boundaryBmp);
|
||||||
|
layout.addView(boundary);
|
||||||
currentButton = 0;
|
currentButton = 0;
|
||||||
|
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||||
|
{
|
||||||
|
int buttons2[] = {
|
||||||
|
R.drawable.sun_dpad,
|
||||||
|
R.drawable.sun_keyboard,
|
||||||
|
R.drawable.sun_b1,
|
||||||
|
R.drawable.sun_b2,
|
||||||
|
R.drawable.sun_b3,
|
||||||
|
R.drawable.sun_b4,
|
||||||
|
R.drawable.sun_b5,
|
||||||
|
R.drawable.sun_b6
|
||||||
|
};
|
||||||
|
buttons = buttons2;
|
||||||
|
}
|
||||||
setupButton(true);
|
setupButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2240,11 +2285,28 @@ class Settings
|
|||||||
if( imgs[currentButton] == null )
|
if( imgs[currentButton] == null )
|
||||||
{
|
{
|
||||||
imgs[currentButton] = new ImageView(p);
|
imgs[currentButton] = new ImageView(p);
|
||||||
imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX);
|
imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] );
|
bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] );
|
||||||
imgs[currentButton].setImageBitmap(bmps[currentButton]);
|
imgs[currentButton].setImageBitmap(bmps[currentButton]);
|
||||||
layout.addView(imgs[currentButton]);
|
layout.addView(imgs[currentButton]);
|
||||||
|
boundary.bringToFront();
|
||||||
|
}
|
||||||
|
if( Globals.ScreenKbControlsLayout[currentButton][0] == Globals.ScreenKbControlsLayout[currentButton][2] ||
|
||||||
|
Globals.ScreenKbControlsLayout[currentButton][1] == Globals.ScreenKbControlsLayout[currentButton][3] )
|
||||||
|
{
|
||||||
|
int displayX = 800;
|
||||||
|
int displayY = 480;
|
||||||
|
try {
|
||||||
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
|
displayX = dm.widthPixels;
|
||||||
|
displayY = dm.heightPixels;
|
||||||
|
} catch (Exception eeeee) {}
|
||||||
|
Globals.ScreenKbControlsLayout[currentButton][0] = displayX / 2 - displayX / 6;
|
||||||
|
Globals.ScreenKbControlsLayout[currentButton][2] = displayX / 2 + displayX / 6;
|
||||||
|
Globals.ScreenKbControlsLayout[currentButton][1] = displayY / 2 - displayY / 4;
|
||||||
|
Globals.ScreenKbControlsLayout[currentButton][3] = displayY / 2 + displayY / 4;
|
||||||
}
|
}
|
||||||
Matrix m = new Matrix();
|
Matrix m = new Matrix();
|
||||||
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
|
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
|
||||||
@@ -2252,6 +2314,10 @@ class Settings
|
|||||||
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
||||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
imgs[currentButton].setImageMatrix(m);
|
imgs[currentButton].setImageMatrix(m);
|
||||||
|
m = new Matrix();
|
||||||
|
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||||
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
|
boundary.setImageMatrix(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTouchEvent(final MotionEvent ev)
|
public void onTouchEvent(final MotionEvent ev)
|
||||||
@@ -2286,6 +2352,10 @@ class Settings
|
|||||||
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
||||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
imgs[currentButton].setImageMatrix(m);
|
imgs[currentButton].setImageMatrix(m);
|
||||||
|
m = new Matrix();
|
||||||
|
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||||
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
|
boundary.setImageMatrix(m);
|
||||||
|
|
||||||
if( ev.getAction() == MotionEvent.ACTION_UP )
|
if( ev.getAction() == MotionEvent.ACTION_UP )
|
||||||
setupButton(false);
|
setupButton(false);
|
||||||
@@ -2438,6 +2508,149 @@ class Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class GyroscopeCalibration extends Menu implements SensorEventListener
|
||||||
|
{
|
||||||
|
String title(final MainActivity p)
|
||||||
|
{
|
||||||
|
return p.getResources().getString(R.string.calibrate_gyroscope);
|
||||||
|
}
|
||||||
|
boolean enabled()
|
||||||
|
{
|
||||||
|
return Globals.AppUsesGyroscope;
|
||||||
|
}
|
||||||
|
void run (final MainActivity p)
|
||||||
|
{
|
||||||
|
if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
|
||||||
|
{
|
||||||
|
goBack(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
|
builder.setTitle(p.getResources().getString(R.string.calibrate_gyroscope));
|
||||||
|
builder.setMessage(p.getResources().getString(R.string.calibrate_gyroscope_text));
|
||||||
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
public void onClick(DialogInterface dialog, int item)
|
||||||
|
{
|
||||||
|
dialog.dismiss();
|
||||||
|
startCalibration(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||||
|
{
|
||||||
|
public void onCancel(DialogInterface dialog)
|
||||||
|
{
|
||||||
|
goBack(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = builder.create();
|
||||||
|
alert.setOwnerActivity(p);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageView img;
|
||||||
|
Bitmap bmp;
|
||||||
|
int numEvents;
|
||||||
|
MainActivity p;
|
||||||
|
|
||||||
|
void startCalibration(final MainActivity _p)
|
||||||
|
{
|
||||||
|
p = _p;
|
||||||
|
img = new ImageView(p);
|
||||||
|
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
|
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
|
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
||||||
|
img.setImageBitmap(bmp);
|
||||||
|
Matrix m = new Matrix();
|
||||||
|
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||||
|
RectF dst = new RectF( p.getVideoLayout().getWidth()/2 - 50, p.getVideoLayout().getHeight()/2 - 50,
|
||||||
|
p.getVideoLayout().getWidth()/2 + 50, p.getVideoLayout().getHeight()/2 + 50);
|
||||||
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
|
img.setImageMatrix(m);
|
||||||
|
p.getVideoLayout().addView(img);
|
||||||
|
numEvents = 0;
|
||||||
|
AccelerometerReader.gyro.x1 = 100;
|
||||||
|
AccelerometerReader.gyro.x2 = -100;
|
||||||
|
AccelerometerReader.gyro.xc = 0;
|
||||||
|
AccelerometerReader.gyro.y1 = 100;
|
||||||
|
AccelerometerReader.gyro.y2 = -100;
|
||||||
|
AccelerometerReader.gyro.yc = 0;
|
||||||
|
AccelerometerReader.gyro.z1 = 100;
|
||||||
|
AccelerometerReader.gyro.z2 = -100;
|
||||||
|
AccelerometerReader.gyro.zc = 0;
|
||||||
|
AccelerometerReader.gyro.registerListener(p, this);
|
||||||
|
(new Thread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
for(int count = 1; count < 10; count++)
|
||||||
|
{
|
||||||
|
p.setText("" + count + "0% ...");
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch( Exception e ) {}
|
||||||
|
}
|
||||||
|
finishCalibration(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSensorChanged(SensorEvent event)
|
||||||
|
{
|
||||||
|
gyroscopeEvent(event.values[0], event.values[1], event.values[2]);
|
||||||
|
}
|
||||||
|
public void onAccuracyChanged(Sensor s, int a)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void gyroscopeEvent(float x, float y, float z)
|
||||||
|
{
|
||||||
|
numEvents++;
|
||||||
|
AccelerometerReader.gyro.xc += x;
|
||||||
|
AccelerometerReader.gyro.yc += y;
|
||||||
|
AccelerometerReader.gyro.zc += z;
|
||||||
|
AccelerometerReader.gyro.x1 = Math.min(AccelerometerReader.gyro.x1, x * 1.1f); // Small safety bound coefficient
|
||||||
|
AccelerometerReader.gyro.x2 = Math.max(AccelerometerReader.gyro.x2, x * 1.1f);
|
||||||
|
AccelerometerReader.gyro.y1 = Math.min(AccelerometerReader.gyro.y1, y * 1.1f);
|
||||||
|
AccelerometerReader.gyro.y2 = Math.max(AccelerometerReader.gyro.y2, y * 1.1f);
|
||||||
|
AccelerometerReader.gyro.z1 = Math.min(AccelerometerReader.gyro.z1, z * 1.1f);
|
||||||
|
AccelerometerReader.gyro.z2 = Math.max(AccelerometerReader.gyro.z2, z * 1.1f);
|
||||||
|
final Matrix m = new Matrix();
|
||||||
|
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||||
|
RectF dst = new RectF( x * 5000 + p.getVideoLayout().getWidth()/2 - 50, y * 5000 + p.getVideoLayout().getHeight()/2 - 50,
|
||||||
|
x * 5000 + p.getVideoLayout().getWidth()/2 + 50, y * 5000 + p.getVideoLayout().getHeight()/2 + 50);
|
||||||
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
|
p.runOnUiThread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
img.setImageMatrix(m);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
void finishCalibration(final MainActivity p)
|
||||||
|
{
|
||||||
|
AccelerometerReader.gyro.unregisterListener(p, this);
|
||||||
|
try {
|
||||||
|
Thread.sleep(200); // Just in case we have pending events
|
||||||
|
} catch( Exception e ) {}
|
||||||
|
if( numEvents > 5 )
|
||||||
|
{
|
||||||
|
AccelerometerReader.gyro.xc /= (float)numEvents;
|
||||||
|
AccelerometerReader.gyro.yc /= (float)numEvents;
|
||||||
|
AccelerometerReader.gyro.zc /= (float)numEvents;
|
||||||
|
}
|
||||||
|
p.runOnUiThread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
p.getVideoLayout().removeView(img);
|
||||||
|
goBack(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===============================================================================================
|
// ===============================================================================================
|
||||||
|
|
||||||
public static boolean deleteRecursively(File dir)
|
public static boolean deleteRecursively(File dir)
|
||||||
|
|||||||
@@ -108,14 +108,13 @@ abstract class DifferentTouchInput
|
|||||||
multiTouchAvailable2 = true;
|
multiTouchAvailable2 = true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
System.out.println("Device model: " + android.os.Build.MODEL);
|
||||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
|
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
|
||||||
{
|
{
|
||||||
if(android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717"))
|
|
||||||
return GalaxyNoteIcsTouchInput.Holder.sInstance;
|
|
||||||
return IcsTouchInput.Holder.sInstance;
|
return IcsTouchInput.Holder.sInstance;
|
||||||
}
|
}
|
||||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
|
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
|
||||||
return XperiaPlayTouchpadTouchInput.Holder.sInstance;
|
return GingerbreadTouchInput.Holder.sInstance;
|
||||||
if (multiTouchAvailable1 && multiTouchAvailable2)
|
if (multiTouchAvailable1 && multiTouchAvailable2)
|
||||||
return MultiTouchInput.Holder.sInstance;
|
return MultiTouchInput.Holder.sInstance;
|
||||||
else
|
else
|
||||||
@@ -296,57 +295,21 @@ abstract class DifferentTouchInput
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static class XperiaPlayTouchpadTouchInput extends MultiTouchInput
|
private static class GingerbreadTouchInput extends MultiTouchInput
|
||||||
{
|
{
|
||||||
private static class Holder
|
private static class Holder
|
||||||
{
|
{
|
||||||
private static final XperiaPlayTouchpadTouchInput sInstance = new XperiaPlayTouchpadTouchInput();
|
private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
float xmin = 0.0f;
|
GingerbreadTouchInput()
|
||||||
float xmax = 1.0f;
|
|
||||||
float ymin = 0.0f;
|
|
||||||
float ymax = 1.0f;
|
|
||||||
float minRange = 1.0f;
|
|
||||||
float xshift = 0.0f;
|
|
||||||
|
|
||||||
XperiaPlayTouchpadTouchInput()
|
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
int[] devIds = InputDevice.getDeviceIds();
|
|
||||||
for( int id : devIds )
|
|
||||||
{
|
|
||||||
InputDevice device = InputDevice.getDevice(id);
|
|
||||||
if( device == null )
|
|
||||||
continue;
|
|
||||||
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
|
|
||||||
if( (device.getSources() & InputDevice.SOURCE_TOUCHPAD) != InputDevice.SOURCE_TOUCHPAD )
|
|
||||||
continue;
|
|
||||||
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() + " is a touchpad" );
|
|
||||||
InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X /*, InputDevice.SOURCE_TOUCHPAD*/);
|
|
||||||
if(range != null)
|
|
||||||
{
|
|
||||||
xmin = range.getMin();
|
|
||||||
xmax = range.getMax() - range.getMin();
|
|
||||||
System.out.println("libSDL: touch pad X range " + xmin + ":" + xmax );
|
|
||||||
}
|
|
||||||
range = device.getMotionRange(MotionEvent.AXIS_Y /*, InputDevice.SOURCE_TOUCHPAD*/);
|
|
||||||
if(range != null)
|
|
||||||
{
|
|
||||||
ymin = range.getMin();
|
|
||||||
ymax = range.getMax() - range.getMin();
|
|
||||||
System.out.println("libSDL: touch pad Y range " + ymin + ":" + ymax );
|
|
||||||
}
|
|
||||||
// Xperia Play has long wide touchpad with joystick-like embossing on the sides, so we'll leave only a left joystick to function
|
|
||||||
// I don't know how to use the second joystick, so I'll just ignore it for now
|
|
||||||
minRange = Math.min( Math.abs(ymax - ymin), Math.abs(xmax - xmin) );
|
|
||||||
xshift = xmax - minRange;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void process(final MotionEvent event)
|
public void process(final MotionEvent event)
|
||||||
{
|
{
|
||||||
boolean hwMouseEvent = ( event.getSource() == InputDevice.SOURCE_MOUSE ||
|
boolean hwMouseEvent = ( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ||
|
||||||
event.getSource() == InputDevice.SOURCE_STYLUS ||
|
(event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS ||
|
||||||
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
|
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
|
||||||
if( ExternalMouseDetected != hwMouseEvent )
|
if( ExternalMouseDetected != hwMouseEvent )
|
||||||
{
|
{
|
||||||
@@ -357,37 +320,10 @@ abstract class DifferentTouchInput
|
|||||||
}
|
}
|
||||||
public void processGenericEvent(final MotionEvent event)
|
public void processGenericEvent(final MotionEvent event)
|
||||||
{
|
{
|
||||||
if( event.getSource() != InputDevice.SOURCE_TOUCHPAD )
|
process(event);
|
||||||
{
|
|
||||||
process(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
int x = (int)((event.getX() - xmin) / xmax * 65535.0f);
|
|
||||||
int y = (int)((event.getY() - ymin) / ymax * 65535.0f);
|
|
||||||
*/
|
|
||||||
// Use only right square part of a touch surface - I've heard reports that it breaks functionality, feel free to uncomment and test it.
|
|
||||||
int x = (int)((event.getX() - xshift) / minRange * 65535.0f);
|
|
||||||
int y = (int)((event.getY() - ymin) / minRange * 65535.0f);
|
|
||||||
if( x > 65535 )
|
|
||||||
x = 65535;
|
|
||||||
if( x < 0 )
|
|
||||||
x = 0;
|
|
||||||
if( y > 65535 )
|
|
||||||
y = 65535;
|
|
||||||
if( y < 0 )
|
|
||||||
y = 0;
|
|
||||||
int down = 1;
|
|
||||||
int multitouch = event.getPointerCount() - 1;
|
|
||||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
|
|
||||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
|
|
||||||
down = 0;
|
|
||||||
// TODO: we're processing only one touch pointer, touchpad will most probably support multitouch
|
|
||||||
//System.out.println("libSDL: touch pad event: " + x + ":" + y + " action " + event.getAction() + " down " + down + " multitouch " + multitouch );
|
|
||||||
DemoGLSurfaceView.nativeTouchpad( x, 65535 - y, down, multitouch ); // Y axis is inverted, as you may have guessed
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static class IcsTouchInput extends XperiaPlayTouchpadTouchInput
|
private static class IcsTouchInput extends GingerbreadTouchInput
|
||||||
{
|
{
|
||||||
private static class Holder
|
private static class Holder
|
||||||
{
|
{
|
||||||
@@ -411,6 +347,16 @@ abstract class DifferentTouchInput
|
|||||||
}
|
}
|
||||||
public void processGenericEvent(final MotionEvent event)
|
public void processGenericEvent(final MotionEvent event)
|
||||||
{
|
{
|
||||||
|
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||||
|
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||||
|
{
|
||||||
|
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
|
||||||
|
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||||
|
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||||
|
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||||
|
event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Process mousewheel
|
// Process mousewheel
|
||||||
if( event.getAction() == MotionEvent.ACTION_SCROLL )
|
if( event.getAction() == MotionEvent.ACTION_SCROLL )
|
||||||
{
|
{
|
||||||
@@ -422,20 +368,6 @@ abstract class DifferentTouchInput
|
|||||||
super.processGenericEvent(event);
|
super.processGenericEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static class GalaxyNoteIcsTouchInput extends IcsTouchInput
|
|
||||||
{
|
|
||||||
private static class Holder
|
|
||||||
{
|
|
||||||
private static final GalaxyNoteIcsTouchInput sInstance = new GalaxyNoteIcsTouchInput();
|
|
||||||
}
|
|
||||||
public void process(final MotionEvent event)
|
|
||||||
{
|
|
||||||
// HACK for Galaxy Note stylus, which pushes the cursor to the lower-right part of the screen, when you lift the stylus.
|
|
||||||
// Also it reports the stylus as the mouse
|
|
||||||
if(! (event.getSource() == InputDevice.SOURCE_MOUSE && (int)event.getX() == 0 && (int)event.getY() == 799))
|
|
||||||
super.process(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -585,6 +517,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
return context.isScreenKeyboardShown() ? 1 : 0;
|
return context.isScreenKeyboardShown() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startAccelerometerGyroscope(int started)
|
||||||
|
{
|
||||||
|
accelerometer.openedBySDL = (started != 0);
|
||||||
|
if( accelerometer.openedBySDL && !mPaused )
|
||||||
|
accelerometer.start();
|
||||||
|
else
|
||||||
|
accelerometer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
public void exitApp()
|
public void exitApp()
|
||||||
{
|
{
|
||||||
nativeDone();
|
nativeDone();
|
||||||
@@ -774,7 +715,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
System.out.println("libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
|
System.out.println("libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
|
||||||
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
|
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
|
||||||
mRenderer.nativeGlContextRecreated();
|
mRenderer.nativeGlContextRecreated();
|
||||||
if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
|
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||||
mRenderer.accelerometer.start();
|
mRenderer.accelerometer.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -805,8 +746,8 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
public static native void initJavaCallbacks();
|
public static native void initJavaCallbacks();
|
||||||
public static native void nativeHardwareMouseDetected( int detected );
|
public static native void nativeHardwareMouseDetected( int detected );
|
||||||
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
||||||
public static native void nativeMouseWheel(int scrollX, int scrollY);
|
public static native void nativeMouseWheel( int scrollX, int scrollY );
|
||||||
|
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -165,4 +165,7 @@
|
|||||||
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
||||||
<string name="ignore">Ignore</string>
|
<string name="ignore">Ignore</string>
|
||||||
|
|
||||||
|
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
|
||||||
|
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -28,16 +28,18 @@ SDL_TRACKBALL_KEYUP_DELAY := 1
|
|||||||
# resized in HW-accelerated way, however it eats a tiny bit of CPU
|
# resized in HW-accelerated way, however it eats a tiny bit of CPU
|
||||||
SDL_VIDEO_RENDER_RESIZE := 1
|
SDL_VIDEO_RENDER_RESIZE := 1
|
||||||
|
|
||||||
SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := 0
|
|
||||||
|
|
||||||
COMPILED_LIBRARIES := tremor ogg
|
COMPILED_LIBRARIES := tremor ogg
|
||||||
|
|
||||||
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address
|
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address
|
||||||
|
|
||||||
APPLICATION_ADDITIONAL_LDFLAGS := -ltremor
|
APPLICATION_ADDITIONAL_LDFLAGS := -ltremor
|
||||||
|
|
||||||
|
APPLICATION_OVERLAPS_SYSTEM_HEADERS := n
|
||||||
|
|
||||||
APPLICATION_SUBDIRS_BUILD := src/*
|
APPLICATION_SUBDIRS_BUILD := src/*
|
||||||
|
|
||||||
|
APPLICATION_BUILD_EXCLUDE :=
|
||||||
|
|
||||||
APPLICATION_CUSTOM_BUILD_SCRIPT :=
|
APPLICATION_CUSTOM_BUILD_SCRIPT :=
|
||||||
|
|
||||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN
|
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN
|
||||||
|
|||||||
@@ -18,17 +18,22 @@ LOCAL_SRC_FILES := $(filter %.c %.cpp, $(APP_SUBDIRS))
|
|||||||
APP_SUBDIRS := $(filter-out %.c %.cpp, $(APP_SUBDIRS))
|
APP_SUBDIRS := $(filter-out %.c %.cpp, $(APP_SUBDIRS))
|
||||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
|
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
|
||||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
|
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
|
||||||
|
LOCAL_SRC_FILES := $(filter-out $(addprefix $(APPDIR)/, $(APPLICATION_BUILD_EXCLUDE)), $(LOCAL_SRC_FILES))
|
||||||
|
|
||||||
# Disabled because they give slight overhead, add "-frtti -fexceptions" to the AppCflags inside AndroidAppSettings.cfg if you need them
|
# Disabled because they give slight overhead, add "-frtti -fexceptions" to the AppCflags inside AndroidAppSettings.cfg if you need them
|
||||||
# If you use setEnvironment.sh you may write "env CXXFLAGS='-frtti -fexceptions' ../setEnvironment.sh ./configure".
|
# If you use setEnvironment.sh you may write "env CXXFLAGS='-frtti -fexceptions' ../setEnvironment.sh ./configure".
|
||||||
#LOCAL_CPP_FEATURES := exceptions rtti
|
#LOCAL_CPP_FEATURES := exceptions rtti
|
||||||
|
|
||||||
LOCAL_CFLAGS :=
|
LOCAL_CFLAGS :=
|
||||||
LOCAL_C_INCLUDES :=
|
LOCAL_C_INCLUDES := $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D))
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D)) \
|
ifeq ($(APPLICATION_OVERLAPS_SYSTEM_HEADERS),y)
|
||||||
$(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include \
|
LOCAL_CFLAGS += $(foreach D, $(LOCAL_C_INCLUDES), -iquote$(D))
|
||||||
$(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include) \
|
LOCAL_C_INCLUDES :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include
|
||||||
|
LOCAL_C_INCLUDES += $(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include)
|
||||||
|
|
||||||
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)
|
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ CompatibilityHacksStaticInit=n
|
|||||||
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||||
CompatibilityHacksPreventAudioChopping=n
|
CompatibilityHacksPreventAudioChopping=n
|
||||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||||
|
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||||
AppUsesMouse=y
|
AppUsesMouse=y
|
||||||
AppNeedsTwoButtonMouse=y
|
AppNeedsTwoButtonMouse=y
|
||||||
ShowMouseCursor=n
|
ShowMouseCursor=n
|
||||||
@@ -26,6 +27,7 @@ AppNeedsArrowKeys=y
|
|||||||
AppNeedsTextInput=y
|
AppNeedsTextInput=y
|
||||||
AppUsesJoystick=y
|
AppUsesJoystick=y
|
||||||
AppUsesAccelerometer=y
|
AppUsesAccelerometer=y
|
||||||
|
AppUsesGyroscope=y
|
||||||
AppUsesMultitouch=y
|
AppUsesMultitouch=y
|
||||||
NonBlockingSwapBuffers=n
|
NonBlockingSwapBuffers=n
|
||||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
|
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
|
||||||
@@ -45,7 +47,9 @@ CompiledLibraries="sdl_mixer sdl_image"
|
|||||||
CustomBuildScript=n
|
CustomBuildScript=n
|
||||||
AppCflags='-O2 -finline-functions'
|
AppCflags='-O2 -finline-functions'
|
||||||
AppLdflags=''
|
AppLdflags=''
|
||||||
|
AppOverlapsSystemHeaders=
|
||||||
AppSubdirsBuild=''
|
AppSubdirsBuild=''
|
||||||
|
AppBuildExclude=''
|
||||||
AppCmdline=''
|
AppCmdline=''
|
||||||
ReadmeText='^Readme text'
|
ReadmeText='^Readme text'
|
||||||
MinimumScreenSize=s
|
MinimumScreenSize=s
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
Definitions...
|
Definitions...
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
#define SCREEN_W 640
|
#define SCREEN_W 800
|
||||||
#define SCREEN_H 480
|
#define SCREEN_H 480
|
||||||
|
|
||||||
|
|
||||||
@@ -437,13 +437,16 @@ int main(int argc, char* argv[])
|
|||||||
// some random colors
|
// some random colors
|
||||||
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
|
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
|
||||||
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
|
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
|
||||||
int accel[2], screenjoy[2];
|
int accel[5], screenjoy[4], gamepads[4][8];
|
||||||
SDL_Surface *mouse[4];
|
SDL_Surface *mouse[4];
|
||||||
int screenKeyboardShown = 0;
|
int screenKeyboardShown = 0;
|
||||||
|
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
|
||||||
SDL_EnableUNICODE(1);
|
SDL_EnableUNICODE(1);
|
||||||
|
SDL_Joystick * joysticks[6];
|
||||||
|
for( i = 0; i < 6; i++ )
|
||||||
|
joysticks[i] = SDL_JoystickOpen(i);
|
||||||
|
|
||||||
atexit(SDL_Quit);
|
atexit(SDL_Quit);
|
||||||
|
|
||||||
@@ -548,7 +551,7 @@ int main(int argc, char* argv[])
|
|||||||
memset(touchPointers, 0, sizeof(touchPointers));
|
memset(touchPointers, 0, sizeof(touchPointers));
|
||||||
memset(accel, 0, sizeof(accel));
|
memset(accel, 0, sizeof(accel));
|
||||||
memset(screenjoy, 0, sizeof(screenjoy));
|
memset(screenjoy, 0, sizeof(screenjoy));
|
||||||
SDL_Joystick * joystick = SDL_JoystickOpen(0);
|
memset(gamepads, 0, sizeof(gamepads));
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -596,22 +599,33 @@ int main(int argc, char* argv[])
|
|||||||
r.y -= r.h/2;
|
r.y -= r.h/2;
|
||||||
SDL_FillRect(screen, &r, colors[i]);
|
SDL_FillRect(screen, &r, colors[i]);
|
||||||
}
|
}
|
||||||
r.x = SCREEN_W/2 + accel[0] * SCREEN_H / 65536;
|
int joyInput[][3] = {
|
||||||
r.y = SCREEN_H/2 + accel[1] * SCREEN_H / 65536;
|
{accel[0], accel[1], 10},
|
||||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Accel: %d %d screen %d %d", accel[0], accel[1], r.x, r.y);
|
{accel[2], accel[3], 10 + abs(accel[4]) * 100 / 32767},
|
||||||
r.w = 10;
|
{screenjoy[0], screenjoy[1], 10},
|
||||||
r.h = 10;
|
{screenjoy[2], screenjoy[3], 10},
|
||||||
r.x -= r.w/2;
|
{gamepads[0][0], gamepads[0][1], 10 + gamepads[0][4] * 100 / 32767},
|
||||||
r.y -= r.h/2;
|
{gamepads[0][2], gamepads[0][3], 10 + gamepads[0][5] * 100 / 32767},
|
||||||
SDL_FillRect(screen, &r, 0xffffff);
|
{gamepads[0][6], gamepads[0][7], 10},
|
||||||
r.x = SCREEN_W/2 + screenjoy[0] * SCREEN_H / 65536;
|
{gamepads[1][0], gamepads[1][1], 10 + gamepads[1][4] * 100 / 32767},
|
||||||
r.y = SCREEN_H/2 + screenjoy[1] * SCREEN_H / 65536;
|
{gamepads[1][2], gamepads[1][3], 10 + gamepads[1][5] * 100 / 32767},
|
||||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen joystick: %d %d screen %d %d", screenjoy[0], screenjoy[1], r.x, r.y);
|
{gamepads[1][6], gamepads[1][7], 10},
|
||||||
r.w = 10;
|
{gamepads[2][0], gamepads[2][1], 10 + gamepads[2][4] * 100 / 32767},
|
||||||
r.h = 10;
|
{gamepads[2][2], gamepads[2][3], 10 + gamepads[2][5] * 100 / 32767},
|
||||||
r.x -= r.w/2;
|
{gamepads[2][6], gamepads[2][7], 10},
|
||||||
r.y -= r.h/2;
|
{gamepads[3][0], gamepads[3][1], 10 + gamepads[3][4] * 100 / 32767},
|
||||||
SDL_FillRect(screen, &r, 0x000000);
|
{gamepads[3][2], gamepads[3][3], 10 + gamepads[3][5] * 100 / 32767},
|
||||||
|
{gamepads[3][6], gamepads[3][7], 10},
|
||||||
|
};
|
||||||
|
for( i = 0; i < 15; i++ )
|
||||||
|
{
|
||||||
|
r.w = joyInput[i][2];
|
||||||
|
r.h = joyInput[i][2];
|
||||||
|
r.x = SCREEN_W/2 + joyInput[i][0] * SCREEN_H / 65536 - r.w/2;
|
||||||
|
r.y = SCREEN_H/2 + joyInput[i][1] * SCREEN_H / 65536 - r.w/2;
|
||||||
|
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Joy input %d: %d %d %d", i, joyInput[i][0], joyInput[i][1], joyInput[i][2] );
|
||||||
|
SDL_FillRect(screen, &r, i * 123);
|
||||||
|
}
|
||||||
|
|
||||||
int mx, my;
|
int mx, my;
|
||||||
int b = SDL_GetMouseState(&mx, &my);
|
int b = SDL_GetMouseState(&mx, &my);
|
||||||
@@ -652,26 +666,35 @@ int main(int argc, char* argv[])
|
|||||||
// Android-specific events - accelerometer, multitoush, and on-screen joystick
|
// Android-specific events - accelerometer, multitoush, and on-screen joystick
|
||||||
if( evt.type == SDL_JOYAXISMOTION )
|
if( evt.type == SDL_JOYAXISMOTION )
|
||||||
{
|
{
|
||||||
if(evt.jaxis.axis < 4)
|
if(evt.jaxis.which == 0) // Multitouch and on-screen joysticks
|
||||||
{
|
{
|
||||||
if(evt.jaxis.axis < 2)
|
if(evt.jaxis.axis < 4)
|
||||||
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
|
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
|
||||||
else
|
else
|
||||||
accel[evt.jaxis.axis - 2] = evt.jaxis.value;
|
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
|
||||||
}
|
}
|
||||||
else
|
if(evt.jaxis.which == 1)
|
||||||
{
|
{
|
||||||
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
|
accel[evt.jaxis.axis] = evt.jaxis.value; // accelerometer and gyroscope
|
||||||
|
}
|
||||||
|
if(evt.jaxis.which >= 2)
|
||||||
|
{
|
||||||
|
// Each gamepad has 8 axes - two joystick hats, two triggers, and Ouya touchpad
|
||||||
|
gamepads[evt.jaxis.which - 2][evt.jaxis.axis] = evt.jaxis.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
|
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
|
||||||
{
|
{
|
||||||
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
|
if(evt.jbutton.which == 0) // Multitouch and on-screen joystick
|
||||||
|
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
|
||||||
}
|
}
|
||||||
if( evt.type == SDL_JOYBALLMOTION )
|
if( evt.type == SDL_JOYBALLMOTION )
|
||||||
{
|
{
|
||||||
touchPointers[evt.jball.ball].x = evt.jball.xrel;
|
if(evt.jball.which == 0) // Multitouch and on-screen joystick
|
||||||
touchPointers[evt.jball.ball].y = evt.jball.yrel;
|
{
|
||||||
|
touchPointers[evt.jball.ball].x = evt.jball.xrel;
|
||||||
|
touchPointers[evt.jball.ball].y = evt.jball.yrel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL))
|
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL))
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ AppName="Commander Genius"
|
|||||||
AppFullName=net.sourceforge.clonekeenplus
|
AppFullName=net.sourceforge.clonekeenplus
|
||||||
ScreenOrientation=h
|
ScreenOrientation=h
|
||||||
InhibitSuspend=n
|
InhibitSuspend=n
|
||||||
AppDataDownloadUrl="!Keen 1|keen1.zip^Keen 4|keen4.zip^Keen 7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqp19.zip/download"
|
AppDataDownloadUrl="!Keen1|keen1.zip^!Keen4|keen4.zip^!Keen7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqpv19.zip/download"
|
||||||
VideoDepthBpp=24
|
VideoDepthBpp=24
|
||||||
NeedDepthBuffer=n
|
NeedDepthBuffer=n
|
||||||
NeedStencilBuffer=n
|
NeedStencilBuffer=n
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ CompatibilityHacksStaticInit=n
|
|||||||
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||||
CompatibilityHacksPreventAudioChopping=n
|
CompatibilityHacksPreventAudioChopping=n
|
||||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||||
|
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||||
|
CompatibilityHacksSlowCompatibleEventQueue=n
|
||||||
|
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
|
||||||
AppUsesMouse=n
|
AppUsesMouse=n
|
||||||
AppNeedsTwoButtonMouse=n
|
AppNeedsTwoButtonMouse=n
|
||||||
ShowMouseCursor=n
|
ShowMouseCursor=n
|
||||||
@@ -26,9 +29,10 @@ AppNeedsArrowKeys=y
|
|||||||
AppNeedsTextInput=y
|
AppNeedsTextInput=y
|
||||||
AppUsesJoystick=y
|
AppUsesJoystick=y
|
||||||
AppUsesAccelerometer=n
|
AppUsesAccelerometer=n
|
||||||
|
AppUsesGyroscope=y
|
||||||
AppUsesMultitouch=y
|
AppUsesMultitouch=y
|
||||||
NonBlockingSwapBuffers=n
|
NonBlockingSwapBuffers=n
|
||||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
|
RedefinedKeys="SPACE SPACE NO_REMAP NO_REMAP RETURN ESCAPE LCTRL"
|
||||||
AppTouchscreenKeyboardKeysAmount=5
|
AppTouchscreenKeyboardKeysAmount=5
|
||||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||||
RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
|
RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
|
||||||
@@ -37,15 +41,17 @@ HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
|
|||||||
FirstStartMenuOptions=''
|
FirstStartMenuOptions=''
|
||||||
MultiABI=y
|
MultiABI=y
|
||||||
AppMinimumRAM=300
|
AppMinimumRAM=300
|
||||||
AppVersionCode=08817
|
AppVersionCode=08819
|
||||||
AppVersionName="0.8.8.17"
|
AppVersionName="0.8.8.19"
|
||||||
ResetSdlConfigForThisVersion=y
|
ResetSdlConfigForThisVersion=n
|
||||||
DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag .openarena/baseoa/q3config.cfg"
|
DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag"
|
||||||
CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg"
|
CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg"
|
||||||
CustomBuildScript=y
|
CustomBuildScript=y
|
||||||
AppCflags='-O2 -finline-functions'
|
AppCflags='-O2 -finline-functions'
|
||||||
AppLdflags=''
|
AppLdflags=''
|
||||||
|
AppOverlapsSystemHeaders=
|
||||||
AppSubdirsBuild=''
|
AppSubdirsBuild=''
|
||||||
|
AppBuildExclude=''
|
||||||
AppCmdline=''
|
AppCmdline=''
|
||||||
ReadmeText='^Readme text'
|
ReadmeText='^Readme text'
|
||||||
MinimumScreenSize=n
|
MinimumScreenSize=n
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
adb shell rm /sdcard/Android/data/ws.openarena.sdl/files/libsdl-DownloadFinished-10.flag
|
adb shell rm /sdcard/Android/data/ws.openarena.sdl/files/libsdl-DownloadFinished-10.flag
|
||||||
adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena
|
[ -n "$1" ] && adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ HiddenMenuOptions='OptionalDownloadConfig'
|
|||||||
FirstStartMenuOptions=''
|
FirstStartMenuOptions=''
|
||||||
MultiABI=n
|
MultiABI=n
|
||||||
AppMinimumRAM=0
|
AppMinimumRAM=0
|
||||||
AppVersionCode=12324
|
AppVersionCode=12325
|
||||||
AppVersionName="1.2.3.24"
|
AppVersionName="1.2.3.25"
|
||||||
ResetSdlConfigForThisVersion=y
|
ResetSdlConfigForThisVersion=n
|
||||||
DeleteFilesOnUpgrade="%"
|
DeleteFilesOnUpgrade="%"
|
||||||
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
|
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
|
||||||
CustomBuildScript=y
|
CustomBuildScript=y
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Quick compilation guide:
|
Quick compilation guide:
|
||||||
Download my GIT repo from https://github.com/pelya/commandergenius,
|
Install liblzma-dev, it's needed for configure script
|
||||||
|
sudo apt-get install liblzma-dev
|
||||||
|
Download my Git repo from https://github.com/pelya/commandergenius,
|
||||||
then install Android SDK, Android NDK, and "ant" tool, then launch commands
|
then install Android SDK, Android NDK, and "ant" tool, then launch commands
|
||||||
rm project/jni/application/src
|
rm project/jni/application/src
|
||||||
ln -s openttd project/jni/application/src
|
ln -s openttd project/jni/application/src
|
||||||
|
|||||||
1
project/jni/application/sc2/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
src
|
||||||
@@ -5,7 +5,7 @@ AppName="Ur-Quan Masters"
|
|||||||
AppFullName=com.sourceforge.sc2
|
AppFullName=com.sourceforge.sc2
|
||||||
ScreenOrientation=h
|
ScreenOrientation=h
|
||||||
InhibitSuspend=n
|
InhibitSuspend=n
|
||||||
AppDataDownloadUrl="!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
|
AppDataDownloadUrl="!!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
|
||||||
VideoDepthBpp=16
|
VideoDepthBpp=16
|
||||||
NeedDepthBuffer=n
|
NeedDepthBuffer=n
|
||||||
NeedStencilBuffer=n
|
NeedStencilBuffer=n
|
||||||
@@ -15,6 +15,10 @@ SdlVideoResize=y
|
|||||||
SdlVideoResizeKeepAspect=n
|
SdlVideoResizeKeepAspect=n
|
||||||
CompatibilityHacks=n
|
CompatibilityHacks=n
|
||||||
CompatibilityHacksStaticInit=n
|
CompatibilityHacksStaticInit=n
|
||||||
|
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||||
|
CompatibilityHacksPreventAudioChopping=n
|
||||||
|
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||||
|
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||||
AppUsesMouse=n
|
AppUsesMouse=n
|
||||||
AppNeedsTwoButtonMouse=n
|
AppNeedsTwoButtonMouse=n
|
||||||
ShowMouseCursor=n
|
ShowMouseCursor=n
|
||||||
@@ -22,7 +26,7 @@ ForceRelativeMouseMode=n
|
|||||||
AppNeedsArrowKeys=y
|
AppNeedsArrowKeys=y
|
||||||
AppNeedsTextInput=y
|
AppNeedsTextInput=y
|
||||||
AppUsesJoystick=y
|
AppUsesJoystick=y
|
||||||
AppHandlesJoystickSensitivity=n
|
AppUsesAccelerometer=n
|
||||||
AppUsesMultitouch=n
|
AppUsesMultitouch=n
|
||||||
NonBlockingSwapBuffers=n
|
NonBlockingSwapBuffers=n
|
||||||
RedefinedKeys="RETURN RSHIFT NO_REMAP NO_REMAP RCTRL F10"
|
RedefinedKeys="RETURN RSHIFT NO_REMAP NO_REMAP RCTRL F10"
|
||||||
@@ -33,14 +37,21 @@ StartupMenuButtonTimeout=3000
|
|||||||
HiddenMenuOptions=''
|
HiddenMenuOptions=''
|
||||||
FirstStartMenuOptions=''
|
FirstStartMenuOptions=''
|
||||||
MultiABI=n
|
MultiABI=n
|
||||||
AppVersionCode=07022
|
AppMinimumRAM=0
|
||||||
AppVersionName="0.7.0.22"
|
AppVersionCode=07023
|
||||||
|
AppVersionName="0.7.0.23"
|
||||||
ResetSdlConfigForThisVersion=y
|
ResetSdlConfigForThisVersion=y
|
||||||
DeleteFilesOnUpgrade="%"
|
DeleteFilesOnUpgrade="%"
|
||||||
CompiledLibraries="sdl_image tremor ogg"
|
CompiledLibraries="sdl_image tremor ogg"
|
||||||
CustomBuildScript=n
|
CustomBuildScript=n
|
||||||
AppCflags='-O3 -DTHREADLIB_SDL=1 -DTIMELIB=SDL -DOVCODEC_TREMOR=1 -DNETPLAY=1 -DHAVE_GETOPT_LONG=1 -DHAVE_ZIP=1 -DHAVE_JOYSTICK=1'
|
AppCflags='-O3 -DGFXMODULE_SDL -DOVCODEC_TREMOR -DNETPLAY=NETPLAY_FULL -DHAVE_JOYSTICK -DHAVE_ZIP=1 -DTHREADLIB_SDL -DUSE_INTERNAL_MIKMOD'
|
||||||
AppLdflags=''
|
AppLdflags=''
|
||||||
AppSubdirsBuild='src src/regex src/libs/* src/uqm/*'
|
AppOverlapsSystemHeaders=y
|
||||||
|
AppSubdirsBuild='src src/libs/* src/uqm/*'
|
||||||
|
AppBuildExclude='src/libs/uio/hashtable.c src/libs/uio/memdebug.c'
|
||||||
AppCmdline='uqm --addon lang'
|
AppCmdline='uqm --addon lang'
|
||||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||||
|
MinimumScreenSize=s
|
||||||
|
AdmobPublisherId=n
|
||||||
|
AdmobTestDeviceId=
|
||||||
|
AdmobBannerSize=
|
||||||
|
|||||||
BIN
project/jni/application/sc2/AndroidData/logo.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
10
project/jni/application/sc2/AndroidPreBuild.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
LOCAL_PATH=`dirname $0`
|
||||||
|
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||||
|
|
||||||
|
if [ -e src/patched.successfully ]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
svn co https://sc2.svn.sourceforge.net/svnroot/sc2/trunk/sc2/src && patch -p0 -d src < android.diff && touch src/patched.successfully || exit 1
|
||||||
|
fi
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../../../sc2/sc2/src/
|
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
|
|
||||||
$(shell mkdir -p AI debug/AI Scripting debug/Scripting \
|
$(shell mkdir -p AI debug/AI Scripting debug/Scripting \
|
||||||
|
<<<<<<< HEAD
|
||||||
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/lib/Mapping \
|
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/lib/Mapping \
|
||||||
out/vcmi/lib/RMG out/vcmi/server out/vcmi/AI/StupidAI \
|
out/vcmi/lib/RMG out/vcmi/server out/vcmi/AI/StupidAI \
|
||||||
out/vcmi/AI/GeniusAI out/vcmi/client out/vcmi/Scripting/ERM)
|
out/vcmi/AI/GeniusAI out/vcmi/client out/vcmi/Scripting/ERM)
|
||||||
|
=======
|
||||||
|
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/server out/vcmi/AI/StupidAI \
|
||||||
|
out/vcmi/AI/BattleAI out/vcmi/AI/EmptyAI \
|
||||||
|
out/vcmi/AI/Fuzzylite out/vcmi/AI/VCAI \
|
||||||
|
out/vcmi/client out/vcmi/Scripting/ERM)
|
||||||
|
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
|
||||||
$(shell rm -f ../../../obj/local/armeabi/libvcmi.so)
|
$(shell rm -f ../../../obj/local/armeabi/libvcmi.so)
|
||||||
|
|
||||||
LOCAL_PATH=$(shell dirname $0)
|
LOCAL_PATH=$(shell dirname $0)
|
||||||
@@ -10,7 +17,7 @@ LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
|||||||
|
|
||||||
GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r8'),arm-linux-androideabi,arm-eabi)
|
GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r8'),arm-linux-androideabi,arm-eabi)
|
||||||
|
|
||||||
SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
|
SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/lib/Filesystem/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
|
||||||
OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB))
|
OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB))
|
||||||
|
|
||||||
SOURCES_LIB_FILESYSTEM=$(wildcard vcmi/lib/Filesystem/*.cpp)
|
SOURCES_LIB_FILESYSTEM=$(wildcard vcmi/lib/Filesystem/*.cpp)
|
||||||
@@ -25,11 +32,26 @@ OBJS_LIB_RMG=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_RMG))
|
|||||||
SOURCES_SERVER=$(wildcard vcmi/server/*.cpp)
|
SOURCES_SERVER=$(wildcard vcmi/server/*.cpp)
|
||||||
OBJS_SERVER=$(patsubst %.cpp, out/%.o, $(SOURCES_SERVER))
|
OBJS_SERVER=$(patsubst %.cpp, out/%.o, $(SOURCES_SERVER))
|
||||||
|
|
||||||
|
SOURCES_CLIENT=$(wildcard vcmi/client/*.cpp vcmi/client/BattleInterface/*.cpp vcmi/client/UIFramework/*.cpp)
|
||||||
|
OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
|
||||||
|
|
||||||
|
#SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
|
||||||
|
#OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
|
||||||
|
|
||||||
|
SOURCES_BATTLEAI=$(wildcard vcmi/AI/BattleAI/*.cpp)
|
||||||
|
OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_BATTLEAI))
|
||||||
|
|
||||||
|
SOURCES_EMPTYAI=$(wildcard vcmi/AI/EmptyAI/*.cpp)
|
||||||
|
OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_EMPTYAI))
|
||||||
|
|
||||||
|
SOURCES_FUZZYLITE=$(wildcard vcmi/AI/FuzzyLite/*.cpp)
|
||||||
|
OBJS_FUZZYLITE=$(patsubst %.cpp, out/%.o, $(SOURCES_FUZZYLITE))
|
||||||
|
|
||||||
SOURCES_STUPIDAI=$(wildcard vcmi/AI/StupidAI/*.cpp)
|
SOURCES_STUPIDAI=$(wildcard vcmi/AI/StupidAI/*.cpp)
|
||||||
OBJS_STUPIDAI=$(patsubst %.cpp, out/%.o, $(SOURCES_STUPIDAI))
|
OBJS_STUPIDAI=$(patsubst %.cpp, out/%.o, $(SOURCES_STUPIDAI))
|
||||||
|
|
||||||
SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
|
SOURCES_VCAI=$(wildcard vcmi/AI/VCAI/*.cpp)
|
||||||
OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
|
OBJS_VCAI=$(patsubst %.cpp, out/%.o, $(SOURCES_VCAI))
|
||||||
|
|
||||||
SOURCES_ERM=$(wildcard vcmi/Scripting/ERM/*.cpp)
|
SOURCES_ERM=$(wildcard vcmi/Scripting/ERM/*.cpp)
|
||||||
OBJS_ERM=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM))
|
OBJS_ERM=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM))
|
||||||
@@ -39,11 +61,15 @@ OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
|
|||||||
|
|
||||||
all: AndroidData/binaries.zip libapplication.so
|
all: AndroidData/binaries.zip libapplication.so
|
||||||
|
|
||||||
AndroidData/binaries.zip: vcmiserver AI/libGeniusAI.so AI/libStupidAI.so Scripting/libvcmiERM.so
|
AndroidData/binaries.zip: vcmiserver AI/libAI.so Scripting/libvcmiERM.so
|
||||||
rm -f $@
|
rm -f $@
|
||||||
zip -r $@ $^
|
zip -r $@ $^
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
|
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
|
||||||
|
=======
|
||||||
|
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
|
||||||
|
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
|
||||||
../setEnvironment.sh sh -c \
|
../setEnvironment.sh sh -c \
|
||||||
"$(GCC_PREFIX)-g++ \
|
"$(GCC_PREFIX)-g++ \
|
||||||
-c \$$CXXFLAGS -Ivcmi -std=c++11 -Ivcmi/lib \
|
-c \$$CXXFLAGS -Ivcmi -std=c++11 -Ivcmi/lib \
|
||||||
@@ -59,8 +85,13 @@ vcmiserver: $(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING
|
|||||||
env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment.sh sh -c \
|
env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment.sh sh -c \
|
||||||
"$(GCC_PREFIX)-g++ \
|
"$(GCC_PREFIX)-g++ \
|
||||||
$^ -o $@ \
|
$^ -o $@ \
|
||||||
|
<<<<<<< HEAD
|
||||||
\$$LDFLAGS -L. -L../../boost/lib/arm-linux-androideabi-4.6 \
|
\$$LDFLAGS -L. -L../../boost/lib/arm-linux-androideabi-4.6 \
|
||||||
-lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lgnustl_static" && \
|
-lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lgnustl_static" && \
|
||||||
|
=======
|
||||||
|
\$$LDFLAGS -L. \
|
||||||
|
-lboost_system -lboost_filesystem -lboost_iostreams -lboost_thread" && \
|
||||||
|
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
|
||||||
cp $@ debug/$@ && \
|
cp $@ debug/$@ && \
|
||||||
$(GCC_PREFIX)-strip $@
|
$(GCC_PREFIX)-strip $@
|
||||||
|
|
||||||
@@ -76,10 +107,7 @@ LINK_LIB= \
|
|||||||
.PHONY: -lvcmi
|
.PHONY: -lvcmi
|
||||||
-lvcmi: libvcmi.so
|
-lvcmi: libvcmi.so
|
||||||
|
|
||||||
AI/libGeniusAI.so: $(OBJS_GENIUSAI) -lvcmi
|
AI/libAI.so: $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) -lvcmi
|
||||||
$(LINK_LIB)
|
|
||||||
|
|
||||||
AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi
|
|
||||||
$(LINK_LIB)
|
$(LINK_LIB)
|
||||||
|
|
||||||
Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi
|
Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi
|
||||||
|
|||||||
@@ -0,0 +1,592 @@
|
|||||||
|
/*
|
||||||
|
SDL - Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2009 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 <jni.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h> // for memset()
|
||||||
|
|
||||||
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
#include "SDL_version.h"
|
||||||
|
#include "SDL_mutex.h"
|
||||||
|
#include "SDL_events.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 "unicodestuff.h"
|
||||||
|
#include "atan2i.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
|
||||||
|
|
||||||
|
// This code is left here to rot - it's bad, complicated and needed by only one applicaiton
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
|
||||||
|
#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
|
||||||
|
extern SDL_Window * ANDROID_CurrentWindow;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
|
||||||
|
#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
|
||||||
|
#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum { MAX_BUFFERED_EVENTS = 64 };
|
||||||
|
static SDL_Event BufferedEvents[MAX_BUFFERED_EVENTS];
|
||||||
|
static int BufferedEventsStart = 0, BufferedEventsEnd = 0;
|
||||||
|
static SDL_mutex * BufferedEventsMutex = NULL;
|
||||||
|
|
||||||
|
/* We need our own event queue, because Free Heroes 2 game uses
|
||||||
|
* SDL_SetEventFilter(), and it calls SDL_Flip() from inside
|
||||||
|
* it's custom filter function, and SDL_Flip() does not work
|
||||||
|
* when it's not called from the main() thread.
|
||||||
|
* So we, like, push the events into our own queue,
|
||||||
|
* read each event from that queue inside SDL_ANDROID_PumpEvents(),
|
||||||
|
* unlock the mutex, and push the event to SDL queue,
|
||||||
|
* which is then immediately read by SDL from the same thread,
|
||||||
|
* and then SDL invokes event filter function from FHeroes2.
|
||||||
|
* FHeroes2 call SDL_Flip() from inside that event filter function,
|
||||||
|
* and it works, because it is called from the main() thread.
|
||||||
|
*/
|
||||||
|
extern void SDL_ANDROID_PumpEvents()
|
||||||
|
{
|
||||||
|
static int oldMouseButtons = 0;
|
||||||
|
SDL_Event ev;
|
||||||
|
SDL_ANDROID_processAndroidTrackballDampening();
|
||||||
|
SDL_ANDROID_processMoveMouseWithKeyboard();
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
SDL_Window * window = SDL_GetFocusWindow();
|
||||||
|
if( !window )
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( !BufferedEventsMutex )
|
||||||
|
BufferedEventsMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
SDL_mutexP(BufferedEventsMutex);
|
||||||
|
while( BufferedEventsStart != BufferedEventsEnd )
|
||||||
|
{
|
||||||
|
ev = BufferedEvents[BufferedEventsStart];
|
||||||
|
BufferedEvents[BufferedEventsStart].type = 0;
|
||||||
|
BufferedEventsStart++;
|
||||||
|
if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
|
||||||
|
BufferedEventsStart = 0;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
|
||||||
|
switch( ev.type )
|
||||||
|
{
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y );
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
|
||||||
|
{
|
||||||
|
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
|
||||||
|
SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
|
||||||
|
SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym );
|
||||||
|
break;
|
||||||
|
case SDL_JOYAXISMOTION:
|
||||||
|
if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] )
|
||||||
|
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value );
|
||||||
|
break;
|
||||||
|
case SDL_JOYBUTTONDOWN:
|
||||||
|
if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
|
||||||
|
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state );
|
||||||
|
break;
|
||||||
|
case SDL_JOYBALLMOTION:
|
||||||
|
if( ev.jball.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
|
||||||
|
SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[ev.jball.which], ev.jball.ball, ev.jball.xrel, ev.jball.yrel );
|
||||||
|
break;
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
//if( ANDROID_CurrentWindow )
|
||||||
|
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
||||||
|
#else
|
||||||
|
case SDL_ACTIVEEVENT:
|
||||||
|
SDL_PrivateAppActive(ev.active.gain, ev.active.state);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
case SDL_FINGERMOTION:
|
||||||
|
SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
|
||||||
|
break;
|
||||||
|
case SDL_FINGERDOWN:
|
||||||
|
SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
|
||||||
|
break;
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
SDL_SendKeyboardText(ev.text.text);
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEWHEEL:
|
||||||
|
SDL_SendMouseWheel( ANDROID_CurrentWindow, ev.wheel.x, ev.wheel.y );
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexP(BufferedEventsMutex);
|
||||||
|
}
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
// Queue events to main thread
|
||||||
|
static int getNextEventAndLock()
|
||||||
|
{
|
||||||
|
int nextEvent;
|
||||||
|
if( !BufferedEventsMutex )
|
||||||
|
return -1;
|
||||||
|
SDL_mutexP(BufferedEventsMutex);
|
||||||
|
nextEvent = BufferedEventsEnd;
|
||||||
|
nextEvent++;
|
||||||
|
if( nextEvent >= MAX_BUFFERED_EVENTS )
|
||||||
|
nextEvent = 0;
|
||||||
|
while( nextEvent == BufferedEventsStart )
|
||||||
|
{
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
if( SDL_ANDROID_InsideVideoThread() )
|
||||||
|
SDL_ANDROID_PumpEvents();
|
||||||
|
else
|
||||||
|
SDL_Delay(100);
|
||||||
|
SDL_mutexP(BufferedEventsMutex);
|
||||||
|
nextEvent = BufferedEventsEnd;
|
||||||
|
nextEvent++;
|
||||||
|
if( nextEvent >= MAX_BUFFERED_EVENTS )
|
||||||
|
nextEvent = 0;
|
||||||
|
}
|
||||||
|
return nextEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getPrevEventNoLock()
|
||||||
|
{
|
||||||
|
int prevEvent;
|
||||||
|
if(BufferedEventsStart == BufferedEventsEnd)
|
||||||
|
return -1;
|
||||||
|
prevEvent = BufferedEventsEnd;
|
||||||
|
prevEvent--;
|
||||||
|
if( prevEvent < 0 )
|
||||||
|
prevEvent = MAX_BUFFERED_EVENTS - 1;
|
||||||
|
return prevEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
|
||||||
|
{
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int prevEvent = getPrevEventNoLock();
|
||||||
|
if( prevEvent > 0 && BufferedEvents[prevEvent].type == SDL_MOUSEMOTION )
|
||||||
|
{
|
||||||
|
// Reuse previous mouse motion event, to prevent mouse movement lag
|
||||||
|
BufferedEvents[prevEvent].motion.x = x;
|
||||||
|
BufferedEvents[prevEvent].motion.y = y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
ev->type = SDL_MOUSEMOTION;
|
||||||
|
ev->motion.x = x;
|
||||||
|
ev->motion.y = y;
|
||||||
|
}
|
||||||
|
SDL_ANDROID_currentMouseX = x;
|
||||||
|
SDL_ANDROID_currentMouseY = y;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
|
||||||
|
{
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_MOUSEBUTTONDOWN;
|
||||||
|
ev->button.state = pressed;
|
||||||
|
ev->button.button = button;
|
||||||
|
|
||||||
|
if(pressed)
|
||||||
|
SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
|
||||||
|
else
|
||||||
|
SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||||
|
{
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
if( SDL_ANDROID_moveMouseWithArrowKeys && (
|
||||||
|
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
||||||
|
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbX < 0 )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
|
||||||
|
SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pressed )
|
||||||
|
{
|
||||||
|
if( key == SDL_KEY(LEFT) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||||
|
}
|
||||||
|
else if( key == SDL_KEY(RIGHT) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( key == SDL_KEY(UP) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||||
|
}
|
||||||
|
else if( key == SDL_KEY(DOWN) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
|
||||||
|
}
|
||||||
|
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
|
||||||
|
SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
|
||||||
|
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
|
||||||
|
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ev->type = SDL_KEYDOWN;
|
||||||
|
ev->key.state = pressed;
|
||||||
|
ev->key.keysym.scancode = key;
|
||||||
|
ev->key.keysym.sym = key;
|
||||||
|
ev->key.keysym.mod = KMOD_NONE;
|
||||||
|
ev->key.keysym.unicode = 0;
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
#else
|
||||||
|
if ( SDL_TranslateUNICODE )
|
||||||
|
#endif
|
||||||
|
ev->key.keysym.unicode = key;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_JOYAXISMOTION;
|
||||||
|
ev->jaxis.which = joy;
|
||||||
|
ev->jaxis.axis = axis;
|
||||||
|
ev->jaxis.value = MAX( -32768, MIN( 32767, value ) );
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_JOYBUTTONDOWN;
|
||||||
|
ev->jbutton.which = joy;
|
||||||
|
ev->jbutton.button = button;
|
||||||
|
ev->jbutton.state = pressed;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_JOYBALLMOTION;
|
||||||
|
ev->jball.which = joy;
|
||||||
|
ev->jball.ball = ball;
|
||||||
|
ev->jball.xrel = x;
|
||||||
|
ev->jball.yrel = y;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
}
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_FINGERDOWN;
|
||||||
|
ev->tfinger.fingerId = id;
|
||||||
|
ev->tfinger.state = pressed;
|
||||||
|
ev->tfinger.x = x;
|
||||||
|
ev->tfinger.y = y;
|
||||||
|
ev->tfinger.pressure = force;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_FINGERMOTION;
|
||||||
|
ev->tfinger.fingerId = id;
|
||||||
|
ev->tfinger.x = x;
|
||||||
|
ev->tfinger.y = y;
|
||||||
|
ev->tfinger.pressure = force;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_MOUSEWHEEL;
|
||||||
|
ev->wheel.x = x;
|
||||||
|
ev->wheel.y = y;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushAppActive(int active)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
//if( ANDROID_CurrentWindow )
|
||||||
|
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
||||||
|
#else
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
ev->type = SDL_ACTIVEEVENT;
|
||||||
|
ev->active.gain = active;
|
||||||
|
ev->active.state = SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS;
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
enum { DEFERRED_TEXT_COUNT = 256 };
|
||||||
|
static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
|
||||||
|
static int deferredTextIdx1 = 0;
|
||||||
|
static int deferredTextIdx2 = 0;
|
||||||
|
static SDL_mutex * deferredTextMutex = NULL;
|
||||||
|
|
||||||
|
void SDL_ANDROID_DeferredTextInput()
|
||||||
|
{
|
||||||
|
if( !deferredTextMutex )
|
||||||
|
deferredTextMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
SDL_mutexP(deferredTextMutex);
|
||||||
|
|
||||||
|
if( deferredTextIdx1 != deferredTextIdx2 )
|
||||||
|
{
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
{
|
||||||
|
SDL_mutexV(deferredTextMutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
deferredTextIdx1++;
|
||||||
|
if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx1 = 0;
|
||||||
|
|
||||||
|
ev->type = SDL_KEYDOWN;
|
||||||
|
ev->key.state = deferredText[deferredTextIdx1].down;
|
||||||
|
ev->key.keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
if( SDL_ANDROID_isMouseUsed )
|
||||||
|
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_TextInputFinished )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_TextInputFinished = 0;
|
||||||
|
SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexV(deferredTextMutex);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
|
||||||
|
{
|
||||||
|
int shiftRequired;
|
||||||
|
|
||||||
|
int nextEvent = getNextEventAndLock();
|
||||||
|
if( nextEvent == -1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
|
||||||
|
ev->type = SDL_TEXTINPUT;
|
||||||
|
UnicodeToUtf8(unicode, ev->text.text);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( !deferredTextMutex )
|
||||||
|
deferredTextMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
SDL_mutexP(deferredTextMutex);
|
||||||
|
|
||||||
|
ev->type = 0;
|
||||||
|
|
||||||
|
shiftRequired = checkShiftRequired(&ascii);
|
||||||
|
|
||||||
|
if( shiftRequired )
|
||||||
|
{
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_PRESSED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
}
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_PRESSED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = ascii;
|
||||||
|
deferredText[deferredTextIdx2].unicode = unicode;
|
||||||
|
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_RELEASED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = ascii;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
if( shiftRequired )
|
||||||
|
{
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_RELEASED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexV(deferredTextMutex);
|
||||||
|
|
||||||
|
BufferedEventsEnd = nextEvent;
|
||||||
|
SDL_mutexV(BufferedEventsMutex);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
/*
|
||||||
|
SDL - Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2009 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 <jni.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h> // for memset()
|
||||||
|
|
||||||
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
#include "SDL_version.h"
|
||||||
|
#include "SDL_mutex.h"
|
||||||
|
#include "SDL_events.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 "unicodestuff.h"
|
||||||
|
#include "atan2i.h"
|
||||||
|
|
||||||
|
#ifndef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
|
||||||
|
#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
|
||||||
|
extern SDL_Window * ANDROID_CurrentWindow;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
|
||||||
|
#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
|
||||||
|
#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static volatile int joystickEventsCount;
|
||||||
|
static int oldMouseButtons = 0;
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_PumpEvents()
|
||||||
|
{
|
||||||
|
joystickEventsCount = 0;
|
||||||
|
|
||||||
|
SDL_ANDROID_processAndroidTrackballDampening();
|
||||||
|
SDL_ANDROID_processMoveMouseWithKeyboard();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
|
||||||
|
{
|
||||||
|
SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y );
|
||||||
|
|
||||||
|
SDL_ANDROID_currentMouseX = x;
|
||||||
|
SDL_ANDROID_currentMouseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
|
||||||
|
{
|
||||||
|
if( ((oldMouseButtons & SDL_BUTTON(button)) != 0) != pressed )
|
||||||
|
{
|
||||||
|
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(button)) | (pressed ? SDL_BUTTON(button) : 0);
|
||||||
|
SDL_SendMouseButton( ANDROID_CurrentWindow, pressed, button );
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pressed)
|
||||||
|
SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
|
||||||
|
else
|
||||||
|
SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||||
|
{
|
||||||
|
SDL_keysym keysym;
|
||||||
|
|
||||||
|
if( SDL_ANDROID_moveMouseWithArrowKeys && (
|
||||||
|
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
||||||
|
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbX < 0 )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
|
||||||
|
SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pressed )
|
||||||
|
{
|
||||||
|
if( key == SDL_KEY(LEFT) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||||
|
}
|
||||||
|
else if( key == SDL_KEY(RIGHT) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( key == SDL_KEY(UP) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||||
|
}
|
||||||
|
else if( key == SDL_KEY(DOWN) )
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelX = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
|
||||||
|
}
|
||||||
|
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelY = 0;
|
||||||
|
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
|
||||||
|
SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
|
||||||
|
|
||||||
|
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
keysym.scancode = key;
|
||||||
|
keysym.sym = key;
|
||||||
|
keysym.mod = KMOD_NONE;
|
||||||
|
keysym.unicode = 0;
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
#else
|
||||||
|
if ( SDL_TranslateUNICODE )
|
||||||
|
#endif
|
||||||
|
keysym.unicode = key;
|
||||||
|
|
||||||
|
if( pressed == SDL_RELEASED )
|
||||||
|
keysym.unicode = 0;
|
||||||
|
|
||||||
|
SDL_SendKeyboardKey( pressed, &keysym );
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( joystickEventsCount > 64 )
|
||||||
|
{
|
||||||
|
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "Too many joystick events in the queue - dropping some events");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
joystickEventsCount++;
|
||||||
|
|
||||||
|
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[joy], axis, MAX( -32768, MIN( 32767, value ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[joy], button, pressed );
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
|
||||||
|
{
|
||||||
|
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[joy], ball, x, y );
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
SDL_SendFingerDown(0, id, pressed ? 1 : 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
SDL_SendTouchMotion(0, id, 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
SDL_SendMouseWheel( ANDROID_CurrentWindow, x, y );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushAppActive(int active)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
//if( ANDROID_CurrentWindow )
|
||||||
|
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
||||||
|
#else
|
||||||
|
SDL_PrivateAppActive(active, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
enum { DEFERRED_TEXT_COUNT = 256 };
|
||||||
|
static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
|
||||||
|
static int deferredTextIdx1 = 0;
|
||||||
|
static int deferredTextIdx2 = 0;
|
||||||
|
static SDL_mutex * deferredTextMutex = NULL;
|
||||||
|
|
||||||
|
void SDL_ANDROID_DeferredTextInput()
|
||||||
|
{
|
||||||
|
if( !deferredTextMutex )
|
||||||
|
deferredTextMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
SDL_mutexP(deferredTextMutex);
|
||||||
|
|
||||||
|
if( deferredTextIdx1 != deferredTextIdx2 )
|
||||||
|
{
|
||||||
|
SDL_keysym keysym;
|
||||||
|
|
||||||
|
deferredTextIdx1++;
|
||||||
|
if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx1 = 0;
|
||||||
|
|
||||||
|
keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
|
||||||
|
if( deferredText[deferredTextIdx1].down == SDL_RELEASED )
|
||||||
|
keysym.unicode = 0;
|
||||||
|
|
||||||
|
SDL_SendKeyboardKey( deferredText[deferredTextIdx1].down, &keysym );
|
||||||
|
|
||||||
|
if( SDL_ANDROID_isMouseUsed )
|
||||||
|
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( SDL_ANDROID_TextInputFinished )
|
||||||
|
{
|
||||||
|
SDL_ANDROID_TextInputFinished = 0;
|
||||||
|
SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexV(deferredTextMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
|
||||||
|
{
|
||||||
|
int shiftRequired;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
{
|
||||||
|
char text[32];
|
||||||
|
UnicodeToUtf8(unicode, text);
|
||||||
|
SDL_SendKeyboardText(text);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( !deferredTextMutex )
|
||||||
|
deferredTextMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
SDL_mutexP(deferredTextMutex);
|
||||||
|
|
||||||
|
shiftRequired = checkShiftRequired(&ascii);
|
||||||
|
|
||||||
|
if( shiftRequired )
|
||||||
|
{
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_PRESSED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
}
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_PRESSED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = ascii;
|
||||||
|
deferredText[deferredTextIdx2].unicode = unicode;
|
||||||
|
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_RELEASED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = ascii;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
if( shiftRequired )
|
||||||
|
{
|
||||||
|
deferredTextIdx2++;
|
||||||
|
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
|
||||||
|
deferredTextIdx2 = 0;
|
||||||
|
deferredText[deferredTextIdx2].down = SDL_RELEASED;
|
||||||
|
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
|
||||||
|
deferredText[deferredTextIdx2].unicode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexV(deferredTextMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -203,4 +203,18 @@ extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode );
|
|||||||
extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap);
|
extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap);
|
||||||
extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only
|
extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only
|
||||||
extern void SDL_ANDROID_MainThreadPushAppActive(int active);
|
extern void SDL_ANDROID_MainThreadPushAppActive(int active);
|
||||||
|
|
||||||
|
// Internal input queue stuff
|
||||||
|
extern SDLKey SDL_android_keymap[];
|
||||||
|
extern SDL_Joystick *SDL_ANDROID_CurrentJoysticks[];
|
||||||
|
extern int SDL_ANDROID_isMouseUsed;
|
||||||
|
extern int SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY, SDL_ANDROID_currentMouseButtons;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithArrowKeys;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbSpeed;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbAccel;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbSpeedX, SDL_ANDROID_moveMouseWithKbSpeedY;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbAccelX, SDL_ANDROID_moveMouseWithKbAccelY;
|
||||||
|
extern int SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -910,10 +910,9 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
|
|||||||
// Do it old-fashioned way with direct GL calls
|
// Do it old-fashioned way with direct GL calls
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrthox( 0, SDL_ANDROID_sFakeWindowWidth * 0x10000, SDL_ANDROID_sFakeWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
|
glOrthof( 0.0f, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight, 0.0f, 0.0f, 1.0f );
|
||||||
glColor4x(0, 0, 0, 0x10000);
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glColor4x(0, 0, 0, 0x10000);
|
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
GLshort vertices[] = { frame.x, frame.y,
|
GLshort vertices[] = { frame.x, frame.y,
|
||||||
frame.x + frame.w, frame.y,
|
frame.x + frame.w, frame.y,
|
||||||
frame.x + frame.w, frame.y + frame.h,
|
frame.x + frame.w, frame.y + frame.h,
|
||||||
@@ -991,7 +990,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
|
|||||||
SDL_GetMouseState(&x, &y);
|
SDL_GetMouseState(&x, &y);
|
||||||
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
|
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
|
||||||
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
|
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
|
||||||
SDL_ANDROID_DrawMouseCursor( x, y, 0, 255 );
|
SDL_ANDROID_DrawMouseCursor( x, y, 0, 1.0f );
|
||||||
}
|
}
|
||||||
if( SDL_ANDROID_ShowScreenUnderFinger != ZOOM_NONE )
|
if( SDL_ANDROID_ShowScreenUnderFinger != ZOOM_NONE )
|
||||||
{
|
{
|
||||||
@@ -1005,7 +1004,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
|
|||||||
SDL_ANDROID_ShowScreenUnderFingerRect.h / SDL_ANDROID_ShowScreenUnderFingerRectSrc.h;
|
SDL_ANDROID_ShowScreenUnderFingerRect.h / SDL_ANDROID_ShowScreenUnderFingerRectSrc.h;
|
||||||
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
|
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
|
||||||
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
|
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
|
||||||
SDL_ANDROID_DrawMouseCursor( x, y, 16, 255 );
|
SDL_ANDROID_DrawMouseCursor( x, y, 16, 1.0f );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ static jmethodID JavaShowScreenKeyboard = NULL;
|
|||||||
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
|
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
|
||||||
static jmethodID JavaHideScreenKeyboard = NULL;
|
static jmethodID JavaHideScreenKeyboard = NULL;
|
||||||
static jmethodID JavaIsScreenKeyboardShown = NULL;
|
static jmethodID JavaIsScreenKeyboardShown = NULL;
|
||||||
|
static jmethodID JavaStartAccelerometerGyroscope = NULL;
|
||||||
static jmethodID JavaGetAdvertisementParams = NULL;
|
static jmethodID JavaGetAdvertisementParams = NULL;
|
||||||
static jmethodID JavaSetAdvertisementVisible = NULL;
|
static jmethodID JavaSetAdvertisementVisible = NULL;
|
||||||
static jmethodID JavaSetAdvertisementPosition = NULL;
|
static jmethodID JavaSetAdvertisementPosition = NULL;
|
||||||
@@ -110,8 +111,8 @@ int SDL_ANDROID_CallJavaSwapBuffers()
|
|||||||
{
|
{
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrthox( 0, (SDL_ANDROID_sRealWindowWidth) * 0x10000, SDL_ANDROID_sRealWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
|
glOrthof( 0.0f, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0.0f, 0.0f, 1.0f );
|
||||||
glColor4x(0, 0, 0, 0x10000);
|
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y,
|
GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y,
|
||||||
@@ -297,6 +298,11 @@ int SDL_ANDROID_IsScreenKeyboardShown()
|
|||||||
return SDL_ANDROID_IsScreenKeyboardShownFlag;
|
return SDL_ANDROID_IsScreenKeyboardShownFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start)
|
||||||
|
{
|
||||||
|
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaStartAccelerometerGyroscope, (jint) start );
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
|
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
|
||||||
{
|
{
|
||||||
@@ -309,7 +315,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
|
|||||||
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
|
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
|
||||||
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
|
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
|
||||||
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
|
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
|
||||||
// TODO: implement it
|
JavaStartAccelerometerGyroscope = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "startAccelerometerGyroscope", "(I)V");
|
||||||
|
|
||||||
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
|
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
|
||||||
JavaSetAdvertisementVisible = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementVisible", "(I)V");
|
JavaSetAdvertisementVisible = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementVisible", "(I)V");
|
||||||
JavaSetAdvertisementPosition = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementPosition", "(II)V");
|
JavaSetAdvertisementPosition = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementPosition", "(II)V");
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ extern void SDL_ANDROID_initFakeStdout();
|
|||||||
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
|
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
|
||||||
extern void SDL_ANDROID_ProcessDeferredEvents();
|
extern void SDL_ANDROID_ProcessDeferredEvents();
|
||||||
extern void SDL_ANDROID_WarpMouse(int x, int y);
|
extern void SDL_ANDROID_WarpMouse(int x, int y);
|
||||||
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha);
|
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha);
|
||||||
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
|
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
|
||||||
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
||||||
|
extern void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start);
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
extern SDL_Window * ANDROID_CurrentWindow;
|
extern SDL_Window * ANDROID_CurrentWindow;
|
||||||
|
|||||||
@@ -40,14 +40,10 @@
|
|||||||
#include "SDL_androidvideo.h"
|
#include "SDL_androidvideo.h"
|
||||||
#include "SDL_androidinput.h"
|
#include "SDL_androidinput.h"
|
||||||
#include "jniwrapperstuff.h"
|
#include "jniwrapperstuff.h"
|
||||||
|
#include "atan2i.h"
|
||||||
// #include "touchscreentheme.h" // Not used yet
|
|
||||||
|
|
||||||
// TODO: this code is a HUGE MESS
|
// TODO: this code is a HUGE MESS
|
||||||
|
|
||||||
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
|
|
||||||
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
|
||||||
|
|
||||||
enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = MAX_BUTTONS } ; // Max amount of custom buttons
|
enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = MAX_BUTTONS } ; // Max amount of custom buttons
|
||||||
|
|
||||||
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
|
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
|
||||||
@@ -56,7 +52,7 @@ static short touchscreenKeyboardShown = 1;
|
|||||||
static short AutoFireButtonsNum = 0;
|
static short AutoFireButtonsNum = 0;
|
||||||
static short buttonsize = 1;
|
static short buttonsize = 1;
|
||||||
static short buttonDrawSize = 1;
|
static short buttonDrawSize = 1;
|
||||||
static short transparency = 128;
|
static float transparency = 128.0f/255.0f;
|
||||||
|
|
||||||
static SDL_Rect arrows, arrowsExtended, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE];
|
static SDL_Rect arrows, arrowsExtended, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE];
|
||||||
static SDL_Rect arrowsDraw, buttonsDraw[MAX_BUTTONS];
|
static SDL_Rect arrowsDraw, buttonsDraw[MAX_BUTTONS];
|
||||||
@@ -118,16 +114,30 @@ oldGlState;
|
|||||||
|
|
||||||
static inline void beginDrawingTex()
|
static inline void beginDrawingTex()
|
||||||
{
|
{
|
||||||
|
#ifndef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
|
||||||
|
// Make the video somehow work on emulator
|
||||||
|
oldGlState.texture2d = GL_TRUE;
|
||||||
|
oldGlState.texunitId = GL_TEXTURE0;
|
||||||
|
oldGlState.clientTexunitId = GL_TEXTURE0;
|
||||||
|
oldGlState.textureId = 0;
|
||||||
|
oldGlState.texEnvMode = GL_MODULATE;
|
||||||
|
oldGlState.blend = GL_TRUE;
|
||||||
|
oldGlState.blend1 = GL_SRC_ALPHA;
|
||||||
|
oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
|
oldGlState.colorArray = GL_FALSE;
|
||||||
|
#else
|
||||||
// Save OpenGL state
|
// Save OpenGL state
|
||||||
glGetError(); // Clear error flag
|
|
||||||
// This code does not work on 1.6 emulator, and on some older devices
|
// This code does not work on 1.6 emulator, and on some older devices
|
||||||
// However GLES 1.1 spec defines all theese values, so it's a device fault for not implementing them
|
// However GLES 1.1 spec defines all theese values, so it's a device fault for not implementing them
|
||||||
oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D);
|
oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D);
|
||||||
glGetIntegerv(GL_ACTIVE_TEXTURE, &oldGlState.texunitId);
|
glGetIntegerv(GL_ACTIVE_TEXTURE, &oldGlState.texunitId);
|
||||||
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &oldGlState.clientTexunitId);
|
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &oldGlState.clientTexunitId);
|
||||||
|
#endif
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
#ifdef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId);
|
||||||
glGetFloatv(GL_CURRENT_COLOR, &(oldGlState.color[0]));
|
glGetFloatv(GL_CURRENT_COLOR, &(oldGlState.color[0]));
|
||||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldGlState.texEnvMode);
|
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldGlState.texEnvMode);
|
||||||
@@ -136,19 +146,7 @@ static inline void beginDrawingTex()
|
|||||||
glGetIntegerv(GL_BLEND_DST, &oldGlState.blend2);
|
glGetIntegerv(GL_BLEND_DST, &oldGlState.blend2);
|
||||||
glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray);
|
glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray);
|
||||||
// It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it
|
// It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it
|
||||||
if( glGetError() != GL_NO_ERROR )
|
#endif
|
||||||
{
|
|
||||||
// Make the video somehow work on emulator
|
|
||||||
oldGlState.texture2d = GL_FALSE;
|
|
||||||
oldGlState.texunitId = GL_TEXTURE0;
|
|
||||||
oldGlState.clientTexunitId = GL_TEXTURE0;
|
|
||||||
oldGlState.textureId = 0;
|
|
||||||
oldGlState.texEnvMode = GL_MODULATE;
|
|
||||||
oldGlState.blend = GL_FALSE;
|
|
||||||
oldGlState.blend1 = GL_SRC_ALPHA;
|
|
||||||
oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
|
|
||||||
oldGlState.colorArray = GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
@@ -164,7 +162,7 @@ static inline void endDrawingTex()
|
|||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, oldGlState.textureId);
|
glBindTexture(GL_TEXTURE_2D, oldGlState.textureId);
|
||||||
glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]);
|
glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
|
||||||
if( oldGlState.blend == GL_FALSE )
|
if( oldGlState.blend == GL_FALSE )
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glBlendFunc(oldGlState.blend1, oldGlState.blend2);
|
glBlendFunc(oldGlState.blend1, oldGlState.blend2);
|
||||||
@@ -174,7 +172,7 @@ static inline void endDrawingTex()
|
|||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
GLint cropRect[4];
|
GLint cropRect[4];
|
||||||
|
|
||||||
@@ -183,7 +181,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex->id);
|
glBindTexture(GL_TEXTURE_2D, tex->id);
|
||||||
|
|
||||||
glColor4x(r * 0x100, g * 0x100, b * 0x100, a * 0x100 );
|
glColor4f(r, g, b, a);
|
||||||
|
|
||||||
if(src)
|
if(src)
|
||||||
{
|
{
|
||||||
@@ -213,7 +211,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
|
|||||||
glDrawTexiOES(dest->x, SDL_ANDROID_sWindowHeight - dest->y - dest->h, 0, dest->w, dest->h);
|
glDrawTexiOES(dest->x, SDL_ANDROID_sWindowHeight - dest->y - dest->h, 0, dest->w, dest->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
drawCharTexFlip(tex, src, dest, 0, 0, r, g, b, a);
|
drawCharTexFlip(tex, src, dest, 0, 0, r, g, b, a);
|
||||||
}
|
}
|
||||||
@@ -221,24 +219,24 @@ static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * des
|
|||||||
static void drawTouchscreenKeyboardLegacy()
|
static void drawTouchscreenKeyboardLegacy()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int blendFactor;
|
float blendFactor;
|
||||||
|
|
||||||
blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) +
|
blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) +
|
||||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
|
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
|
||||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
|
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
|
||||||
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
|
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
|
||||||
if( blendFactor == 0 )
|
if( blendFactor == 0 )
|
||||||
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
|
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
|
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
|
||||||
drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
|
||||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
|
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
|
||||||
drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
|
||||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
|
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
|
||||||
drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
|
||||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
|
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
|
||||||
drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < MAX_BUTTONS; i++ )
|
for( i = 0; i < MAX_BUTTONS; i++ )
|
||||||
@@ -274,7 +272,7 @@ static void drawTouchscreenKeyboardLegacy()
|
|||||||
autoFireDest.w = pos1dst;
|
autoFireDest.w = pos1dst;
|
||||||
|
|
||||||
drawCharTex( &buttonImages[i*2+1],
|
drawCharTex( &buttonImages[i*2+1],
|
||||||
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
|
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
|
|
||||||
autoFireCrop.x = pos2src;
|
autoFireCrop.x = pos2src;
|
||||||
autoFireCrop.w = buttonImages[i*2+1].w - pos2src;
|
autoFireCrop.w = buttonImages[i*2+1].w - pos2src;
|
||||||
@@ -282,7 +280,7 @@ static void drawTouchscreenKeyboardLegacy()
|
|||||||
autoFireDest.w = buttonsDraw[i].w - pos2dst;
|
autoFireDest.w = buttonsDraw[i].w - pos2dst;
|
||||||
|
|
||||||
drawCharTex( &buttonImages[i*2+1],
|
drawCharTex( &buttonImages[i*2+1],
|
||||||
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
|
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
|
|
||||||
autoFireCrop.x = pos1src;
|
autoFireCrop.x = pos1src;
|
||||||
autoFireCrop.w = pos2src - pos1src;
|
autoFireCrop.w = pos2src - pos1src;
|
||||||
@@ -290,13 +288,13 @@ static void drawTouchscreenKeyboardLegacy()
|
|||||||
autoFireDest.w = pos2dst - pos1dst;
|
autoFireDest.w = pos2dst - pos1dst;
|
||||||
|
|
||||||
drawCharTex( &buttonAutoFireImages[i*2+1],
|
drawCharTex( &buttonAutoFireImages[i*2+1],
|
||||||
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
|
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] :
|
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] :
|
||||||
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ],
|
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ],
|
||||||
NULL, &buttonsDraw[i], 255, 255, 255, transparency );
|
NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,7 +303,7 @@ static void drawTouchscreenKeyboardSun()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
|
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
if(pointerInButtonRect[BUTTON_ARROWS] != -1)
|
if(pointerInButtonRect[BUTTON_ARROWS] != -1)
|
||||||
{
|
{
|
||||||
SDL_Rect touch = arrowsDraw;
|
SDL_Rect touch = arrowsDraw;
|
||||||
@@ -313,7 +311,7 @@ static void drawTouchscreenKeyboardSun()
|
|||||||
touch.h /= 2;
|
touch.h /= 2;
|
||||||
touch.x = joystickTouchPoints[0] - touch.w / 2;
|
touch.x = joystickTouchPoints[0] - touch.w / 2;
|
||||||
touch.y = joystickTouchPoints[1] - touch.h / 2;
|
touch.y = joystickTouchPoints[1] - touch.h / 2;
|
||||||
drawCharTex( &arrowImages[0], NULL, &touch, 255, 255, 255, transparency );
|
drawCharTex( &arrowImages[0], NULL, &touch, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < MAX_BUTTONS; i++ )
|
for( i = 0; i < MAX_BUTTONS; i++ )
|
||||||
@@ -339,10 +337,10 @@ static void drawTouchscreenKeyboardSun()
|
|||||||
|
|
||||||
if( i < AutoFireButtonsNum && ButtonAutoFire[i] )
|
if( i < AutoFireButtonsNum && ButtonAutoFire[i] )
|
||||||
drawCharTex( &buttonAutoFireImages[i*2+1],
|
drawCharTex( &buttonAutoFireImages[i*2+1],
|
||||||
NULL, &buttonsDraw[i], 255, 255, 255, transparency );
|
NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
|
||||||
|
|
||||||
drawCharTexFlip( &buttonImages[ pressed ? (i * 2 + 1) : (i * 2) ],
|
drawCharTexFlip( &buttonImages[ pressed ? (i * 2 + 1) : (i * 2) ],
|
||||||
NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 255, 255, 255, transparency );
|
NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
|
|
||||||
if( i < AutoFireButtonsNum && ! ButtonAutoFire[i] &&
|
if( i < AutoFireButtonsNum && ! ButtonAutoFire[i] &&
|
||||||
( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) )
|
( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) )
|
||||||
@@ -359,7 +357,7 @@ static void drawTouchscreenKeyboardSun()
|
|||||||
autoFireDest.y = buttonsDraw[i].y + buttonsDraw[i].h/2 - autoFireDest.h/2;
|
autoFireDest.y = buttonsDraw[i].y + buttonsDraw[i].h/2 - autoFireDest.h/2;
|
||||||
|
|
||||||
drawCharTex( &buttonAutoFireImages[i*2],
|
drawCharTex( &buttonAutoFireImages[i*2],
|
||||||
NULL, &autoFireDest, 255, 255, 255, transparency );
|
NULL, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -700,12 +698,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
|
|||||||
buttonDrawSize = drawsize;
|
buttonDrawSize = drawsize;
|
||||||
switch(_transparency)
|
switch(_transparency)
|
||||||
{
|
{
|
||||||
case 0: transparency = 32; break;
|
case 0: transparency = 32.0f/255.0f; break;
|
||||||
case 1: transparency = 64; break;
|
case 1: transparency = 64.0f/255.0f; break;
|
||||||
case 2: transparency = 128; break;
|
case 2: transparency = 128.0f/255.0f; break;
|
||||||
case 3: transparency = 192; break;
|
case 3: transparency = 192.0f/255.0f; break;
|
||||||
case 4: transparency = 255; break;
|
case 4: transparency = 255.0f/255.0f; break;
|
||||||
default: transparency = 192; break;
|
default: transparency = 192.0f/255.0f; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arrows to the lower-left part of screen
|
// Arrows to the lower-left part of screen
|
||||||
@@ -778,16 +776,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetTouchscreenKeyboardUsed) ( JNIEnv* env, jobj
|
|||||||
SDL_ANDROID_isTouchscreenKeyboardUsed = 1;
|
SDL_ANDROID_isTouchscreenKeyboardUsed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha)
|
void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
// I've failed with size calcualtions, so leaving it as-is
|
// I've failed with size calculations, so leaving it as-is
|
||||||
r.x = x - MOUSE_POINTER_X;
|
r.x = x - MOUSE_POINTER_X;
|
||||||
r.y = y - MOUSE_POINTER_Y;
|
r.y = y - MOUSE_POINTER_Y;
|
||||||
r.w = MOUSE_POINTER_W;
|
r.w = MOUSE_POINTER_W;
|
||||||
r.h = MOUSE_POINTER_H;
|
r.h = MOUSE_POINTER_H;
|
||||||
beginDrawingTex();
|
beginDrawingTex();
|
||||||
drawCharTex( &mousePointer, NULL, &r, 255, 255, 255, alpha );
|
drawCharTex( &mousePointer, NULL, &r, 1.0f, 1.0f, 1.0f, alpha );
|
||||||
endDrawingTex();
|
endDrawingTex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,4 +30,7 @@ static inline int atan2i(int y, int x)
|
|||||||
return(angle);
|
return(angle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
|
||||||
|
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -130,18 +130,18 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
|
|||||||
keymap[KEYCODE_PAGE_DOWN] = SDL_KEY(PAGEDOWN);
|
keymap[KEYCODE_PAGE_DOWN] = SDL_KEY(PAGEDOWN);
|
||||||
keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT);
|
keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT);
|
||||||
keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT);
|
keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT);
|
||||||
keymap[KEYCODE_BUTTON_A] = SDL_KEY(A);
|
keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
|
||||||
keymap[KEYCODE_BUTTON_B] = SDL_KEY(B);
|
keymap[KEYCODE_BUTTON_B] = SDL_KEY(ESCAPE); // SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); // There's no Back key on Ouya
|
||||||
keymap[KEYCODE_BUTTON_C] = SDL_KEY(C);
|
keymap[KEYCODE_BUTTON_C] = SDL_KEY(C);
|
||||||
keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0));
|
keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0));
|
||||||
keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1));
|
keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1));
|
||||||
keymap[KEYCODE_BUTTON_Z] = SDL_KEY(Z);
|
keymap[KEYCODE_BUTTON_Z] = SDL_KEY(Z);
|
||||||
keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
|
keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_5));
|
||||||
keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3));
|
keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_4));
|
||||||
keymap[KEYCODE_BUTTON_L2] = SDL_KEY(LCTRL);
|
keymap[KEYCODE_BUTTON_L2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0));
|
||||||
keymap[KEYCODE_BUTTON_R2] = SDL_KEY(RCTRL);
|
keymap[KEYCODE_BUTTON_R2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_6));
|
||||||
keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(LALT);
|
keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
|
||||||
keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(RALT);
|
keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_4));
|
||||||
keymap[KEYCODE_BUTTON_START] = SDL_KEY(RETURN);
|
keymap[KEYCODE_BUTTON_START] = SDL_KEY(RETURN);
|
||||||
keymap[KEYCODE_BUTTON_SELECT] = SDL_KEY(ESCAPE);
|
keymap[KEYCODE_BUTTON_SELECT] = SDL_KEY(ESCAPE);
|
||||||
keymap[KEYCODE_BUTTON_MODE] = SDL_KEY(SPACE);
|
keymap[KEYCODE_BUTTON_MODE] = SDL_KEY(SPACE);
|
||||||
|
|||||||
86
project/jni/sdl-1.2/src/video/android/unicodestuff.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#ifndef _UNICODE_STUFF_H_
|
||||||
|
#define _UNICODE_STUFF_H_
|
||||||
|
|
||||||
|
#include "SDL_androidinput.h"
|
||||||
|
|
||||||
|
// I'm too lazy to move code into .c file
|
||||||
|
|
||||||
|
static inline int UnicodeToUtf8(int src, char * dest)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
if ( src <= 0x007f) {
|
||||||
|
*dest++ = (char)src;
|
||||||
|
len = 1;
|
||||||
|
} else if (src <= 0x07ff) {
|
||||||
|
*dest++ = (char)0xc0 | (src >> 6);
|
||||||
|
*dest++ = (char)0x80 | (src & 0x003f);
|
||||||
|
len = 2;
|
||||||
|
} else if (src == 0xFEFF) {
|
||||||
|
// nop -- zap the BOM
|
||||||
|
} else if (src >= 0xD800 && src <= 0xDFFF) {
|
||||||
|
// surrogates not supported
|
||||||
|
} else if (src <= 0xffff) {
|
||||||
|
*dest++ = (char)0xe0 | (src >> 12);
|
||||||
|
*dest++ = (char)0x80 | ((src >> 6) & 0x003f);
|
||||||
|
*dest++ = (char)0x80 | (src & 0x003f);
|
||||||
|
len = 3;
|
||||||
|
} else if (src <= 0xffff) {
|
||||||
|
*dest++ = (char)0xf0 | (src >> 18);
|
||||||
|
*dest++ = (char)0x80 | ((src >> 12) & 0x3f);
|
||||||
|
*dest++ = (char)0x80 | ((src >> 6) & 0x3f);
|
||||||
|
*dest++ = (char)0x80 | (src & 0x3f);
|
||||||
|
len = 4;
|
||||||
|
} else {
|
||||||
|
// out of Unicode range
|
||||||
|
}
|
||||||
|
*dest = 0;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline SDL_keysym asciiToKeysym(int ascii, int unicode)
|
||||||
|
{
|
||||||
|
SDL_keysym keysym;
|
||||||
|
keysym.scancode = ascii;
|
||||||
|
keysym.sym = ascii;
|
||||||
|
keysym.mod = KMOD_NONE;
|
||||||
|
keysym.unicode = 0;
|
||||||
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
keysym.sym = SDL_GetScancodeFromKey(ascii);
|
||||||
|
#else
|
||||||
|
if ( SDL_TranslateUNICODE )
|
||||||
|
#endif
|
||||||
|
keysym.unicode = unicode;
|
||||||
|
return keysym;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int checkShiftRequired( int * sym )
|
||||||
|
{
|
||||||
|
switch( *sym )
|
||||||
|
{
|
||||||
|
case '!': *sym = '1'; return 1;
|
||||||
|
case '@': *sym = '2'; return 1;
|
||||||
|
case '#': *sym = '3'; return 1;
|
||||||
|
case '$': *sym = '4'; return 1;
|
||||||
|
case '%': *sym = '5'; return 1;
|
||||||
|
case '^': *sym = '6'; return 1;
|
||||||
|
case '&': *sym = '7'; return 1;
|
||||||
|
case '*': *sym = '8'; return 1;
|
||||||
|
case '(': *sym = '9'; return 1;
|
||||||
|
case ')': *sym = '0'; return 1;
|
||||||
|
case '_': *sym = '-'; return 1;
|
||||||
|
case '+': *sym = '='; return 1;
|
||||||
|
case '|': *sym = '\\';return 1;
|
||||||
|
case '<': *sym = ','; return 1;
|
||||||
|
case '>': *sym = '.'; return 1;
|
||||||
|
case '?': *sym = '/'; return 1;
|
||||||
|
case ':': *sym = ';'; return 1;
|
||||||
|
case '"': *sym = '\'';return 1;
|
||||||
|
case '{': *sym = '['; return 1;
|
||||||
|
case '}': *sym = ']'; return 1;
|
||||||
|
case '~': *sym = '`'; return 1;
|
||||||
|
default: if( *sym >= 'A' && *sym <= 'Z' ) { *sym += 'a' - 'A'; return 1; };
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-15
|
target=android-17
|
||||||
|
|||||||
1
project/res/drawable-xhdpi/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ouya_icon.png
|
||||||
1
project/res/drawable/ouya_icon.png
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
icon.png
|
||||||
BIN
project/res/drawable/rectangle.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
project/res/drawable/sun_b1.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
project/res/drawable/sun_b2.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
project/res/drawable/sun_b3.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
project/res/drawable/sun_b4.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
project/res/drawable/sun_b5.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
project/res/drawable/sun_b6.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
project/res/drawable/sun_dpad.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
project/res/drawable/sun_keyboard.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
21
readme.txt
@@ -10,10 +10,10 @@ Also this port is developed very slowly, although the same is true for an offici
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
This project should be compiled with Android 3.1 SDK (API level 15) and NDK r8, r7c, r6 or r5c,
|
This project should be compiled with Android 4.2 SDK (API level 17) and NDK r8, r7c, r6 or r5c,
|
||||||
google for them and install them as described in their docs.
|
google for them and install them as described in their docs.
|
||||||
You'll need to install Java Ant too.
|
You'll need to install Java Ant too.
|
||||||
The application will run on Android OS 1.6 and above, don't mind the 3.1 dependency.
|
The application will run on Android OS 1.6 and above, but will use features from Android 4.2 if available.
|
||||||
Also it's compatible with NDK r4b and all versions of CrystaX NDK starting from r4b.
|
Also it's compatible with NDK r4b and all versions of CrystaX NDK starting from r4b.
|
||||||
CrystaX NDK adds support for wide chars, and required if you want to use Boost libraries.
|
CrystaX NDK adds support for wide chars, and required if you want to use Boost libraries.
|
||||||
http://www.crystax.net/android/ndk.php
|
http://www.crystax.net/android/ndk.php
|
||||||
@@ -120,8 +120,21 @@ Also make sure that your HW textures are not wider than 1024 pixels, or it will
|
|||||||
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
|
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
|
||||||
|
|
||||||
If you want HW acceleration - just use OpenGL, that's the easiest and most cross-platform way,
|
If you want HW acceleration - just use OpenGL, that's the easiest and most cross-platform way,
|
||||||
however note that on-screen keyboard (even the text input button) is also drawn using OpenGL,
|
however if you'll use on-screen keyboard (even the text input button) the OpenGL state will get
|
||||||
so it might mess up your GL state (although it should not do that due to recent code changes).
|
messed up after each frame - after each SDL_GL_SwapBuffers() you'll need to restore following GL state:
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, your_texture_id);
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
|
Previously I've got the code to save/restore OpenGL state, but it doens't work on every device -
|
||||||
|
you may wish to uncomment it inside file SDL_touchscreenkeyboard.c in functions beginDrawingTex() and endDrawingTex().
|
||||||
|
|
||||||
If you don't use on-screen keyboard you don't need to reinit OpenGL state - set following in AndroidAppSettings.cfg:
|
If you don't use on-screen keyboard you don't need to reinit OpenGL state - set following in AndroidAppSettings.cfg:
|
||||||
AppNeedsArrowKeys=n
|
AppNeedsArrowKeys=n
|
||||||
|
|||||||
26
todo.txt
@@ -1,2 +1,24 @@
|
|||||||
I'm not planning any more games to port, or any development on this SDL port.
|
Requested features (see also bugs.txt)
|
||||||
See bugs.txt if you want to contribute.
|
======================================
|
||||||
|
|
||||||
|
- Option for default on-screen key theme in AndroidAppSettings.cfg.
|
||||||
|
|
||||||
|
- Select between normal mouse input and magnifying glass/relative input automatically, based on screen size.
|
||||||
|
|
||||||
|
- Split Settings.java into several files.
|
||||||
|
|
||||||
|
- Show/hide screen controls with longpress on Text Edit button.
|
||||||
|
|
||||||
|
- Floating on-screen joystick - initially invisible, it appears when you touch the screen,
|
||||||
|
centered on your finger, then it slides with your finger if you bump the joystick edge.
|
||||||
|
|
||||||
|
- Export phone vibrator to SDL - interface is available in SDL 1.3.
|
||||||
|
|
||||||
|
- Control screen brightness with SDL_SetGamma().
|
||||||
|
|
||||||
|
- Zoom in-out whole screen in SW mode with some SDL key or gesture, as in AndroidVNC. -
|
||||||
|
|
||||||
|
- Support of libjnigraphics (it will disable on-screen keyboard, only SW SDL screen surface supported).
|
||||||
|
This is not relevant already, as every device around is fast enough with GL.
|
||||||
|
|
||||||
|
- Second joystick, to be used in TeeWorlds.
|
||||||