From 5e2db336041e331649cdb17d69a74f69b27a8b98 Mon Sep 17 00:00:00 2001 From: pelya Date: Sat, 1 Jun 2013 18:20:45 +0300 Subject: [PATCH] UQM: moved UI elements out of screen buttons --- .../commandergenius/commandergenius | 2 +- .../application/uqm-hd/AndroidAppSettings.cfg | 10 +- project/jni/application/uqm-hd/android.diff | 2300 +++++++------- .../application/uqm/AndroidAppSettings.cfg | 2 +- project/jni/application/uqm/android.diff | 2705 +++++++++-------- 5 files changed, 2644 insertions(+), 2375 deletions(-) diff --git a/project/jni/application/commandergenius/commandergenius b/project/jni/application/commandergenius/commandergenius index cdd8564eb..6f28771d5 160000 --- a/project/jni/application/commandergenius/commandergenius +++ b/project/jni/application/commandergenius/commandergenius @@ -1 +1 @@ -Subproject commit cdd8564ebdd26b6c733bad120a8df44e11edc041 +Subproject commit 6f28771d57ca7d878e3cfee08014651b854b9c7f diff --git a/project/jni/application/uqm-hd/AndroidAppSettings.cfg b/project/jni/application/uqm-hd/AndroidAppSettings.cfg index bd3d4889a..b945c6bab 100644 --- a/project/jni/application/uqm-hd/AndroidAppSettings.cfg +++ b/project/jni/application/uqm-hd/AndroidAppSettings.cfg @@ -133,7 +133,7 @@ AppTouchscreenKeyboardKeysAmount=6 AppTouchscreenKeyboardKeysAmountAutoFire=0 # Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) -RedefinedKeysScreenKb="RCTRL RSHIFT END PAGEUP PAGEDOWN W" +RedefinedKeysScreenKb="RCTRL RSHIFT END PAGEUP PAGEDOWN W UNKNOWN UNKNOWN UNKNOWN UNKNOWN" # Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu RedefinedKeysScreenKbNames="Fire Secondary_weapon Thrust Player_2_fire Player_2_secondary_weapon Player_2_thrust" @@ -159,16 +159,16 @@ MultiABI=y AppMinimumRAM=0 # Application version code (integer) -AppVersionCode=07023 +AppVersionCode=07001 # Application user-visible version name (string) -AppVersionName="0.7.0.23" +AppVersionName="0.7.0 beta 1" # Reset SDL config when updating application to the new version (y) / (n) -ResetSdlConfigForThisVersion=y +ResetSdlConfigForThisVersion=n # Delete application data files when upgrading (specify file/dir paths separated by spaces) -DeleteFilesOnUpgrade="addons packages menu.key uqm.key uqm.rmp version config/uqm.cfg config/flight.cfg libsdl-DownloadFinished-4.flag libsdl-DownloadFinished-5.flag libsdl-DownloadFinished-6.flag libsdl-DownloadFinished-7.flag libsdl-DownloadFinished-8.flag" +DeleteFilesOnUpgrade="%" # Optional shared libraries to compile - removing some of them will save space # MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed diff --git a/project/jni/application/uqm-hd/android.diff b/project/jni/application/uqm-hd/android.diff index 92d5810d0..67182dad8 100644 --- a/project/jni/application/uqm-hd/android.diff +++ b/project/jni/application/uqm-hd/android.diff @@ -1,6 +1,73 @@ +Index: src/uqm.c +=================================================================== +--- src/uqm.c (revision 1310) ++++ src/uqm.c (working copy) +@@ -63,6 +63,22 @@ + // Including this is actually necessary on OSX. + #endif + ++#if defined (ANDROID) ++# include ++static void AndroidAppPutToBackgroundCallback (void) ++{ ++ SDL_ANDROID_PauseAudioPlayback (); ++ GameActive = FALSE; ++ //GamePaused = TRUE; ++} ++static void SDLCALL AndroidAppRestoredCallback (void) ++{ ++ SDL_ANDROID_ResumeAudioPlayback (); ++ GameActive = TRUE; ++ //GamePaused = FALSE; ++} ++#endif ++ + struct bool_option + { + bool value; +@@ -256,8 +272,8 @@ + INIT_CONFIG_OPTION( gamma, 0.0f ), + INIT_CONFIG_OPTION( soundDriver, audio_DRIVER_MIXSDL ), + INIT_CONFIG_OPTION( soundQuality, audio_QUALITY_MEDIUM ), +- INIT_CONFIG_OPTION( use3doMusic, true ), +- INIT_CONFIG_OPTION( useRemixMusic, false ), ++ INIT_CONFIG_OPTION( use3doMusic, false ), ++ INIT_CONFIG_OPTION( useRemixMusic, true ), + INIT_CONFIG_OPTION( whichCoarseScan, OPT_PC ), + INIT_CONFIG_OPTION( whichMenu, OPT_PC ), + INIT_CONFIG_OPTION( whichFonts, OPT_PC ), +@@ -271,11 +287,11 @@ + INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ), + INIT_CONFIG_OPTION( speechVolumeScale, 0.3f ), + INIT_CONFIG_OPTION( safeMode, false ), +- INIT_CONFIG_OPTION( resolutionFactor, 2 ), ++ INIT_CONFIG_OPTION( resolutionFactor, 1 ), + INIT_CONFIG_OPTION( forceAspectRatio, false ), + INIT_CONFIG_OPTION( loresBlowupScale, 0 ), + INIT_CONFIG_OPTION( mainmenuMusic, true ), +- INIT_CONFIG_OPTION( mineralSubmenu, true ), ++ INIT_CONFIG_OPTION( mineralSubmenu, false ), + INIT_CONFIG_OPTION( nebulae, true ), + INIT_CONFIG_OPTION( rotatingIpPlanets, true), + INIT_CONFIG_OPTION( texturedIpPlanets, true), +@@ -346,6 +362,14 @@ + return optionsResult; + } + ++#if defined (ANDROID) ++ SDL_ANDROID_SetApplicationPutToBackgroundCallback (AndroidAppPutToBackgroundCallback, AndroidAppRestoredCallback); ++ if( !fileExists("config/save") ) { ++ // Copy savegames from UQM non-HD, I'm too lazy to do that properly. ++ system("SAVEDIR=`pwd`/config/save ; mkdir -p $SAVEDIR ; cd ../../../../app-data/com.sourceforge.sc2/config/save || exit 1 ; for f in * ; do cat $f > $SAVEDIR/$f ; done"); ++ } ++#endif ++ + TFB_PreInit (); + mem_init (); + InitThreadSystem (); Index: src/libs/sound/decoders/oggaud.c =================================================================== ---- src/libs/sound/decoders/oggaud.c (revision 1308) +--- src/libs/sound/decoders/oggaud.c (revision 1310) +++ src/libs/sound/decoders/oggaud.c (working copy) @@ -270,7 +270,7 @@ // this is the closest to a frame there is in ogg vorbis stream @@ -11,9 +78,24 @@ Index: src/libs/sound/decoders/oggaud.c #else return ova->vf.os.pageno; #endif /* OVCODEC_TREMOR */ +Index: src/libs/graphics/gfx_common.h +=================================================================== +--- src/libs/graphics/gfx_common.h (revision 1310) ++++ src/libs/graphics/gfx_common.h (working copy) +@@ -119,4 +119,10 @@ + extern int ScreenColorDepth; + extern int GraphicsDriver; + ++void TFB_SetOnScreenKeyboard_Hidden (void); ++void TFB_SetOnScreenKeyboard_Menu (void); ++void TFB_SetOnScreenKeyboard_Starmap (void); ++void TFB_SetOnScreenKeyboard_Melee (void); ++void TFB_SetOnScreenKeyboard_TwoPlayersMelee (void); ++ + #endif Index: src/libs/graphics/sdl/sdl_common.c =================================================================== ---- src/libs/graphics/sdl/sdl_common.c (revision 1308) +--- src/libs/graphics/sdl/sdl_common.c (revision 1310) +++ src/libs/graphics/sdl/sdl_common.c (working copy) @@ -34,7 +34,11 @@ #include "libs/memlib.h" @@ -194,7 +276,7 @@ Index: src/libs/graphics/sdl/sdl_common.c +#endif Index: src/libs/graphics/sdl/sdl_common.h =================================================================== ---- src/libs/graphics/sdl/sdl_common.h (revision 1308) +--- src/libs/graphics/sdl/sdl_common.h (revision 1310) +++ src/libs/graphics/sdl/sdl_common.h (working copy) @@ -50,4 +50,6 @@ @@ -205,7 +287,7 @@ Index: src/libs/graphics/sdl/sdl_common.h #endif Index: src/libs/graphics/sdl/pure.c =================================================================== ---- src/libs/graphics/sdl/pure.c (revision 1308) +--- src/libs/graphics/sdl/pure.c (revision 1310) +++ src/libs/graphics/sdl/pure.c (working copy) @@ -128,6 +128,7 @@ { @@ -239,66 +321,9 @@ Index: src/libs/graphics/sdl/pure.c if (SDL_Video == NULL) { -Index: src/libs/graphics/gfx_common.h -=================================================================== ---- src/libs/graphics/gfx_common.h (revision 1308) -+++ src/libs/graphics/gfx_common.h (working copy) -@@ -119,4 +119,10 @@ - extern int ScreenColorDepth; - extern int GraphicsDriver; - -+void TFB_SetOnScreenKeyboard_Hidden (void); -+void TFB_SetOnScreenKeyboard_Menu (void); -+void TFB_SetOnScreenKeyboard_Starmap (void); -+void TFB_SetOnScreenKeyboard_Melee (void); -+void TFB_SetOnScreenKeyboard_TwoPlayersMelee (void); -+ - #endif -Index: src/libs/log/msgbox_win.c -=================================================================== ---- src/libs/log/msgbox_win.c (revision 1308) -+++ src/libs/log/msgbox_win.c (working copy) -@@ -14,6 +14,7 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#ifndef ANDROID - #include "msgbox.h" - #define WIN32_LEAN_AND_MEAN - #include -@@ -64,4 +65,4 @@ - free (swTitle); - free (swMsg); - } -- -+#endif -Index: src/libs/log/msgbox_stub.c -=================================================================== ---- src/libs/log/msgbox_stub.c (revision 1308) -+++ src/libs/log/msgbox_stub.c (working copy) -@@ -16,6 +16,9 @@ - - #include "msgbox.h" - #include "loginternal.h" -+#ifdef ANDROID -+#include -+#endif - - void - log_displayBox (const /*UTF-8*/char *title, int isError, -@@ -26,6 +29,9 @@ - // So just inform the user of our predicament - fprintf (streamOut, "Do not know how to display %s box\n", - isError ? "an error" : "a"); -+#ifdef ANDROID -+ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg ); -+#endif - - // Suppress the compiler warnings in any case. - (void)title; Index: src/libs/log/uqmlog.c =================================================================== ---- src/libs/log/uqmlog.c (revision 1308) +--- src/libs/log/uqmlog.c (revision 1310) +++ src/libs/log/uqmlog.c (working copy) @@ -23,6 +23,9 @@ #include @@ -330,9 +355,66 @@ Index: src/libs/log/uqmlog.c } if ((int)level <= maxLevel) +Index: src/libs/log/msgbox_win.c +=================================================================== +--- src/libs/log/msgbox_win.c (revision 1310) ++++ src/libs/log/msgbox_win.c (working copy) +@@ -14,6 +14,7 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#ifndef ANDROID + #include "msgbox.h" + #define WIN32_LEAN_AND_MEAN + #include +@@ -64,4 +65,4 @@ + free (swTitle); + free (swMsg); + } +- ++#endif +Index: src/libs/log/msgbox_stub.c +=================================================================== +--- src/libs/log/msgbox_stub.c (revision 1310) ++++ src/libs/log/msgbox_stub.c (working copy) +@@ -16,6 +16,9 @@ + + #include "msgbox.h" + #include "loginternal.h" ++#ifdef ANDROID ++#include ++#endif + + void + log_displayBox (const /*UTF-8*/char *title, int isError, +@@ -26,6 +29,9 @@ + // So just inform the user of our predicament + fprintf (streamOut, "Do not know how to display %s box\n", + isError ? "an error" : "a"); ++#ifdef ANDROID ++ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg ); ++#endif + + // Suppress the compiler warnings in any case. + (void)title; +Index: src/libs/uio/zip/zip.c +=================================================================== +--- src/libs/uio/zip/zip.c (revision 1310) ++++ src/libs/uio/zip/zip.c (working copy) +@@ -1366,6 +1366,10 @@ + gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]); + break; + } ++ case 0x7875: // 'Unix string UID/GID' ++ // Just skip it ++ break; ++ + default: + #ifdef DEBUG + fprintf(stderr, "Debug: Extra field 0x%04x unsupported, " Index: src/libs/uio/io.c =================================================================== ---- src/libs/uio/io.c (revision 1308) +--- src/libs/uio/io.c (revision 1310) +++ src/libs/uio/io.c (working copy) @@ -35,6 +35,7 @@ #include "mem.h" @@ -397,24 +479,9 @@ Index: src/libs/uio/io.c int savedErrno = errno; uio_free(name); uio_PDirHandle_unref(pDirHandle); -Index: src/libs/uio/zip/zip.c -=================================================================== ---- src/libs/uio/zip/zip.c (revision 1308) -+++ src/libs/uio/zip/zip.c (working copy) -@@ -1366,6 +1366,10 @@ - gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]); - break; - } -+ case 0x7875: // 'Unix string UID/GID' -+ // Just skip it -+ break; -+ - default: - #ifdef DEBUG - fprintf(stderr, "Debug: Extra field 0x%04x unsupported, " Index: src/libs/md5/md5.c =================================================================== ---- src/libs/md5/md5.c (revision 1308) +--- src/libs/md5/md5.c (revision 1310) +++ src/libs/md5/md5.c (working copy) @@ -21,7 +21,7 @@ @@ -427,7 +494,7 @@ Index: src/libs/md5/md5.c Index: src/libs/input/input_common.h =================================================================== ---- src/libs/input/input_common.h (revision 1308) +--- src/libs/input/input_common.h (revision 1310) +++ src/libs/input/input_common.h (working copy) @@ -31,7 +31,7 @@ extern int TFB_InitInput (int driver, int flags); @@ -438,9 +505,23 @@ Index: src/libs/input/input_common.h extern void TFB_SetInputVectors (volatile int menu[], int num_menu, volatile int flight[], int num_templ, int num_flight); +Index: src/libs/input/sdl/vcontrol.h +=================================================================== +--- src/libs/input/sdl/vcontrol.h (revision 1310) ++++ src/libs/input/sdl/vcontrol.h (working copy) +@@ -76,6 +76,9 @@ + void VControl_ProcessJoyAxis (int port, int axis, int value); + void VControl_ProcessJoyHat (int port, int which, Uint8 value); + ++int VControl_GetJoyAxis(int port, int axis); ++int VControl_GetJoysticksAmount(); ++ + /* Force the input into the blank state. For preventing "sticky" keys. */ + void VControl_ResetInput (void); + Index: src/libs/input/sdl/input.c =================================================================== ---- src/libs/input/sdl/input.c (revision 1308) +--- src/libs/input/sdl/input.c (revision 1310) +++ src/libs/input/sdl/input.c (working copy) @@ -88,6 +88,7 @@ "weapon", @@ -461,7 +542,7 @@ Index: src/libs/input/sdl/input.c return; Index: src/libs/input/sdl/vcontrol.c =================================================================== ---- src/libs/input/sdl/vcontrol.c (revision 1308) +--- src/libs/input/sdl/vcontrol.c (revision 1310) +++ src/libs/input/sdl/vcontrol.c (working copy) @@ -46,6 +46,7 @@ typedef struct vcontrol_joystick_axis { @@ -522,23 +603,9 @@ Index: src/libs/input/sdl/vcontrol.c void VControl_ResetInput (void) { -Index: src/libs/input/sdl/vcontrol.h -=================================================================== ---- src/libs/input/sdl/vcontrol.h (revision 1308) -+++ src/libs/input/sdl/vcontrol.h (working copy) -@@ -76,6 +76,9 @@ - void VControl_ProcessJoyAxis (int port, int axis, int value); - void VControl_ProcessJoyHat (int port, int which, Uint8 value); - -+int VControl_GetJoyAxis(int port, int axis); -+int VControl_GetJoysticksAmount(); -+ - /* Force the input into the blank state. For preventing "sticky" keys. */ - void VControl_ResetInput (void); - Index: src/libs/resource/filecntl.c =================================================================== ---- src/libs/resource/filecntl.c (revision 1308) +--- src/libs/resource/filecntl.c (revision 1310) +++ src/libs/resource/filecntl.c (working copy) @@ -26,6 +26,7 @@ #include "port.h" @@ -559,681 +626,293 @@ Index: src/libs/resource/filecntl.c fp = uio_fopen (dir, filename, mode); -Index: src/uqm/battle.c +Index: src/config_unix.h =================================================================== ---- src/uqm/battle.c (revision 1308) -+++ src/uqm/battle.c (working copy) -@@ -16,6 +16,10 @@ +--- src/config_unix.h (revision 0) ++++ src/config_unix.h (working copy) +@@ -0,0 +1,63 @@ ++/* This file contains some compile-time configuration options for *nix ++ * systems. ++ * config_unix.h is generated from config_unix.h.in by build.sh ++ * When building on MS Windows using build.sh (MinGW, Cygwin), ++ * config_win.h is generated from src/config_win.h.in. ++ * When using MSVC on MS Windows, you'll have to edit src/config_vc6.h ++ * manually if you want anything else than the defaults. ++ */ ++ ++#ifndef _CONFIG_UNIX_H ++#define _CONFIG_UNIX_H ++ ++/* Directory where the UQM game data is located */ ++#define CONTENTDIR "" ++ ++/* Directory where game data will be stored */ ++#define USERDIR "config/" ++ ++/* Directory where config files will be stored */ ++#define CONFIGDIR USERDIR ++ ++/* Directory where supermelee teams will be stored */ ++#define MELEEDIR "teams/" ++ ++/* Directory where save games will be stored */ ++#define SAVEDIR "save/" ++ ++/* Defined if words are stored with the most significant byte first */ ++#undef WORDS_BIGENDIAN ++ ++/* Defined if your system has readdir_r of its own */ ++#define HAVE_READDIR_R ++ ++/* Defined if your system has setenv of its own */ ++#define HAVE_SETENV ++ ++/* Defined if your system has strupr of its own */ ++#undef HAVE_STRUPR ++ ++/* Defined if your system has strcasecmp of its own */ ++#define HAVE_STRCASECMP_UQM ++ // Not using "HAVE_STRCASECMP" as that conflicts with SDL. ++ ++/* Defined if your system has stricmp of its own */ ++#undef HAVE_STRICMP ++ ++/* Defined if your system has getopt_long */ ++#define HAVE_GETOPT_LONG ++ ++/* Defined if your system has iswgraph of its own*/ ++#define HAVE_ISWGRAPH ++ ++/* Defined if your system has wchar_t of its own */ ++#define HAVE_WCHAR_T ++ ++/* Defined if your system has wint_t of its own */ ++#define HAVE_WINT_T ++ ++/* Defined if your system has _Bool of its own */ ++#define HAVE__BOOL ++ ++#endif /* _CONFIG_UNIX_H */ ++ +Index: src/uqm/gameinp.c +=================================================================== +--- src/uqm/gameinp.c (revision 1310) ++++ src/uqm/gameinp.c (working copy) +@@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -+#ifdef ANDROID -+#include -+#endif -+ - #include "battle.h" - ++#include + #include "controls.h" #include "battlecontrols.h" -@@ -43,6 +47,8 @@ - #include "libs/graphics/gfx_common.h" - #include "libs/log.h" - #include "libs/mathlib.h" -+#include "globdata.h" -+#include "libs/input/sdl/vcontrol.h" + #include "init.h" +@@ -32,11 +33,14 @@ + #include "libs/timelib.h" + #include "libs/threadlib.h" +- ++#ifdef ANDROID ++#define ACCELERATION_INCREMENT (ONE_SECOND) ++#define MENU_REPEAT_DELAY (ONE_SECOND) ++#else + #define ACCELERATION_INCREMENT (ONE_SECOND / 12) + #define MENU_REPEAT_DELAY (ONE_SECOND / 2) ++#endif - BYTE battle_counter[NUM_SIDES]; -@@ -137,7 +143,8 @@ - frameInputHuman (HumanInputContext *context, STARSHIP *StarShipPtr) +- + typedef struct { - (void) StarShipPtr; -- return CurrentInputToBattleInput (context->playerNr); -+ -+ return CurrentInputToBattleInput (context->playerNr, StarShipPtr ? StarShipPtr->ShipFacing : -1); + BOOLEAN (*InputFunc) (void *pInputState); +@@ -66,6 +70,7 @@ + + volatile BOOLEAN ExitRequested; + volatile BOOLEAN GamePaused; ++volatile BOOLEAN OnScreenKeyboardLocked; + + static InputFrameCallback *inputCallback; + +@@ -422,16 +427,10 @@ } - static void -@@ -207,8 +214,11 @@ - StarShipPtr->ship_input_state |= SPECIAL; + static BATTLE_INPUT_STATE +-ControlInputToBattleInput (const int *keyState) ++ControlInputToBattleInput (const int *keyState, COUNT player, int direction) + { + BATTLE_INPUT_STATE InputState = 0; - if (CanRunAway && cur_player == 0 && -- (InputState & BATTLE_ESCAPE)) -+ ((InputState & BATTLE_ESCAPE) || EmergencyEscapeWarpUnitActivatedFromMenu)) -+ { -+ EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; - DoRunAway (StarShipPtr); -+ } - } - } +- if (keyState[KEY_UP]) +- InputState |= BATTLE_THRUST; +- if (keyState[KEY_LEFT]) +- InputState |= BATTLE_LEFT; +- if (keyState[KEY_RIGHT]) +- InputState |= BATTLE_RIGHT; + if (keyState[KEY_WEAPON]) + InputState |= BATTLE_WEAPON; + if (keyState[KEY_SPECIAL]) +@@ -441,21 +440,35 @@ + if (keyState[KEY_DOWN]) + InputState |= BATTLE_DOWN; -@@ -399,6 +409,11 @@ - - LockMutex (GraphicsLock); - -+ TFB_SetOnScreenKeyboard_Melee (); -+ if (PlayerControl[1] & HUMAN_CONTROL) { -+ TFB_SetOnScreenKeyboard_TwoPlayersMelee (); ++ if(direction < 0) ++ { ++ if (keyState[KEY_LEFT]) ++ InputState |= BATTLE_LEFT; ++ if (keyState[KEY_RIGHT]) ++ InputState |= BATTLE_RIGHT; ++ if (keyState[KEY_UP]) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ InputState |= GetDirectionalJoystickInput(direction, player); + } + - #if !(DEMO_MODE || CREATE_JOURNAL) - if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) { - // In Supermelee, the RNG is already initialised. -@@ -512,6 +527,8 @@ - UninitShips (); - FreeBattleSong (); - -+ TFB_SetOnScreenKeyboard_Menu (); -+ - UnlockMutex (GraphicsLock); - - return (BOOLEAN) (num_ships < 0); -Index: src/uqm/starcon.c -=================================================================== ---- src/uqm/starcon.c (revision 1308) -+++ src/uqm/starcon.c (working copy) -@@ -240,6 +240,7 @@ - if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) - AskNameForCaptainAndShip(); - -+ TFB_SetOnScreenKeyboard_Melee (); - do - { - #ifdef DEBUG -Index: src/uqm/status.c -=================================================================== ---- src/uqm/status.c (revision 1308) -+++ src/uqm/status.c (working copy) -@@ -328,7 +328,7 @@ - StarShipPtr->RaceDescPtr->characteristics.energy_wait; - - DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], -- 0, energy_delta); -+ 0, energy_delta, StarShipPtr->playerNr); - } - - return (retval); -@@ -370,7 +370,7 @@ - } - - DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], -- crew_delta, 0); -+ crew_delta, 0, StarShipPtr->playerNr); - - return (retval); + return InputState; } -Index: src/uqm/status.h -=================================================================== ---- src/uqm/status.h (revision 1308) -+++ src/uqm/status.h (working copy) -@@ -36,9 +36,15 @@ - #define CAPTAIN_HEIGHT RES_STAT_SCALE(30) // JMS_GFX - #define CAPTAIN_XOFFS ((STATUS_WIDTH - CAPTAIN_WIDTH) >> 1) // JMS_GFX - #define CAPTAIN_YOFFS (SHIP_INFO_HEIGHT + (4 << RESOLUTION_FACTOR)) // JMS_GFX --#define SHIP_STATUS_HEIGHT (STATUS_HEIGHT >> 1) --#define BAD_GUY_YOFFS 0 --#define GOOD_GUY_YOFFS SHIP_STATUS_HEIGHT -+#define SHIP_STATUS_HEIGHT ((STATUS_HEIGHT >> 1) - (17 << RESOLUTION_FACTOR)) -+#define BAD_GUY_YOFFS (-1 << RESOLUTION_FACTOR) -+#define GOOD_GUY_YOFFS (STATUS_HEIGHT - SHIP_STATUS_HEIGHT) -+#define HORIZ_CREW_ENERGY_SIZE (18 << RESOLUTION_FACTOR) -+#define HORIZ_CREW_XOFFS (2 << RESOLUTION_FACTOR) -+#define BAD_GUY_HORIZ_CREW_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT + (HORIZ_CREW_ENERGY_SIZE >> 1)) -+#define GOOD_GUY_HORIZ_CREW_YOFFS (GOOD_GUY_YOFFS - HORIZ_CREW_ENERGY_SIZE + (1 << RESOLUTION_FACTOR)) -+#define BAD_GUY_HORIZ_ENERGY_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT) -+#define GOOD_GUY_HORIZ_ENERGY_YOFFS (GOOD_GUY_YOFFS - (HORIZ_CREW_ENERGY_SIZE >> 1) + (1 << RESOLUTION_FACTOR)) - #define STARCON_TEXT_HEIGHT (7 << RESOLUTION_FACTOR) // JMS_GFX - #define TINY_TEXT_HEIGHT (9 << RESOLUTION_FACTOR) // JMS_GFX - #define BATTLE_CREW_X RES_STAT_SCALE(10) // JMS_GFX -@@ -54,7 +60,7 @@ - extern void InitShipStatus (SHIP_INFO *ShipInfoPtr, STARSHIP *StarShipPtr, RECT *pClipRect, BOOLEAN inMeleeMenu); - // StarShipPtr or pClipRect can be NULL - extern void DeltaStatistics (SHIP_INFO *ShipInfoPtr, COORD y_offs, -- SIZE crew_delta, SIZE energy_delta); -+ SIZE crew_delta, SIZE energy_delta, SIZE player_num); - extern void DrawBattleCrewAmount (SHIP_INFO *ShipInfoPtr, COORD y_offs); - extern void DrawCaptainsWindow (STARSHIP *StarShipPtr); -Index: src/uqm/controls.h -=================================================================== ---- src/uqm/controls.h (revision 1308) -+++ src/uqm/controls.h (working copy) -@@ -32,6 +32,7 @@ - KEY_WEAPON, - KEY_SPECIAL, - KEY_ESCAPE, -+ KEY_THRUST, - NUM_KEYS - }; - enum { -@@ -90,13 +91,14 @@ - #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5)) - #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) - --BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player); -+BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */); - BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player); - - extern CONTROLLER_INPUT_STATE CurrentInputState; - extern CONTROLLER_INPUT_STATE PulsedInputState; - extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; - extern CONTROL_TEMPLATE PlayerControls[]; -+extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu; - - void UpdateInputState (void); - extern void FlushInput (void); -@@ -116,6 +118,8 @@ - BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput); - BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); - -+extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player); -+ - void DoPopupWindow(const char *msg); - - typedef void (InputFrameCallback) (void); -Index: src/uqm/supermelee/melee.c -=================================================================== ---- src/uqm/supermelee/melee.c (revision 1308) -+++ src/uqm/supermelee/melee.c (working copy) -@@ -2124,7 +2124,7 @@ - PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING; - Melee_LocalChange_team (&MenuState, 0, - MenuState.load.preBuiltList[0]); -- PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING; -+ PlayerControl[1] = HUMAN_CONTROL | STANDARD_RATING; // COMPUTER_CONTROL | STANDARD_RATING; - Melee_LocalChange_team (&MenuState, 1, - MenuState.load.preBuiltList[1]); - } -Index: src/uqm/menu.c -=================================================================== ---- src/uqm/menu.c (revision 1308) -+++ src/uqm/menu.c (working copy) -@@ -508,7 +508,7 @@ - s.origin.x = RADAR_X - r.corner.x; - s.origin.y = RADAR_Y - r.corner.y; - r.corner.x = s.origin.x - 1; -- r.corner.y = s.origin.y - (11 << RESOLUTION_FACTOR); // JMS_GFX -+ r.corner.y = s.origin.y - (40 << RESOLUTION_FACTOR); // JMS_GFX - r.extent.width = RADAR_WIDTH + 2; - BatchGraphics (); - SetContextForeGroundColor ( -Index: src/uqm/planets/solarsys.c -=================================================================== ---- src/uqm/planets/solarsys.c (revision 1308) -+++ src/uqm/planets/solarsys.c (working copy) -@@ -1245,18 +1245,19 @@ - static void - ProcessShipControls (void) + BATTLE_INPUT_STATE +-CurrentInputToBattleInput (COUNT player) ++CurrentInputToBattleInput (COUNT player, int direction) { -- COUNT index; -+ COUNT index = GetFrameIndex (GLOBAL (ShipStamp.frame));; - SIZE delta_x, delta_y; -+ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); - -- if (CurrentInputState.key[PlayerControls[0]][KEY_UP]) -+ if (InputState & BATTLE_THRUST) - delta_y = -1; - else - delta_y = 0; - - delta_x = 0; -- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) -+ if (InputState & BATTLE_LEFT) - delta_x -= 1; -- if (CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) -+ if (InputState & BATTLE_RIGHT) - delta_x += 1; - - if (delta_x || delta_y < 0) -@@ -1269,7 +1270,6 @@ - else - delta_y = 0; - -- index = GetFrameIndex (GLOBAL (ShipStamp.frame)); - if (pSolarSysState->turn_counter) - --pSolarSysState->turn_counter; - else if (delta_x) -@@ -2473,7 +2473,9 @@ - InitSolarSys (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - SolarSysState.InputFunc = DoIpFlight; -+ TFB_SetOnScreenKeyboard_Melee (); - DoInput (&SolarSysState, FALSE); -+ TFB_SetOnScreenKeyboard_Menu (); - UninitSolarSys (); - pSolarSysState = 0; + return ControlInputToBattleInput( +- CurrentInputState.key[PlayerControls[player]]); ++ CurrentInputState.key[PlayerControls[player]], player, direction); } -@@ -2751,13 +2753,17 @@ - if (pSS->InOrbit) - { // CheckShipLocation() or InitSolarSys() sent us to orbital -+ TFB_SetOnScreenKeyboard_Menu (); - EnterPlanetOrbit (); -+ TFB_SetOnScreenKeyboard_Melee (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - pSS->InOrbit = FALSE; - } - else if (cancel || LastActivity == CHECK_LOAD) - { -+ TFB_SetOnScreenKeyboard_Menu (); - SolarSysMenu (); -+ TFB_SetOnScreenKeyboard_Melee (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - } - else -Index: src/uqm/planets/pstarmap.c -=================================================================== ---- src/uqm/planets/pstarmap.c (revision 1308) -+++ src/uqm/planets/pstarmap.c (working copy) -@@ -2005,7 +2005,9 @@ - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, - TRUE); -+ TFB_SetOnScreenKeyboard_Starmap (); - DoInput (&MenuState, FALSE); -+ TFB_SetOnScreenKeyboard_Menu (); - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - SetDefaultMenuRepeatDelay (); - -Index: src/uqm/planets/lander.c -=================================================================== ---- src/uqm/planets/lander.c (revision 1308) -+++ src/uqm/planets/lander.c (working copy) -@@ -1852,15 +1852,15 @@ - if (crew_left) - { - SIZE index = GetFrameIndex (LanderFrame[0]); -+ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); - if (turn_wait) - --turn_wait; -- else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] || -- CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) -+ else if ((InputState & BATTLE_LEFT) || (InputState & BATTLE_RIGHT)) - { - COUNT landerSpeedNumer; - COUNT angle; - -- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) -+ if (InputState & BATTLE_LEFT) - --index; - else - ++index; -@@ -1884,7 +1884,7 @@ - turn_wait = SHUTTLE_TURN_WAIT; - } - -- if (!CurrentInputState.key[PlayerControls[0]][KEY_UP]) -+ if (!(InputState & BATTLE_THRUST)) - { - dx = 0; - dy = 0; -@@ -2212,7 +2212,9 @@ - landerInputState.Initialized = FALSE; - landerInputState.InputFunc = DoPlanetSide; - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); -+ TFB_SetOnScreenKeyboard_Melee (); - DoInput (&landerInputState, FALSE); -+ TFB_SetOnScreenKeyboard_Menu (); - - if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) - { -Index: src/uqm/comm/yehat/yehatc.c -=================================================================== ---- src/uqm/comm/yehat/yehatc.c (revision 1308) -+++ src/uqm/comm/yehat/yehatc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../yehat/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/orz/orzc.c -=================================================================== ---- src/uqm/comm/orz/orzc.c (revision 1308) -+++ src/uqm/comm/orz/orzc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../orz/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/urquan/urquanc.c -=================================================================== ---- src/uqm/comm/urquan/urquanc.c (revision 1308) -+++ src/uqm/comm/urquan/urquanc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../urquan/strings.h" - - static LOCDATA urquan_desc = + BATTLE_INPUT_STATE + PulsedInputToBattleInput (COUNT player) { -Index: src/uqm/comm/slyhome/slyhome.c -=================================================================== ---- src/uqm/comm/slyhome/slyhome.c (revision 1308) -+++ src/uqm/comm/slyhome/slyhome.c (working copy) -@@ -18,7 +18,7 @@ + return ControlInputToBattleInput( +- PulsedInputState.key[PlayerControls[player]]); ++ PulsedInputState.key[PlayerControls[player]], player, -1); + } - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../slyhome/strings.h" + BOOLEAN +@@ -500,3 +513,121 @@ + return result; + } - #include "uqm/gameev.h" - -Index: src/uqm/comm/comandr/comandr.c -=================================================================== ---- src/uqm/comm/comandr/comandr.c (revision 1308) -+++ src/uqm/comm/comandr/comandr.c (working copy) -@@ -20,7 +20,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../comandr/strings.h" - - #include "uqm/setup.h" - #include "uqm/sis.h" -Index: src/uqm/comm/blackur/blackurc.c -=================================================================== ---- src/uqm/comm/blackur/blackurc.c (revision 1308) -+++ src/uqm/comm/blackur/blackurc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../blackur/strings.h" - - static LOCDATA blackurq_desc = - { -Index: src/uqm/comm/mycon/myconc.c -=================================================================== ---- src/uqm/comm/mycon/myconc.c (revision 1308) -+++ src/uqm/comm/mycon/myconc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../mycon/strings.h" - - #include "uqm/gameev.h" - #include "libs/mathlib.h" -Index: src/uqm/comm/spathi/spathic.c -=================================================================== ---- src/uqm/comm/spathi/spathic.c (revision 1308) -+++ src/uqm/comm/spathi/spathic.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../spathi/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/druuge/druugec.c -=================================================================== ---- src/uqm/comm/druuge/druugec.c (revision 1308) -+++ src/uqm/comm/druuge/druugec.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../druuge/strings.h" - - #include "uqm/build.h" - #include "uqm/setup.h" -Index: src/uqm/comm/syreen/syreenc.c -=================================================================== ---- src/uqm/comm/syreen/syreenc.c (revision 1308) -+++ src/uqm/comm/syreen/syreenc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../syreen/strings.h" - - #include "libs/sound/sound.h" - #include "uqm/build.h" -Index: src/uqm/comm/chmmr/chmmrc.c -=================================================================== ---- src/uqm/comm/chmmr/chmmrc.c (revision 1308) -+++ src/uqm/comm/chmmr/chmmrc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../chmmr/strings.h" - - #include "uqm/build.h" - #include "uqm/hyper.h" -Index: src/uqm/comm/slyland/slyland.c -=================================================================== ---- src/uqm/comm/slyland/slyland.c (revision 1308) -+++ src/uqm/comm/slyland/slyland.c (working copy) -@@ -16,10 +16,10 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#include "../slyland/strings.h" -+#include - #include "../commall.h" --#include - #include "resinst.h" --#include "strings.h" - - #include "options.h" - #include "uqm/battle.h" -Index: src/uqm/comm/ilwrath/ilwrathc.c -=================================================================== ---- src/uqm/comm/ilwrath/ilwrathc.c (revision 1308) -+++ src/uqm/comm/ilwrath/ilwrathc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../ilwrath/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/supox/supoxc.c -=================================================================== ---- src/uqm/comm/supox/supoxc.c (revision 1308) -+++ src/uqm/comm/supox/supoxc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../supox/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/vux/vuxc.c -=================================================================== ---- src/uqm/comm/vux/vuxc.c (revision 1308) -+++ src/uqm/comm/vux/vuxc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../vux/strings.h" - - static LOCDATA vux_desc_1x = - { -Index: src/uqm/comm/zoqfot/zoqfotc.c -=================================================================== ---- src/uqm/comm/zoqfot/zoqfotc.c (revision 1308) -+++ src/uqm/comm/zoqfot/zoqfotc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../zoqfot/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/shofixt/shofixt.c -=================================================================== ---- src/uqm/comm/shofixt/shofixt.c (revision 1308) -+++ src/uqm/comm/shofixt/shofixt.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../shofixt/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/pkunk/pkunkc.c -=================================================================== ---- src/uqm/comm/pkunk/pkunkc.c (revision 1308) -+++ src/uqm/comm/pkunk/pkunkc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../pkunk/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/rebel/rebel.c -=================================================================== ---- src/uqm/comm/rebel/rebel.c (revision 1308) -+++ src/uqm/comm/rebel/rebel.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../yehat/resinst.h" --#include "strings.h" -+#include "../rebel/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/arilou/arilouc.c -=================================================================== ---- src/uqm/comm/arilou/arilouc.c (revision 1308) -+++ src/uqm/comm/arilou/arilouc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../arilou/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/spahome/spahome.c -=================================================================== ---- src/uqm/comm/spahome/spahome.c (revision 1308) -+++ src/uqm/comm/spahome/spahome.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../spathi/resinst.h" --#include "strings.h" -+#include "../spahome/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/starbas/starbas.c -=================================================================== ---- src/uqm/comm/starbas/starbas.c (revision 1308) -+++ src/uqm/comm/starbas/starbas.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../comandr/resinst.h" --#include "strings.h" -+#include "../starbas/strings.h" - - #include "uqm/build.h" - #include "uqm/setup.h" -Index: src/uqm/comm/utwig/utwigc.c -=================================================================== ---- src/uqm/comm/utwig/utwigc.c (revision 1308) -+++ src/uqm/comm/utwig/utwigc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../utwig/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/umgah/umgahc.c -=================================================================== ---- src/uqm/comm/umgah/umgahc.c (revision 1308) -+++ src/uqm/comm/umgah/umgahc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../umgah/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/talkpet/talkpet.c -=================================================================== ---- src/uqm/comm/talkpet/talkpet.c (revision 1308) -+++ src/uqm/comm/talkpet/talkpet.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../talkpet/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/thradd/thraddc.c -=================================================================== ---- src/uqm/comm/thradd/thraddc.c (revision 1308) -+++ src/uqm/comm/thradd/thraddc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../thradd/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/melnorm/melnorm.c -=================================================================== ---- src/uqm/comm/melnorm/melnorm.c (revision 1308) -+++ src/uqm/comm/melnorm/melnorm.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../melnorm/strings.h" - - #include "uqm/gameev.h" - #include "uqm/setup.h" ++// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits ++// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads ++ ++#ifndef M_PI ++#define M_PI 3.14159265358979323846 ++#endif ++enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0), SHIP_DIRECTIONS = 16 }; ++ ++static inline int atan2i(int y, int x) ++{ ++ int angle; ++ int abs_y = abs(y); ++ if( abs_y == 0 ) ++ abs_y = 1; ++ if (x>=0) ++ { ++ angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); ++ } ++ else ++ { ++ angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); ++ } ++ if (y < 0) ++ return(-angle); // negate if in quad III or IV ++ else ++ return(angle); ++} ++ ++ ++BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player) ++{ ++ BATTLE_INPUT_STATE InputState = 0; ++ static BOOLEAN JoystickThrust[NUM_PLAYERS] = { FALSE, FALSE }; ++ static BOOLEAN JoystickTapFlag[NUM_PLAYERS] = { FALSE, FALSE }; ++ static TimeCount JoystickTapTime[NUM_PLAYERS] = { 0, 0 }; ++ ++ if (CurrentInputState.key[PlayerControls[player]][KEY_THRUST]) ++ InputState |= BATTLE_THRUST; ++ ++ if(VControl_GetJoysticksAmount() <= 0) ++ { ++ if (CurrentInputState.key[PlayerControls[player]][KEY_LEFT]) ++ InputState |= BATTLE_LEFT; ++ if (CurrentInputState.key[PlayerControls[player]][KEY_RIGHT]) ++ InputState |= BATTLE_RIGHT; ++ if (CurrentInputState.key[PlayerControls[player]][KEY_UP]) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ int axisX = VControl_GetJoyAxis(0, player * 2), axisY = VControl_GetJoyAxis(0, player * 2 + 1); ++ ++ if( axisX == 0 && axisY == 0 ) ++ { ++ // Some basic gamepad input support ++ axisX = VControl_GetJoyAxis(2, player * 2); ++ axisY = VControl_GetJoyAxis(2, player * 2 + 1); ++ if( abs( axisX ) > 5000 || abs( axisY ) > 5000 ) ++ { ++ if( !JoystickTapFlag[player] ) ++ TFB_SetOnScreenKeyboard_Hidden (); // Gamepad used - hide on-screen keys ++ JoystickTapFlag[player] = TRUE; ++ JoystickThrust[player] = FALSE; ++ // Turning thrust with joystick is uncomfortable ++ //if( abs( axisX ) > 25000 || abs( axisY ) > 25000 ) ++ // JoystickThrust[player] = TRUE; ++ } ++ else ++ { ++ axisX = 0; ++ axisY = 0; ++ } ++ } ++ ++ if( axisX != 0 || axisY != 0 ) ++ { ++ int angle = atan2i(axisY, axisX), diff; ++ // Convert it to 16 directions used by Melee ++ angle += atan2i_PI / SHIP_DIRECTIONS; ++ if( angle < 0 ) ++ angle += atan2i_PI * 2; ++ if( angle > atan2i_PI * 2 ) ++ angle -= atan2i_PI * 2; ++ angle = angle * SHIP_DIRECTIONS / atan2i_PI / 2; ++ ++ diff = angle - direction - SHIP_DIRECTIONS / 4; ++ while( diff >= SHIP_DIRECTIONS ) ++ diff -= SHIP_DIRECTIONS; ++ while( diff < 0 ) ++ diff += SHIP_DIRECTIONS; ++ ++ if( diff < SHIP_DIRECTIONS / 2 ) ++ InputState |= BATTLE_LEFT; ++ if( diff > SHIP_DIRECTIONS / 2 ) ++ InputState |= BATTLE_RIGHT; ++ ++ if( !JoystickTapFlag[player] ) ++ { ++ JoystickTapFlag[player] = TRUE; ++ if( GetTimeCounter() < JoystickTapTime[player] + ONE_SECOND ) ++ JoystickThrust[player] = !JoystickThrust[player]; ++ else ++ JoystickThrust[player] = TRUE; ++ } ++ if( JoystickThrust[player] ) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ if( JoystickTapFlag[player] ) ++ { ++ JoystickTapFlag[player] = FALSE; ++ JoystickTapTime[player] = GetTimeCounter(); ++ } ++ } ++ } ++ return InputState; ++} Index: src/uqm/shipstat.c =================================================================== ---- src/uqm/shipstat.c (revision 1308) +--- src/uqm/shipstat.c (revision 1310) +++ src/uqm/shipstat.c (working copy) @@ -144,6 +144,45 @@ DrawFilledRectangle (&r); @@ -1412,261 +1091,9 @@ Index: src/uqm/shipstat.c } } -Index: src/uqm/gameinp.c -=================================================================== ---- src/uqm/gameinp.c (revision 1308) -+++ src/uqm/gameinp.c (working copy) -@@ -16,6 +16,7 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#include - #include "controls.h" - #include "battlecontrols.h" - #include "init.h" -@@ -32,11 +33,14 @@ - #include "libs/timelib.h" - #include "libs/threadlib.h" - -- -+#ifdef ANDROID -+#define ACCELERATION_INCREMENT (ONE_SECOND) -+#define MENU_REPEAT_DELAY (ONE_SECOND) -+#else - #define ACCELERATION_INCREMENT (ONE_SECOND / 12) - #define MENU_REPEAT_DELAY (ONE_SECOND / 2) -+#endif - -- - typedef struct - { - BOOLEAN (*InputFunc) (void *pInputState); -@@ -66,6 +70,7 @@ - - volatile BOOLEAN ExitRequested; - volatile BOOLEAN GamePaused; -+volatile BOOLEAN OnScreenKeyboardLocked; - - static InputFrameCallback *inputCallback; - -@@ -422,16 +427,10 @@ - } - - static BATTLE_INPUT_STATE --ControlInputToBattleInput (const int *keyState) -+ControlInputToBattleInput (const int *keyState, COUNT player, int direction) - { - BATTLE_INPUT_STATE InputState = 0; - -- if (keyState[KEY_UP]) -- InputState |= BATTLE_THRUST; -- if (keyState[KEY_LEFT]) -- InputState |= BATTLE_LEFT; -- if (keyState[KEY_RIGHT]) -- InputState |= BATTLE_RIGHT; - if (keyState[KEY_WEAPON]) - InputState |= BATTLE_WEAPON; - if (keyState[KEY_SPECIAL]) -@@ -441,21 +440,35 @@ - if (keyState[KEY_DOWN]) - InputState |= BATTLE_DOWN; - -+ if(direction < 0) -+ { -+ if (keyState[KEY_LEFT]) -+ InputState |= BATTLE_LEFT; -+ if (keyState[KEY_RIGHT]) -+ InputState |= BATTLE_RIGHT; -+ if (keyState[KEY_UP]) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ InputState |= GetDirectionalJoystickInput(direction, player); -+ } -+ - return InputState; - } - - BATTLE_INPUT_STATE --CurrentInputToBattleInput (COUNT player) -+CurrentInputToBattleInput (COUNT player, int direction) - { - return ControlInputToBattleInput( -- CurrentInputState.key[PlayerControls[player]]); -+ CurrentInputState.key[PlayerControls[player]], player, direction); - } - - BATTLE_INPUT_STATE - PulsedInputToBattleInput (COUNT player) - { - return ControlInputToBattleInput( -- PulsedInputState.key[PlayerControls[player]]); -+ PulsedInputState.key[PlayerControls[player]], player, -1); - } - - BOOLEAN -@@ -500,3 +513,113 @@ - return result; - } - -+// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits -+// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads -+ -+#ifndef M_PI -+#define M_PI 3.14159265358979323846 -+#endif -+enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0), SHIP_DIRECTIONS = 16 }; -+ -+static inline int atan2i(int y, int x) -+{ -+ int angle; -+ int abs_y = abs(y); -+ if( abs_y == 0 ) -+ abs_y = 1; -+ if (x>=0) -+ { -+ angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); -+ } -+ else -+ { -+ angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); -+ } -+ if (y < 0) -+ return(-angle); // negate if in quad III or IV -+ else -+ return(angle); -+} -+ -+ -+BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player) -+{ -+ BATTLE_INPUT_STATE InputState = 0; -+ static BOOLEAN JoystickThrust[NUM_PLAYERS] = { FALSE, FALSE }; -+ static BOOLEAN JoystickTapFlag[NUM_PLAYERS] = { FALSE, FALSE }; -+ static TimeCount JoystickTapTime[NUM_PLAYERS] = { 0, 0 }; -+ -+ if (CurrentInputState.key[PlayerControls[player]][KEY_THRUST]) -+ InputState |= BATTLE_THRUST; -+ -+ if(VControl_GetJoysticksAmount() <= 0) -+ { -+ if (CurrentInputState.key[PlayerControls[player]][KEY_LEFT]) -+ InputState |= BATTLE_LEFT; -+ if (CurrentInputState.key[PlayerControls[player]][KEY_RIGHT]) -+ InputState |= BATTLE_RIGHT; -+ if (CurrentInputState.key[PlayerControls[player]][KEY_UP]) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ int axisX = VControl_GetJoyAxis(0, player * 2), axisY = VControl_GetJoyAxis(0, player * 2 + 1); -+ -+ if( axisX == 0 && axisY == 0 ) -+ { -+ // Some basic gamepad input support -+ axisX = VControl_GetJoyAxis(2, player * 2); -+ axisY = VControl_GetJoyAxis(2, player * 2 + 1); -+ if( axisX != 0 || axisY != 0 ) -+ { -+ if( !JoystickTapFlag[player] ) -+ TFB_SetOnScreenKeyboard_Hidden (); // Gamepad used - hide on-screen keys -+ JoystickTapFlag[player] = TRUE; -+ JoystickThrust[player] = FALSE; -+ } -+ } -+ -+ if( axisX != 0 || axisY != 0 ) -+ { -+ int angle = atan2i(axisY, axisX), diff; -+ // Convert it to 16 directions used by Melee -+ angle += atan2i_PI / SHIP_DIRECTIONS; -+ if( angle < 0 ) -+ angle += atan2i_PI * 2; -+ if( angle > atan2i_PI * 2 ) -+ angle -= atan2i_PI * 2; -+ angle = angle * SHIP_DIRECTIONS / atan2i_PI / 2; -+ -+ diff = angle - direction - SHIP_DIRECTIONS / 4; -+ while( diff >= SHIP_DIRECTIONS ) -+ diff -= SHIP_DIRECTIONS; -+ while( diff < 0 ) -+ diff += SHIP_DIRECTIONS; -+ -+ if( diff < SHIP_DIRECTIONS / 2 ) -+ InputState |= BATTLE_LEFT; -+ if( diff > SHIP_DIRECTIONS / 2 ) -+ InputState |= BATTLE_RIGHT; -+ -+ if( !JoystickTapFlag[player] ) -+ { -+ JoystickTapFlag[player] = TRUE; -+ if( GetTimeCounter() < JoystickTapTime[player] + ONE_SECOND ) -+ JoystickThrust[player] = !JoystickThrust[player]; -+ else -+ JoystickThrust[player] = TRUE; -+ } -+ if( JoystickThrust[player] ) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ if( JoystickTapFlag[player] ) -+ { -+ JoystickTapFlag[player] = FALSE; -+ JoystickTapTime[player] = GetTimeCounter(); -+ } -+ } -+ } -+ return InputState; -+} -Index: src/uqm/hyper.c -=================================================================== ---- src/uqm/hyper.c (revision 1308) -+++ src/uqm/hyper.c (working copy) -@@ -1930,7 +1930,6 @@ - Color OldColor; - CONTEXT OldContext; - MENU_STATE MenuState; -- - UnbatchGraphics (); - - OldContext = SetContext (SpaceContext); -Index: src/uqm/intro.c -=================================================================== ---- src/uqm/intro.c (revision 1308) -+++ src/uqm/intro.c (working copy) -@@ -909,7 +909,9 @@ - pis.MovieFrame = -1; - pis.StartTime = GetTimeCounter (); - pis.LastSyncTime = pis.StartTime; -+ TFB_SetOnScreenKeyboard_Hidden (); - DoInput (&pis, TRUE); -+ TFB_SetOnScreenKeyboard_Menu(); - - SleepThreadUntil (FadeMusic (0, ONE_SECOND)); - StopMusic (); -@@ -1001,7 +1003,9 @@ - vis.InputFunc = DoVideoInput; - vis.CurVideo = ref; - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); -+ TFB_SetOnScreenKeyboard_Hidden (); - DoInput (&vis, TRUE); -+ TFB_SetOnScreenKeyboard_Menu (); - - StopLegacyVideo (ref); - FadeClearScreen (); -@@ -1017,6 +1021,7 @@ - { - return FALSE; - } -+ - if (!strcmp (resType, "STRTAB")) - { - STRING pres = CaptureStringTable (LoadStringTable (res)); Index: src/uqm/intel.c =================================================================== ---- src/uqm/intel.c (revision 1308) +--- src/uqm/intel.c (revision 1310) +++ src/uqm/intel.c (working copy) @@ -45,10 +45,10 @@ // Allow a player to warp-escape in cyborg mode @@ -1681,9 +1108,77 @@ Index: src/uqm/intel.c } else if (!(PlayerControl[context->playerNr] & PSYTRON_CONTROL)) InputState = 0; +Index: src/uqm/battle.c +=================================================================== +--- src/uqm/battle.c (revision 1310) ++++ src/uqm/battle.c (working copy) +@@ -16,6 +16,10 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#ifdef ANDROID ++#include ++#endif ++ + #include "battle.h" + + #include "battlecontrols.h" +@@ -43,6 +47,8 @@ + #include "libs/graphics/gfx_common.h" + #include "libs/log.h" + #include "libs/mathlib.h" ++#include "globdata.h" ++#include "libs/input/sdl/vcontrol.h" + + + BYTE battle_counter[NUM_SIDES]; +@@ -137,7 +143,8 @@ + frameInputHuman (HumanInputContext *context, STARSHIP *StarShipPtr) + { + (void) StarShipPtr; +- return CurrentInputToBattleInput (context->playerNr); ++ ++ return CurrentInputToBattleInput (context->playerNr, StarShipPtr ? StarShipPtr->ShipFacing : -1); + } + + static void +@@ -207,8 +214,11 @@ + StarShipPtr->ship_input_state |= SPECIAL; + + if (CanRunAway && cur_player == 0 && +- (InputState & BATTLE_ESCAPE)) ++ ((InputState & BATTLE_ESCAPE) || EmergencyEscapeWarpUnitActivatedFromMenu)) ++ { ++ EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; + DoRunAway (StarShipPtr); ++ } + } + } + +@@ -399,6 +409,11 @@ + + LockMutex (GraphicsLock); + ++ TFB_SetOnScreenKeyboard_Melee (); ++ if (PlayerControl[1] & HUMAN_CONTROL) { ++ TFB_SetOnScreenKeyboard_TwoPlayersMelee (); ++ } ++ + #if !(DEMO_MODE || CREATE_JOURNAL) + if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) { + // In Supermelee, the RNG is already initialised. +@@ -512,6 +527,8 @@ + UninitShips (); + FreeBattleSong (); + ++ TFB_SetOnScreenKeyboard_Menu (); ++ + UnlockMutex (GraphicsLock); + + return (BOOLEAN) (num_ships < 0); Index: src/uqm/confirm.c =================================================================== ---- src/uqm/confirm.c (revision 1308) +--- src/uqm/confirm.c (revision 1310) +++ src/uqm/confirm.c (working copy) @@ -34,9 +34,11 @@ #include @@ -1743,9 +1238,746 @@ Index: src/uqm/confirm.c result = FALSE; } ExitRequested = FALSE; +Index: src/uqm/outfit.c +=================================================================== +--- src/uqm/outfit.c (revision 1310) ++++ src/uqm/outfit.c (working copy) +@@ -59,7 +59,7 @@ + OldContext = SetContext (StatusContext); + GetContextClipRect (&r); + s.origin.x = RADAR_X - r.corner.x; +- s.origin.y = RADAR_Y - r.corner.y - 19 * RESOLUTION_FACTOR; // JMS_GFX; ++ s.origin.y = RADAR_Y_LIFTED_UP - r.corner.y + RES_CASE(10,6,12); // JMS_GFX; + r.corner.x = s.origin.x - 1; + r.corner.y = s.origin.y - 11; + r.extent.width = RADAR_WIDTH + 2; +Index: src/uqm/globdata.c +=================================================================== +--- src/uqm/globdata.c (revision 1310) ++++ src/uqm/globdata.c (working copy) +@@ -130,7 +130,7 @@ + OldContext = SetContext (RadarContext); + SetContextFGFrame (Screen); + r.corner.x = RADAR_X; +- r.corner.y = RADAR_Y; ++ r.corner.y = RADAR_Y_LIFTED_UP; + r.extent.width = RADAR_WIDTH; + r.extent.height = RADAR_HEIGHT; + SetContextClipRect (&r); +Index: src/uqm/shipyard.c +=================================================================== +--- src/uqm/shipyard.c (revision 1310) ++++ src/uqm/shipyard.c (working copy) +@@ -212,9 +212,9 @@ + OldContext = SetContext (StatusContext); + GetContextClipRect (&r); + s.origin.x = RADAR_X - r.corner.x; +- s.origin.y = RADAR_Y - r.corner.y; ++ s.origin.y = RADAR_Y_LIFTED_UP - r.corner.y; + r.corner.x = s.origin.x - 1; +- r.corner.y = s.origin.y - RES_CASE(11,24,33); // JMS_GFX ++ r.corner.y = s.origin.y - RES_CASE(1,2,3); // JMS_GFX + r.extent.width = RADAR_WIDTH + 2; + r.extent.height = RES_CASE(11,24,33); // JMS_GFX + BatchGraphics (); +@@ -242,8 +242,6 @@ + hStarShip = GetAvailableRaceFromIndex (NewRaceItem); + NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q), + hStarShip); +- s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem); +- DrawStamp (&s); + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); + s.frame = FleetPtr->melee_icon; + UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip); +@@ -253,6 +251,12 @@ + s.origin.x += (RADAR_WIDTH >> 1); + s.origin.y += (RADAR_HEIGHT >> 1); + DrawStamp (&s); ++ // Draw the ship name, above the ship image. ++ s.origin.x -= (RADAR_WIDTH >> 1); ++ s.origin.y -= (RADAR_HEIGHT >> 2); ++ s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem); ++ DrawStamp (&s); ++ + t.align = ALIGN_RIGHT; + t.CharCount = (COUNT)~0; + t.pStr = buf; +Index: src/uqm/status.c +=================================================================== +--- src/uqm/status.c (revision 1310) ++++ src/uqm/status.c (working copy) +@@ -328,7 +328,7 @@ + StarShipPtr->RaceDescPtr->characteristics.energy_wait; + + DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], +- 0, energy_delta); ++ 0, energy_delta, StarShipPtr->playerNr); + } + + return (retval); +@@ -370,7 +370,7 @@ + } + + DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], +- crew_delta, 0); ++ crew_delta, 0, StarShipPtr->playerNr); + + return (retval); + } +Index: src/uqm/status.h +=================================================================== +--- src/uqm/status.h (revision 1310) ++++ src/uqm/status.h (working copy) +@@ -36,9 +36,15 @@ + #define CAPTAIN_HEIGHT RES_STAT_SCALE(30) // JMS_GFX + #define CAPTAIN_XOFFS ((STATUS_WIDTH - CAPTAIN_WIDTH) >> 1) // JMS_GFX + #define CAPTAIN_YOFFS (SHIP_INFO_HEIGHT + (4 << RESOLUTION_FACTOR)) // JMS_GFX +-#define SHIP_STATUS_HEIGHT (STATUS_HEIGHT >> 1) +-#define BAD_GUY_YOFFS 0 +-#define GOOD_GUY_YOFFS SHIP_STATUS_HEIGHT ++#define SHIP_STATUS_HEIGHT ((STATUS_HEIGHT >> 1) - (17 << RESOLUTION_FACTOR)) ++#define BAD_GUY_YOFFS (-1 << RESOLUTION_FACTOR) ++#define GOOD_GUY_YOFFS (STATUS_HEIGHT - SHIP_STATUS_HEIGHT) ++#define HORIZ_CREW_ENERGY_SIZE (18 << RESOLUTION_FACTOR) ++#define HORIZ_CREW_XOFFS (2 << RESOLUTION_FACTOR) ++#define BAD_GUY_HORIZ_CREW_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT + (HORIZ_CREW_ENERGY_SIZE >> 1)) ++#define GOOD_GUY_HORIZ_CREW_YOFFS (GOOD_GUY_YOFFS - HORIZ_CREW_ENERGY_SIZE + (1 << RESOLUTION_FACTOR)) ++#define BAD_GUY_HORIZ_ENERGY_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT) ++#define GOOD_GUY_HORIZ_ENERGY_YOFFS (GOOD_GUY_YOFFS - (HORIZ_CREW_ENERGY_SIZE >> 1) + (1 << RESOLUTION_FACTOR)) + #define STARCON_TEXT_HEIGHT (7 << RESOLUTION_FACTOR) // JMS_GFX + #define TINY_TEXT_HEIGHT (9 << RESOLUTION_FACTOR) // JMS_GFX + #define BATTLE_CREW_X RES_STAT_SCALE(10) // JMS_GFX +@@ -54,7 +60,7 @@ + extern void InitShipStatus (SHIP_INFO *ShipInfoPtr, STARSHIP *StarShipPtr, RECT *pClipRect, BOOLEAN inMeleeMenu); + // StarShipPtr or pClipRect can be NULL + extern void DeltaStatistics (SHIP_INFO *ShipInfoPtr, COORD y_offs, +- SIZE crew_delta, SIZE energy_delta); ++ SIZE crew_delta, SIZE energy_delta, SIZE player_num); + extern void DrawBattleCrewAmount (SHIP_INFO *ShipInfoPtr, COORD y_offs); + + extern void DrawCaptainsWindow (STARSHIP *StarShipPtr); +Index: src/uqm/starcon.c +=================================================================== +--- src/uqm/starcon.c (revision 1310) ++++ src/uqm/starcon.c (working copy) +@@ -240,6 +240,7 @@ + if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) + AskNameForCaptainAndShip(); + ++ TFB_SetOnScreenKeyboard_Melee (); + do + { + #ifdef DEBUG +Index: src/uqm/menu.c +=================================================================== +--- src/uqm/menu.c (revision 1310) ++++ src/uqm/menu.c (working copy) +@@ -508,7 +508,7 @@ + s.origin.x = RADAR_X - r.corner.x; + s.origin.y = RADAR_Y - r.corner.y; + r.corner.x = s.origin.x - 1; +- r.corner.y = s.origin.y - (11 << RESOLUTION_FACTOR); // JMS_GFX ++ r.corner.y = s.origin.y - (40 << RESOLUTION_FACTOR); // JMS_GFX + r.extent.width = RADAR_WIDTH + 2; + BatchGraphics (); + SetContextForeGroundColor ( +Index: src/uqm/comm/umgah/umgahc.c +=================================================================== +--- src/uqm/comm/umgah/umgahc.c (revision 1310) ++++ src/uqm/comm/umgah/umgahc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../umgah/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/talkpet/talkpet.c +=================================================================== +--- src/uqm/comm/talkpet/talkpet.c (revision 1310) ++++ src/uqm/comm/talkpet/talkpet.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../talkpet/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/thradd/thraddc.c +=================================================================== +--- src/uqm/comm/thradd/thraddc.c (revision 1310) ++++ src/uqm/comm/thradd/thraddc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../thradd/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/melnorm/melnorm.c +=================================================================== +--- src/uqm/comm/melnorm/melnorm.c (revision 1310) ++++ src/uqm/comm/melnorm/melnorm.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../melnorm/strings.h" + + #include "uqm/gameev.h" + #include "uqm/setup.h" +Index: src/uqm/comm/yehat/yehatc.c +=================================================================== +--- src/uqm/comm/yehat/yehatc.c (revision 1310) ++++ src/uqm/comm/yehat/yehatc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../yehat/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/orz/orzc.c +=================================================================== +--- src/uqm/comm/orz/orzc.c (revision 1310) ++++ src/uqm/comm/orz/orzc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../orz/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/urquan/urquanc.c +=================================================================== +--- src/uqm/comm/urquan/urquanc.c (revision 1310) ++++ src/uqm/comm/urquan/urquanc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../urquan/strings.h" + + static LOCDATA urquan_desc = + { +Index: src/uqm/comm/slyhome/slyhome.c +=================================================================== +--- src/uqm/comm/slyhome/slyhome.c (revision 1310) ++++ src/uqm/comm/slyhome/slyhome.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../slyhome/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/blackur/blackurc.c +=================================================================== +--- src/uqm/comm/blackur/blackurc.c (revision 1310) ++++ src/uqm/comm/blackur/blackurc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../blackur/strings.h" + + static LOCDATA blackurq_desc = + { +Index: src/uqm/comm/comandr/comandr.c +=================================================================== +--- src/uqm/comm/comandr/comandr.c (revision 1310) ++++ src/uqm/comm/comandr/comandr.c (working copy) +@@ -20,7 +20,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../comandr/strings.h" + + #include "uqm/setup.h" + #include "uqm/sis.h" +Index: src/uqm/comm/mycon/myconc.c +=================================================================== +--- src/uqm/comm/mycon/myconc.c (revision 1310) ++++ src/uqm/comm/mycon/myconc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../mycon/strings.h" + + #include "uqm/gameev.h" + #include "libs/mathlib.h" +Index: src/uqm/comm/spathi/spathic.c +=================================================================== +--- src/uqm/comm/spathi/spathic.c (revision 1310) ++++ src/uqm/comm/spathi/spathic.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../spathi/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/druuge/druugec.c +=================================================================== +--- src/uqm/comm/druuge/druugec.c (revision 1310) ++++ src/uqm/comm/druuge/druugec.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../druuge/strings.h" + + #include "uqm/build.h" + #include "uqm/setup.h" +Index: src/uqm/comm/syreen/syreenc.c +=================================================================== +--- src/uqm/comm/syreen/syreenc.c (revision 1310) ++++ src/uqm/comm/syreen/syreenc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../syreen/strings.h" + + #include "libs/sound/sound.h" + #include "uqm/build.h" +Index: src/uqm/comm/slyland/slyland.c +=================================================================== +--- src/uqm/comm/slyland/slyland.c (revision 1310) ++++ src/uqm/comm/slyland/slyland.c (working copy) +@@ -16,10 +16,10 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#include "../slyland/strings.h" ++#include + #include "../commall.h" +-#include + #include "resinst.h" +-#include "strings.h" + + #include "options.h" + #include "uqm/battle.h" +Index: src/uqm/comm/chmmr/chmmrc.c +=================================================================== +--- src/uqm/comm/chmmr/chmmrc.c (revision 1310) ++++ src/uqm/comm/chmmr/chmmrc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../chmmr/strings.h" + + #include "uqm/build.h" + #include "uqm/hyper.h" +Index: src/uqm/comm/ilwrath/ilwrathc.c +=================================================================== +--- src/uqm/comm/ilwrath/ilwrathc.c (revision 1310) ++++ src/uqm/comm/ilwrath/ilwrathc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../ilwrath/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/supox/supoxc.c +=================================================================== +--- src/uqm/comm/supox/supoxc.c (revision 1310) ++++ src/uqm/comm/supox/supoxc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../supox/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/vux/vuxc.c +=================================================================== +--- src/uqm/comm/vux/vuxc.c (revision 1310) ++++ src/uqm/comm/vux/vuxc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../vux/strings.h" + + static LOCDATA vux_desc_1x = + { +Index: src/uqm/comm/zoqfot/zoqfotc.c +=================================================================== +--- src/uqm/comm/zoqfot/zoqfotc.c (revision 1310) ++++ src/uqm/comm/zoqfot/zoqfotc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../zoqfot/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/shofixt/shofixt.c +=================================================================== +--- src/uqm/comm/shofixt/shofixt.c (revision 1310) ++++ src/uqm/comm/shofixt/shofixt.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../shofixt/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/pkunk/pkunkc.c +=================================================================== +--- src/uqm/comm/pkunk/pkunkc.c (revision 1310) ++++ src/uqm/comm/pkunk/pkunkc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../pkunk/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/rebel/rebel.c +=================================================================== +--- src/uqm/comm/rebel/rebel.c (revision 1310) ++++ src/uqm/comm/rebel/rebel.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../yehat/resinst.h" +-#include "strings.h" ++#include "../rebel/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/arilou/arilouc.c +=================================================================== +--- src/uqm/comm/arilou/arilouc.c (revision 1310) ++++ src/uqm/comm/arilou/arilouc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../arilou/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/spahome/spahome.c +=================================================================== +--- src/uqm/comm/spahome/spahome.c (revision 1310) ++++ src/uqm/comm/spahome/spahome.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../spathi/resinst.h" +-#include "strings.h" ++#include "../spahome/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/starbas/starbas.c +=================================================================== +--- src/uqm/comm/starbas/starbas.c (revision 1310) ++++ src/uqm/comm/starbas/starbas.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../comandr/resinst.h" +-#include "strings.h" ++#include "../starbas/strings.h" + + #include "uqm/build.h" + #include "uqm/setup.h" +Index: src/uqm/comm/utwig/utwigc.c +=================================================================== +--- src/uqm/comm/utwig/utwigc.c (revision 1310) ++++ src/uqm/comm/utwig/utwigc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../utwig/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/units.h +=================================================================== +--- src/uqm/units.h (revision 1310) ++++ src/uqm/units.h (working copy) +@@ -67,6 +67,7 @@ + #define RADAR_WIDTH (STATUS_WIDTH - RES_STAT_SCALE(8)) // JMS_GFX + #define RADAR_HEIGHT RES_STAT_SCALE(53) // JMS_GFX + #define RADAR_Y (SIS_ORG_Y + SIS_SCREEN_HEIGHT - (53 << RESOLUTION_FACTOR)) // JMS_GFX ++#define RADAR_Y_LIFTED_UP (RADAR_Y - (40 << RESOLUTION_FACTOR)) + + /* Blue boxes which display messages and the green date box. */ + #define SIS_TITLE_BOX_WIDTH (57 << RESOLUTION_FACTOR) // JMS_GFX +Index: src/uqm/controls.h +=================================================================== +--- src/uqm/controls.h (revision 1310) ++++ src/uqm/controls.h (working copy) +@@ -32,6 +32,7 @@ + KEY_WEAPON, + KEY_SPECIAL, + KEY_ESCAPE, ++ KEY_THRUST, + NUM_KEYS + }; + enum { +@@ -90,13 +91,14 @@ + #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5)) + #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) + +-BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player); ++BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */); + BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player); + + extern CONTROLLER_INPUT_STATE CurrentInputState; + extern CONTROLLER_INPUT_STATE PulsedInputState; + extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; + extern CONTROL_TEMPLATE PlayerControls[]; ++extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu; + + void UpdateInputState (void); + extern void FlushInput (void); +@@ -116,6 +118,8 @@ + BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput); + BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); + ++extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player); ++ + void DoPopupWindow(const char *msg); + + typedef void (InputFrameCallback) (void); +Index: src/uqm/planets/pstarmap.c +=================================================================== +--- src/uqm/planets/pstarmap.c (revision 1310) ++++ src/uqm/planets/pstarmap.c (working copy) +@@ -2005,7 +2005,9 @@ + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, + TRUE); ++ TFB_SetOnScreenKeyboard_Starmap (); + DoInput (&MenuState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + SetDefaultMenuRepeatDelay (); + +Index: src/uqm/planets/lander.c +=================================================================== +--- src/uqm/planets/lander.c (revision 1310) ++++ src/uqm/planets/lander.c (working copy) +@@ -1852,15 +1852,15 @@ + if (crew_left) + { + SIZE index = GetFrameIndex (LanderFrame[0]); ++ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); + if (turn_wait) + --turn_wait; +- else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] || +- CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) ++ else if ((InputState & BATTLE_LEFT) || (InputState & BATTLE_RIGHT)) + { + COUNT landerSpeedNumer; + COUNT angle; + +- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) ++ if (InputState & BATTLE_LEFT) + --index; + else + ++index; +@@ -1884,7 +1884,7 @@ + turn_wait = SHUTTLE_TURN_WAIT; + } + +- if (!CurrentInputState.key[PlayerControls[0]][KEY_UP]) ++ if (!(InputState & BATTLE_THRUST)) + { + dx = 0; + dy = 0; +@@ -2212,7 +2212,9 @@ + landerInputState.Initialized = FALSE; + landerInputState.InputFunc = DoPlanetSide; + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); ++ TFB_SetOnScreenKeyboard_Melee (); + DoInput (&landerInputState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + + if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + { +Index: src/uqm/planets/solarsys.c +=================================================================== +--- src/uqm/planets/solarsys.c (revision 1310) ++++ src/uqm/planets/solarsys.c (working copy) +@@ -1245,18 +1245,19 @@ + static void + ProcessShipControls (void) + { +- COUNT index; ++ COUNT index = GetFrameIndex (GLOBAL (ShipStamp.frame));; + SIZE delta_x, delta_y; ++ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); + +- if (CurrentInputState.key[PlayerControls[0]][KEY_UP]) ++ if (InputState & BATTLE_THRUST) + delta_y = -1; + else + delta_y = 0; + + delta_x = 0; +- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) ++ if (InputState & BATTLE_LEFT) + delta_x -= 1; +- if (CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) ++ if (InputState & BATTLE_RIGHT) + delta_x += 1; + + if (delta_x || delta_y < 0) +@@ -1269,7 +1270,6 @@ + else + delta_y = 0; + +- index = GetFrameIndex (GLOBAL (ShipStamp.frame)); + if (pSolarSysState->turn_counter) + --pSolarSysState->turn_counter; + else if (delta_x) +@@ -2473,7 +2473,9 @@ + InitSolarSys (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + SolarSysState.InputFunc = DoIpFlight; ++ TFB_SetOnScreenKeyboard_Melee (); + DoInput (&SolarSysState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + UninitSolarSys (); + pSolarSysState = 0; + } +@@ -2751,13 +2753,17 @@ + + if (pSS->InOrbit) + { // CheckShipLocation() or InitSolarSys() sent us to orbital ++ TFB_SetOnScreenKeyboard_Menu (); + EnterPlanetOrbit (); ++ TFB_SetOnScreenKeyboard_Melee (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + pSS->InOrbit = FALSE; + } + else if (cancel || LastActivity == CHECK_LOAD) + { ++ TFB_SetOnScreenKeyboard_Menu (); + SolarSysMenu (); ++ TFB_SetOnScreenKeyboard_Melee (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + } + else +Index: src/uqm/supermelee/melee.c +=================================================================== +--- src/uqm/supermelee/melee.c (revision 1310) ++++ src/uqm/supermelee/melee.c (working copy) +@@ -2124,7 +2124,7 @@ + PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING; + Melee_LocalChange_team (&MenuState, 0, + MenuState.load.preBuiltList[0]); +- PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING; ++ PlayerControl[1] = HUMAN_CONTROL | STANDARD_RATING; // COMPUTER_CONTROL | STANDARD_RATING; + Melee_LocalChange_team (&MenuState, 1, + MenuState.load.preBuiltList[1]); + } +Index: src/uqm/sis.c +=================================================================== +--- src/uqm/sis.c (revision 1310) ++++ src/uqm/sis.c (working copy) +@@ -1810,7 +1810,7 @@ + GetContextClipRect (&clip_r); + pRect = &temp_r; + temp_r.corner.x = RADAR_X - clip_r.corner.x; +- temp_r.corner.y = RADAR_Y - clip_r.corner.y; ++ temp_r.corner.y = RADAR_Y_LIFTED_UP - clip_r.corner.y; + temp_r.extent.width = RADAR_WIDTH; + temp_r.extent.height = RADAR_HEIGHT; + SetContext (ScreenContext); +Index: src/uqm/hyper.c +=================================================================== +--- src/uqm/hyper.c (revision 1310) ++++ src/uqm/hyper.c (working copy) +@@ -1930,7 +1930,6 @@ + Color OldColor; + CONTEXT OldContext; + MENU_STATE MenuState; +- + UnbatchGraphics (); + + OldContext = SetContext (SpaceContext); +Index: src/uqm/intro.c +=================================================================== +--- src/uqm/intro.c (revision 1310) ++++ src/uqm/intro.c (working copy) +@@ -909,7 +909,9 @@ + pis.MovieFrame = -1; + pis.StartTime = GetTimeCounter (); + pis.LastSyncTime = pis.StartTime; ++ TFB_SetOnScreenKeyboard_Hidden (); + DoInput (&pis, TRUE); ++ TFB_SetOnScreenKeyboard_Menu(); + + SleepThreadUntil (FadeMusic (0, ONE_SECOND)); + StopMusic (); +@@ -1001,7 +1003,9 @@ + vis.InputFunc = DoVideoInput; + vis.CurVideo = ref; + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); ++ TFB_SetOnScreenKeyboard_Hidden (); + DoInput (&vis, TRUE); ++ TFB_SetOnScreenKeyboard_Menu (); + + StopLegacyVideo (ref); + FadeClearScreen (); +@@ -1017,6 +1021,7 @@ + { + return FALSE; + } ++ + if (!strcmp (resType, "STRTAB")) + { + STRING pres = CaptureStringTable (LoadStringTable (res)); Index: src/options.c =================================================================== ---- src/options.c (revision 1308) +--- src/options.c (revision 1310) +++ src/options.c (working copy) @@ -480,6 +480,7 @@ @@ -1755,65 +1987,3 @@ Index: src/options.c if (uio_mountDir (repository, mountPoint, uio_FSTYPE_ZIP, dirHandle, dirList->names[i], "/", autoMount, relativeFlags | uio_MOUNT_RDONLY, -Index: src/uqm.c -=================================================================== ---- src/uqm.c (revision 1308) -+++ src/uqm.c (working copy) -@@ -63,6 +63,22 @@ - // Including this is actually necessary on OSX. - #endif - -+#if defined (ANDROID) -+# include -+static void AndroidAppPutToBackgroundCallback (void) -+{ -+ SDL_ANDROID_PauseAudioPlayback (); -+ GameActive = FALSE; -+ //GamePaused = TRUE; -+} -+static void SDLCALL AndroidAppRestoredCallback (void) -+{ -+ SDL_ANDROID_ResumeAudioPlayback (); -+ GameActive = TRUE; -+ //GamePaused = FALSE; -+} -+#endif -+ - struct bool_option - { - bool value; -@@ -256,8 +272,8 @@ - INIT_CONFIG_OPTION( gamma, 0.0f ), - INIT_CONFIG_OPTION( soundDriver, audio_DRIVER_MIXSDL ), - INIT_CONFIG_OPTION( soundQuality, audio_QUALITY_MEDIUM ), -- INIT_CONFIG_OPTION( use3doMusic, true ), -- INIT_CONFIG_OPTION( useRemixMusic, false ), -+ INIT_CONFIG_OPTION( use3doMusic, false ), -+ INIT_CONFIG_OPTION( useRemixMusic, true ), - INIT_CONFIG_OPTION( whichCoarseScan, OPT_PC ), - INIT_CONFIG_OPTION( whichMenu, OPT_PC ), - INIT_CONFIG_OPTION( whichFonts, OPT_PC ), -@@ -271,7 +287,7 @@ - INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ), - INIT_CONFIG_OPTION( speechVolumeScale, 0.3f ), - INIT_CONFIG_OPTION( safeMode, false ), -- INIT_CONFIG_OPTION( resolutionFactor, 2 ), -+ INIT_CONFIG_OPTION( resolutionFactor, 1 ), - INIT_CONFIG_OPTION( forceAspectRatio, false ), - INIT_CONFIG_OPTION( loresBlowupScale, 0 ), - INIT_CONFIG_OPTION( mainmenuMusic, true ), -@@ -346,6 +362,14 @@ - return optionsResult; - } - -+#if defined (ANDROID) -+ SDL_ANDROID_SetApplicationPutToBackgroundCallback (AndroidAppPutToBackgroundCallback, AndroidAppRestoredCallback); -+ if( !fileExists("config/save") ) { -+ // Copy savegames from UQM non-HD, I'm too lazy to do that properly. -+ system("SAVEDIR=`pwd`/config/save ; mkdir -p $SAVEDIR ; cd ../../../../app-data/com.sourceforge.sc2/config/save || exit 1 ; for f in * ; do cat $f > $SAVEDIR/$f ; done"); -+ } -+#endif -+ - TFB_PreInit (); - mem_init (); - InitThreadSystem (); diff --git a/project/jni/application/uqm/AndroidAppSettings.cfg b/project/jni/application/uqm/AndroidAppSettings.cfg index 3dfe607e3..f4a0bd6b0 100644 --- a/project/jni/application/uqm/AndroidAppSettings.cfg +++ b/project/jni/application/uqm/AndroidAppSettings.cfg @@ -133,7 +133,7 @@ AppTouchscreenKeyboardKeysAmount=6 AppTouchscreenKeyboardKeysAmountAutoFire=0 # Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) -RedefinedKeysScreenKb="RCTRL RSHIFT END PAGEUP PAGEDOWN W" +RedefinedKeysScreenKb="RCTRL RSHIFT END PAGEUP PAGEDOWN W UNKNOWN UNKNOWN UNKNOWN UNKNOWN" # Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu RedefinedKeysScreenKbNames="Fire Secondary_weapon Thrust Player_2_fire Player_2_secondary_weapon Player_2_thrust" diff --git a/project/jni/application/uqm/android.diff b/project/jni/application/uqm/android.diff index eefa7e1ea..039daf726 100644 --- a/project/jni/application/uqm/android.diff +++ b/project/jni/application/uqm/android.diff @@ -1,3 +1,302 @@ +Index: src/options.h +=================================================================== +--- src/options.h (revision 3779) ++++ src/options.h (working copy) +@@ -41,6 +41,7 @@ + extern int optWhichShield; + extern int optSmoothScroll; + extern int optMeleeScale; ++extern int optDirectionalJoystick; + + extern BOOLEAN opt3doMusic; + extern BOOLEAN optRemixMusic; +Index: src/uqm.c +=================================================================== +--- src/uqm.c (revision 3779) ++++ src/uqm.c (working copy) +@@ -62,6 +62,22 @@ + // Including this is actually necessary on OSX. + #endif + ++#if defined (ANDROID) ++# include ++static void AndroidAppPutToBackgroundCallback (void) ++{ ++ SDL_ANDROID_PauseAudioPlayback (); ++ GameActive = FALSE; ++ //GamePaused = TRUE; ++} ++static void SDLCALL AndroidAppRestoredCallback (void) ++{ ++ SDL_ANDROID_ResumeAudioPlayback (); ++ GameActive = TRUE; ++ //GamePaused = FALSE; ++} ++#endif ++ + struct bool_option + { + bool value; +@@ -129,6 +145,7 @@ + DECL_CONFIG_OPTION(float, sfxVolumeScale); + DECL_CONFIG_OPTION(float, speechVolumeScale); + DECL_CONFIG_OPTION(bool, safeMode); ++ DECL_CONFIG_OPTION(bool, directionalJoystick); + + #define INIT_CONFIG_OPTION(name, val) \ + { val, false } +@@ -247,8 +264,8 @@ + INIT_CONFIG_OPTION( gamma, 1.0f ), + INIT_CONFIG_OPTION( soundDriver, audio_DRIVER_MIXSDL ), + INIT_CONFIG_OPTION( soundQuality, audio_QUALITY_MEDIUM ), +- INIT_CONFIG_OPTION( use3doMusic, true ), +- INIT_CONFIG_OPTION( useRemixMusic, false ), ++ INIT_CONFIG_OPTION( use3doMusic, false ), ++ INIT_CONFIG_OPTION( useRemixMusic, true ), + INIT_CONFIG_OPTION( useSpeech, true ), + INIT_CONFIG_OPTION( whichCoarseScan, OPT_PC ), + INIT_CONFIG_OPTION( whichMenu, OPT_PC ), +@@ -263,6 +280,7 @@ + INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ), + INIT_CONFIG_OPTION( speechVolumeScale, 1.0f ), + INIT_CONFIG_OPTION( safeMode, false ), ++ INIT_CONFIG_OPTION( directionalJoystick, true ), + }; + struct options_struct defaults = options; + int optionsResult; +@@ -390,6 +408,7 @@ + sfxVolumeScale = options.sfxVolumeScale.value; + speechVolumeScale = options.speechVolumeScale.value; + optAddons = options.addons; ++ optDirectionalJoystick = options.directionalJoystick.value; + + prepareContentDir (options.contentDir, options.addonDir, argv[0]); + prepareMeleeDir (); +@@ -439,6 +458,10 @@ + (volatile int *)ImmediateInputState.key, NUM_TEMPLATES, NUM_KEYS); + TFB_InitInput (TFB_INPUTDRIVER_SDL, 0); + ++#if defined (ANDROID) ++ SDL_ANDROID_SetApplicationPutToBackgroundCallback (AndroidAppPutToBackgroundCallback, AndroidAppRestoredCallback); ++#endif ++ + StartThread (Starcon2Main, NULL, 1024, "Starcon2Main"); + + for (i = 0; i < 2000 && !MainExited; ) +@@ -637,6 +660,7 @@ + getBoolConfigValue (&options->fullscreen, "config.fullscreen"); + getBoolConfigValue (&options->scanlines, "config.scanlines"); + getBoolConfigValue (&options->showFps, "config.showfps"); ++ getBoolConfigValue (&options->directionalJoystick, "config.directionaljoystick"); + getBoolConfigValue (&options->keepAspectRatio, "config.keepaspectratio"); + getGammaConfigValue (&options->gamma, "config.gamma"); + +Index: src/libs/uio/io.c +=================================================================== +--- src/libs/uio/io.c (revision 3779) ++++ src/libs/uio/io.c (working copy) +@@ -35,6 +35,7 @@ + #include "mem.h" + #include "uioutils.h" + #include "uioport.h" ++#include "../log.h" + #ifdef uio_MEM_DEBUG + # include "memdebug.h" + #endif +@@ -193,6 +194,7 @@ + errno = EINVAL; + return NULL; + } ++ log_add (log_Info, "uio_open %s", sourcePath); + handle = uio_open(sourceDir, sourcePath, + ((flags & uio_MOUNT_RDONLY) == uio_MOUNT_RDONLY ? + O_RDONLY : O_RDWR) +@@ -201,12 +203,14 @@ + #endif + , 0); + if (handle == NULL) { ++ log_add (log_Info, "uio_open failed for %s", sourcePath); + // errno is set + return NULL; + } + } + + handler = uio_getFileSystemHandler(fsType); ++ log_add (log_Info, "uio_getFileSystemHandler %p", handler); + if (handler == NULL) { + if (handle) + uio_close(handle); +@@ -800,6 +804,7 @@ + &readMountInfo, &readPDirHandle, NULL, + &writeMountInfo, &writePDirHandle, NULL, &name) == -1) { + // errno is set ++ log_add (log_Info, "uio_open: uio_getPhysicalAccess failed for '%s'", path); + return NULL; + } + +@@ -826,6 +831,7 @@ + uio_PDirHandle_unref(readPDirHandle); + uio_PDirHandle_unref(writePDirHandle); + errno = EEXIST; ++ log_add (log_Info, "uio_open: O_CREAT | O_EXCL: file already exists '%s'", name); + return NULL; + } + if ((flags & O_TRUNC) == O_TRUNC) { +@@ -842,6 +848,7 @@ + uio_PDirHandle_unref(readPDirHandle); + uio_PDirHandle_unref(writePDirHandle); + errno = savedErrno; ++ log_add (log_Info, "uio_open: uio_copyFilePhysical failed '%s'", name); + return NULL; + } + } +@@ -863,6 +870,7 @@ + handle = (pDirHandle->pRoot->handler->open)(pDirHandle, name, flags, mode); + // Also adds a new entry to the physical dir if appropriate. + if (handle == NULL) { ++ log_add (log_Info, "uio_open: open file failed '%s'", name); + int savedErrno = errno; + uio_free(name); + uio_PDirHandle_unref(pDirHandle); +Index: src/libs/uio/zip/zip.c +=================================================================== +--- src/libs/uio/zip/zip.c (revision 3779) ++++ src/libs/uio/zip/zip.c (working copy) +@@ -1366,6 +1366,10 @@ + gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]); + break; + } ++ case 0x7875: // 'Unix string UID/GID' ++ // Just skip it ++ break; ++ + default: + #ifdef DEBUG + fprintf(stderr, "Debug: Extra field 0x%04x unsupported, " +Index: src/libs/md5/md5.c +=================================================================== +--- src/libs/md5/md5.c (revision 3779) ++++ src/libs/md5/md5.c (working copy) +@@ -21,7 +21,7 @@ + + /* Written by Ulrich Drepper , 1995. */ + +-#include ++#include "config.h" + + #include "md5.h" + +Index: src/libs/input/sdl/input.c +=================================================================== +--- src/libs/input/sdl/input.c (revision 3779) ++++ src/libs/input/sdl/input.c (working copy) +@@ -86,6 +86,7 @@ + "weapon", + "special", + "escape", ++ "thrust", + NULL + }; + +@@ -186,7 +187,7 @@ + directory. */ + LoadResourceIndex (contentDir, "uqm.key", "keys."); + } +- ++ + register_flight_controls (); + + return; +Index: src/libs/input/sdl/vcontrol.c +=================================================================== +--- src/libs/input/sdl/vcontrol.c (revision 3779) ++++ src/libs/input/sdl/vcontrol.c (working copy) +@@ -46,6 +46,7 @@ + typedef struct vcontrol_joystick_axis { + keybinding *neg, *pos; + int polarity; ++ int value; + } axis_type; + + typedef struct vcontrol_joystick_hat { +@@ -66,7 +67,7 @@ + + #endif /* HAVE_JOYSTICK */ + +-static unsigned int joycount; ++static unsigned int joycount = 0; + static unsigned int num_sdl_keys = 0; + static keybinding **bindings = NULL; + +@@ -141,6 +142,7 @@ + for (j = 0; j < axes; j++) + { + x->axes[j].neg = x->axes[j].pos = NULL; ++ x->axes[j].polarity = x->axes[j].value = 0; + } + for (j = 0; j < hats; j++) + { +@@ -818,6 +820,7 @@ + int t; + if (!joysticks[port].stick) + return; ++ joysticks[port].axes[axis].value = value; + t = joysticks[port].threshold; + if (value > t) + { +@@ -894,6 +897,25 @@ + #endif /* HAVE_JOYSTICK */ + } + ++int ++VControl_GetJoyAxis(int port, int axis) ++{ ++#ifdef HAVE_JOYSTICK ++ if( joycount <= port ) ++ return 0; ++ if (!joysticks[port].stick || joysticks[port].numaxes <= axis ) ++ return 0; ++ return joysticks[port].axes[axis].value; ++#else ++ return 0; ++#endif /* HAVE_JOYSTICK */ ++}; ++ ++int VControl_GetJoysticksAmount() ++{ ++ return joycount; ++}; ++ + void + VControl_ResetInput (void) + { +Index: src/libs/input/sdl/vcontrol.h +=================================================================== +--- src/libs/input/sdl/vcontrol.h (revision 3779) ++++ src/libs/input/sdl/vcontrol.h (working copy) +@@ -76,6 +76,9 @@ + void VControl_ProcessJoyAxis (int port, int axis, int value); + void VControl_ProcessJoyHat (int port, int which, Uint8 value); + ++int VControl_GetJoyAxis(int port, int axis); ++int VControl_GetJoysticksAmount(); ++ + /* Force the input into the blank state. For preventing "sticky" keys. */ + void VControl_ResetInput (void); + +Index: src/libs/input/input_common.h +=================================================================== +--- src/libs/input/input_common.h (revision 3779) ++++ src/libs/input/input_common.h (working copy) +@@ -31,7 +31,7 @@ + extern int TFB_InitInput (int driver, int flags); + extern void TFB_UninitInput (void); + +-#define MAX_FLIGHT_ALTERNATES 2 ++#define MAX_FLIGHT_ALTERNATES 3 + + extern void TFB_SetInputVectors (volatile int menu[], int num_menu, + volatile int flight[], int num_templ, int num_flight); Index: src/libs/resource/filecntl.c =================================================================== --- src/libs/resource/filecntl.c (revision 3779) @@ -290,30 +589,6 @@ Index: src/libs/graphics/sdl/pure.c if (SDL_Video == NULL) { -Index: src/libs/log/msgbox_stub.c -=================================================================== ---- src/libs/log/msgbox_stub.c (revision 3779) -+++ src/libs/log/msgbox_stub.c (working copy) -@@ -16,6 +16,9 @@ - - #include "msgbox.h" - #include "loginternal.h" -+#ifdef ANDROID -+#include -+#endif - - void - log_displayBox (const /*UTF-8*/char *title, int isError, -@@ -26,6 +29,9 @@ - // So just inform the user of our predicament - fprintf (streamOut, "Do not know how to display %s box\n", - isError ? "an error" : "a"); -+#ifdef ANDROID -+ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg ); -+#endif - - // Suppress the compiler warnings in any case. - (void)title; Index: src/libs/log/uqmlog.c =================================================================== --- src/libs/log/uqmlog.c (revision 3779) @@ -366,212 +641,30 @@ Index: src/libs/log/msgbox_win.c } - +#endif -Index: src/libs/uio/io.c +Index: src/libs/log/msgbox_stub.c =================================================================== ---- src/libs/uio/io.c (revision 3779) -+++ src/libs/uio/io.c (working copy) -@@ -35,6 +35,7 @@ - #include "mem.h" - #include "uioutils.h" - #include "uioport.h" -+#include "../log.h" - #ifdef uio_MEM_DEBUG - # include "memdebug.h" - #endif -@@ -193,6 +194,7 @@ - errno = EINVAL; - return NULL; - } -+ log_add (log_Info, "uio_open %s", sourcePath); - handle = uio_open(sourceDir, sourcePath, - ((flags & uio_MOUNT_RDONLY) == uio_MOUNT_RDONLY ? - O_RDONLY : O_RDWR) -@@ -201,12 +203,14 @@ - #endif - , 0); - if (handle == NULL) { -+ log_add (log_Info, "uio_open failed for %s", sourcePath); - // errno is set - return NULL; - } - } +--- src/libs/log/msgbox_stub.c (revision 3779) ++++ src/libs/log/msgbox_stub.c (working copy) +@@ -16,6 +16,9 @@ - handler = uio_getFileSystemHandler(fsType); -+ log_add (log_Info, "uio_getFileSystemHandler %p", handler); - if (handler == NULL) { - if (handle) - uio_close(handle); -@@ -800,6 +804,7 @@ - &readMountInfo, &readPDirHandle, NULL, - &writeMountInfo, &writePDirHandle, NULL, &name) == -1) { - // errno is set -+ log_add (log_Info, "uio_open: uio_getPhysicalAccess failed for '%s'", path); - return NULL; - } - -@@ -826,6 +831,7 @@ - uio_PDirHandle_unref(readPDirHandle); - uio_PDirHandle_unref(writePDirHandle); - errno = EEXIST; -+ log_add (log_Info, "uio_open: O_CREAT | O_EXCL: file already exists '%s'", name); - return NULL; - } - if ((flags & O_TRUNC) == O_TRUNC) { -@@ -842,6 +848,7 @@ - uio_PDirHandle_unref(readPDirHandle); - uio_PDirHandle_unref(writePDirHandle); - errno = savedErrno; -+ log_add (log_Info, "uio_open: uio_copyFilePhysical failed '%s'", name); - return NULL; - } - } -@@ -863,6 +870,7 @@ - handle = (pDirHandle->pRoot->handler->open)(pDirHandle, name, flags, mode); - // Also adds a new entry to the physical dir if appropriate. - if (handle == NULL) { -+ log_add (log_Info, "uio_open: open file failed '%s'", name); - int savedErrno = errno; - uio_free(name); - uio_PDirHandle_unref(pDirHandle); -Index: src/libs/uio/zip/zip.c -=================================================================== ---- src/libs/uio/zip/zip.c (revision 3779) -+++ src/libs/uio/zip/zip.c (working copy) -@@ -1366,6 +1366,10 @@ - gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]); - break; - } -+ case 0x7875: // 'Unix string UID/GID' -+ // Just skip it -+ break; -+ - default: - #ifdef DEBUG - fprintf(stderr, "Debug: Extra field 0x%04x unsupported, " -Index: src/libs/md5/md5.c -=================================================================== ---- src/libs/md5/md5.c (revision 3779) -+++ src/libs/md5/md5.c (working copy) -@@ -21,7 +21,7 @@ + #include "msgbox.h" + #include "loginternal.h" ++#ifdef ANDROID ++#include ++#endif - /* Written by Ulrich Drepper , 1995. */ - --#include -+#include "config.h" - - #include "md5.h" - -Index: src/libs/input/input_common.h -=================================================================== ---- src/libs/input/input_common.h (revision 3779) -+++ src/libs/input/input_common.h (working copy) -@@ -31,7 +31,7 @@ - extern int TFB_InitInput (int driver, int flags); - extern void TFB_UninitInput (void); - --#define MAX_FLIGHT_ALTERNATES 2 -+#define MAX_FLIGHT_ALTERNATES 3 - - extern void TFB_SetInputVectors (volatile int menu[], int num_menu, - volatile int flight[], int num_templ, int num_flight); -Index: src/libs/input/sdl/input.c -=================================================================== ---- src/libs/input/sdl/input.c (revision 3779) -+++ src/libs/input/sdl/input.c (working copy) -@@ -86,6 +86,7 @@ - "weapon", - "special", - "escape", -+ "thrust", - NULL - }; - -@@ -186,7 +187,7 @@ - directory. */ - LoadResourceIndex (contentDir, "uqm.key", "keys."); - } -- -+ - register_flight_controls (); - - return; -Index: src/libs/input/sdl/vcontrol.c -=================================================================== ---- src/libs/input/sdl/vcontrol.c (revision 3779) -+++ src/libs/input/sdl/vcontrol.c (working copy) -@@ -46,6 +46,7 @@ - typedef struct vcontrol_joystick_axis { - keybinding *neg, *pos; - int polarity; -+ int value; - } axis_type; - - typedef struct vcontrol_joystick_hat { -@@ -66,7 +67,7 @@ - - #endif /* HAVE_JOYSTICK */ - --static unsigned int joycount; -+static unsigned int joycount = 0; - static unsigned int num_sdl_keys = 0; - static keybinding **bindings = NULL; - -@@ -141,6 +142,7 @@ - for (j = 0; j < axes; j++) - { - x->axes[j].neg = x->axes[j].pos = NULL; -+ x->axes[j].polarity = x->axes[j].value = 0; - } - for (j = 0; j < hats; j++) - { -@@ -818,6 +820,7 @@ - int t; - if (!joysticks[port].stick) - return; -+ joysticks[port].axes[axis].value = value; - t = joysticks[port].threshold; - if (value > t) - { -@@ -894,6 +897,25 @@ - #endif /* HAVE_JOYSTICK */ - } - -+int -+VControl_GetJoyAxis(int port, int axis) -+{ -+#ifdef HAVE_JOYSTICK -+ if( joycount <= port ) -+ return 0; -+ if (!joysticks[port].stick || joysticks[port].numaxes <= axis ) -+ return 0; -+ return joysticks[port].axes[axis].value; -+#else -+ return 0; -+#endif /* HAVE_JOYSTICK */ -+}; -+ -+int VControl_GetJoysticksAmount() -+{ -+ return joycount; -+}; -+ void - VControl_ResetInput (void) - { -Index: src/libs/input/sdl/vcontrol.h -=================================================================== ---- src/libs/input/sdl/vcontrol.h (revision 3779) -+++ src/libs/input/sdl/vcontrol.h (working copy) -@@ -76,6 +76,9 @@ - void VControl_ProcessJoyAxis (int port, int axis, int value); - void VControl_ProcessJoyHat (int port, int which, Uint8 value); - -+int VControl_GetJoyAxis(int port, int axis); -+int VControl_GetJoysticksAmount(); -+ - /* Force the input into the blank state. For preventing "sticky" keys. */ - void VControl_ResetInput (void); - + log_displayBox (const /*UTF-8*/char *title, int isError, +@@ -26,6 +29,9 @@ + // So just inform the user of our predicament + fprintf (streamOut, "Do not know how to display %s box\n", + isError ? "an error" : "a"); ++#ifdef ANDROID ++ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg ); ++#endif + + // Suppress the compiler warnings in any case. + (void)title; Index: src/config_unix.h =================================================================== --- src/config_unix.h (revision 0) @@ -640,760 +733,6 @@ Index: src/config_unix.h + +#endif /* _CONFIG_UNIX_H */ + -Index: src/uqm/hyper.c -=================================================================== ---- src/uqm/hyper.c (revision 3779) -+++ src/uqm/hyper.c (working copy) -@@ -1685,7 +1685,6 @@ - Color OldColor; - CONTEXT OldContext; - MENU_STATE MenuState; -- - UnbatchGraphics (); - - OldContext = SetContext (SpaceContext); -Index: src/uqm/intro.c -=================================================================== ---- src/uqm/intro.c (revision 3779) -+++ src/uqm/intro.c (working copy) -@@ -751,7 +751,9 @@ - pis.MovieFrame = -1; - pis.StartTime = GetTimeCounter (); - pis.LastSyncTime = pis.StartTime; -+ TFB_SetOnScreenKeyboard_Hidden (); - DoInput (&pis, TRUE); -+ TFB_SetOnScreenKeyboard_Menu(); - - SleepThreadUntil (FadeMusic (0, ONE_SECOND)); - StopMusic (); -@@ -839,7 +841,9 @@ - vis.InputFunc = DoVideoInput; - vis.CurVideo = ref; - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); -+ TFB_SetOnScreenKeyboard_Hidden (); - DoInput (&vis, TRUE); -+ TFB_SetOnScreenKeyboard_Menu (); - - StopLegacyVideo (ref); - FadeClearScreen (); -@@ -855,6 +859,7 @@ - { - return FALSE; - } -+ - if (!strcmp (resType, "STRTAB")) - { - STRING pres = CaptureStringTable (LoadStringTable (res)); -Index: src/uqm/controls.h -=================================================================== ---- src/uqm/controls.h (revision 3779) -+++ src/uqm/controls.h (working copy) -@@ -36,6 +36,7 @@ - KEY_WEAPON, - KEY_SPECIAL, - KEY_ESCAPE, -+ KEY_THRUST, - NUM_KEYS - }; - enum { -@@ -90,13 +91,14 @@ - #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5)) - #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) - --BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player); -+BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */); - BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player); - - extern CONTROLLER_INPUT_STATE CurrentInputState; - extern CONTROLLER_INPUT_STATE PulsedInputState; - extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; - extern CONTROL_TEMPLATE PlayerControls[]; -+extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu; - - void UpdateInputState (void); - extern void FlushInput (void); -@@ -116,6 +118,8 @@ - BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput); - BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); - -+extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player); -+ - void DoPopupWindow(const char *msg); - - typedef void (InputFrameCallback) (void); -Index: src/uqm/intel.c -=================================================================== ---- src/uqm/intel.c (revision 3779) -+++ src/uqm/intel.c (working copy) -@@ -45,10 +45,10 @@ - // Allow a player to warp-escape in cyborg mode - if (StarShipPtr->playerNr == RPG_PLAYER_NUM) - InputState |= CurrentInputToBattleInput ( -- context->playerNr) & BATTLE_ESCAPE; -+ context->playerNr, -1) & BATTLE_ESCAPE; - } - else -- InputState = CurrentInputToBattleInput (context->playerNr); -+ InputState = CurrentInputToBattleInput (context->playerNr, -1); - } - else if (!(PlayerControl[context->playerNr] & PSYTRON_CONTROL)) - InputState = 0; -Index: src/uqm/supermelee/melee.c -=================================================================== ---- src/uqm/supermelee/melee.c (revision 3779) -+++ src/uqm/supermelee/melee.c (working copy) -@@ -2074,7 +2074,7 @@ - PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING; - Melee_LocalChange_team (&MenuState, 0, - MenuState.load.preBuiltList[0]); -- PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING; -+ PlayerControl[1] = HUMAN_CONTROL | STANDARD_RATING; // COMPUTER_CONTROL | STANDARD_RATING; - Melee_LocalChange_team (&MenuState, 1, - MenuState.load.preBuiltList[1]); - } -Index: src/uqm/comm/umgah/umgahc.c -=================================================================== ---- src/uqm/comm/umgah/umgahc.c (revision 3779) -+++ src/uqm/comm/umgah/umgahc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../umgah/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/talkpet/talkpet.c -=================================================================== ---- src/uqm/comm/talkpet/talkpet.c (revision 3779) -+++ src/uqm/comm/talkpet/talkpet.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../talkpet/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/thradd/thraddc.c -=================================================================== ---- src/uqm/comm/thradd/thraddc.c (revision 3779) -+++ src/uqm/comm/thradd/thraddc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../thradd/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/melnorm/melnorm.c -=================================================================== ---- src/uqm/comm/melnorm/melnorm.c (revision 3779) -+++ src/uqm/comm/melnorm/melnorm.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../melnorm/strings.h" - - #include "uqm/gameev.h" - #include "uqm/shipcont.h" -Index: src/uqm/comm/yehat/yehatc.c -=================================================================== ---- src/uqm/comm/yehat/yehatc.c (revision 3779) -+++ src/uqm/comm/yehat/yehatc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../yehat/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/orz/orzc.c -=================================================================== ---- src/uqm/comm/orz/orzc.c (revision 3779) -+++ src/uqm/comm/orz/orzc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../orz/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/urquan/urquanc.c -=================================================================== ---- src/uqm/comm/urquan/urquanc.c (revision 3779) -+++ src/uqm/comm/urquan/urquanc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../urquan/strings.h" - - static LOCDATA urquan_desc = - { -Index: src/uqm/comm/slyhome/slyhome.c -=================================================================== ---- src/uqm/comm/slyhome/slyhome.c (revision 3779) -+++ src/uqm/comm/slyhome/slyhome.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../slyhome/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/comandr/comandr.c -=================================================================== ---- src/uqm/comm/comandr/comandr.c (revision 3779) -+++ src/uqm/comm/comandr/comandr.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../comandr/strings.h" - - #include "uqm/setup.h" - #include "uqm/sis.h" -Index: src/uqm/comm/blackur/blackurc.c -=================================================================== ---- src/uqm/comm/blackur/blackurc.c (revision 3779) -+++ src/uqm/comm/blackur/blackurc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../blackur/strings.h" - - static LOCDATA blackurq_desc = - { -Index: src/uqm/comm/mycon/myconc.c -=================================================================== ---- src/uqm/comm/mycon/myconc.c (revision 3779) -+++ src/uqm/comm/mycon/myconc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../mycon/strings.h" - - #include "uqm/gameev.h" - #include "libs/mathlib.h" -Index: src/uqm/comm/spathi/spathic.c -=================================================================== ---- src/uqm/comm/spathi/spathic.c (revision 3779) -+++ src/uqm/comm/spathi/spathic.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../spathi/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/druuge/druugec.c -=================================================================== ---- src/uqm/comm/druuge/druugec.c (revision 3779) -+++ src/uqm/comm/druuge/druugec.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../druuge/strings.h" - - #include "uqm/build.h" - #include "uqm/setup.h" -Index: src/uqm/comm/syreen/syreenc.c -=================================================================== ---- src/uqm/comm/syreen/syreenc.c (revision 3779) -+++ src/uqm/comm/syreen/syreenc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../syreen/strings.h" - - #include "uqm/build.h" - #include "uqm/setup.h" -Index: src/uqm/comm/chmmr/chmmrc.c -=================================================================== ---- src/uqm/comm/chmmr/chmmrc.c (revision 3779) -+++ src/uqm/comm/chmmr/chmmrc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../chmmr/strings.h" - - #include "uqm/build.h" - #include "uqm/hyper.h" -Index: src/uqm/comm/slyland/slyland.c -=================================================================== ---- src/uqm/comm/slyland/slyland.c (revision 3779) -+++ src/uqm/comm/slyland/slyland.c (working copy) -@@ -16,10 +16,10 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#include "../slyland/strings.h" -+#include - #include "../commall.h" --#include - #include "resinst.h" --#include "strings.h" - - #include "options.h" - #include "uqm/battle.h" -Index: src/uqm/comm/ilwrath/ilwrathc.c -=================================================================== ---- src/uqm/comm/ilwrath/ilwrathc.c (revision 3779) -+++ src/uqm/comm/ilwrath/ilwrathc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../ilwrath/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/supox/supoxc.c -=================================================================== ---- src/uqm/comm/supox/supoxc.c (revision 3779) -+++ src/uqm/comm/supox/supoxc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../supox/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/vux/vuxc.c -=================================================================== ---- src/uqm/comm/vux/vuxc.c (revision 3779) -+++ src/uqm/comm/vux/vuxc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../vux/strings.h" - - static LOCDATA vux_desc = - { -Index: src/uqm/comm/zoqfot/zoqfotc.c -=================================================================== ---- src/uqm/comm/zoqfot/zoqfotc.c (revision 3779) -+++ src/uqm/comm/zoqfot/zoqfotc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../zoqfot/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/shofixt/shofixt.c -=================================================================== ---- src/uqm/comm/shofixt/shofixt.c (revision 3779) -+++ src/uqm/comm/shofixt/shofixt.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../shofixt/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/pkunk/pkunkc.c -=================================================================== ---- src/uqm/comm/pkunk/pkunkc.c (revision 3779) -+++ src/uqm/comm/pkunk/pkunkc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../pkunk/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/rebel/rebel.c -=================================================================== ---- src/uqm/comm/rebel/rebel.c (revision 3779) -+++ src/uqm/comm/rebel/rebel.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../yehat/resinst.h" --#include "strings.h" -+#include "../rebel/strings.h" - - #include "uqm/build.h" - -Index: src/uqm/comm/arilou/arilouc.c -=================================================================== ---- src/uqm/comm/arilou/arilouc.c (revision 3779) -+++ src/uqm/comm/arilou/arilouc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../arilou/strings.h" - - #include "uqm/gameev.h" - -Index: src/uqm/comm/spahome/spahome.c -=================================================================== ---- src/uqm/comm/spahome/spahome.c (revision 3779) -+++ src/uqm/comm/spahome/spahome.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../spathi/resinst.h" --#include "strings.h" -+#include "../spahome/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/comm/starbas/starbas.c -=================================================================== ---- src/uqm/comm/starbas/starbas.c (revision 3779) -+++ src/uqm/comm/starbas/starbas.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "../comandr/resinst.h" --#include "strings.h" -+#include "../starbas/strings.h" - - #include "uqm/build.h" - #include "uqm/setup.h" -Index: src/uqm/comm/utwig/utwigc.c -=================================================================== ---- src/uqm/comm/utwig/utwigc.c (revision 3779) -+++ src/uqm/comm/utwig/utwigc.c (working copy) -@@ -18,7 +18,7 @@ - - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../utwig/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: src/uqm/gameinp.c -=================================================================== ---- src/uqm/gameinp.c (revision 3779) -+++ src/uqm/gameinp.c (working copy) -@@ -16,6 +16,7 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#include - #include "controls.h" - #include "battlecontrols.h" - #include "init.h" -@@ -33,11 +34,14 @@ - #include "libs/timelib.h" - #include "libs/threadlib.h" - -- -+#ifdef ANDROID -+#define ACCELERATION_INCREMENT (ONE_SECOND) -+#define MENU_REPEAT_DELAY (ONE_SECOND) -+#else - #define ACCELERATION_INCREMENT (ONE_SECOND / 12) - #define MENU_REPEAT_DELAY (ONE_SECOND / 2) -+#endif - -- - typedef struct - { - BOOLEAN (*InputFunc) (void *pInputState); -@@ -67,6 +71,7 @@ - - volatile BOOLEAN ExitRequested; - volatile BOOLEAN GamePaused; -+volatile BOOLEAN OnScreenKeyboardLocked; - - static InputFrameCallback *inputCallback; - -@@ -416,16 +421,10 @@ - } - - static BATTLE_INPUT_STATE --ControlInputToBattleInput (const int *keyState) -+ControlInputToBattleInput (const int *keyState, COUNT player, int direction) - { - BATTLE_INPUT_STATE InputState = 0; - -- if (keyState[KEY_UP]) -- InputState |= BATTLE_THRUST; -- if (keyState[KEY_LEFT]) -- InputState |= BATTLE_LEFT; -- if (keyState[KEY_RIGHT]) -- InputState |= BATTLE_RIGHT; - if (keyState[KEY_WEAPON]) - InputState |= BATTLE_WEAPON; - if (keyState[KEY_SPECIAL]) -@@ -435,21 +434,35 @@ - if (keyState[KEY_DOWN]) - InputState |= BATTLE_DOWN; - -+ if(direction < 0) -+ { -+ if (keyState[KEY_LEFT]) -+ InputState |= BATTLE_LEFT; -+ if (keyState[KEY_RIGHT]) -+ InputState |= BATTLE_RIGHT; -+ if (keyState[KEY_UP]) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ InputState |= GetDirectionalJoystickInput(direction, player); -+ } -+ - return InputState; - } - - BATTLE_INPUT_STATE --CurrentInputToBattleInput (COUNT player) -+CurrentInputToBattleInput (COUNT player, int direction) - { - return ControlInputToBattleInput( -- CurrentInputState.key[PlayerControls[player]]); -+ CurrentInputState.key[PlayerControls[player]], player, direction); - } - - BATTLE_INPUT_STATE - PulsedInputToBattleInput (COUNT player) - { - return ControlInputToBattleInput( -- PulsedInputState.key[PlayerControls[player]]); -+ PulsedInputState.key[PlayerControls[player]], player, -1); - } - - BOOLEAN -@@ -494,3 +507,113 @@ - return result; - } - -+// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits -+// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads -+ -+#ifndef M_PI -+#define M_PI 3.14159265358979323846 -+#endif -+enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0), SHIP_DIRECTIONS = 16 }; -+ -+static inline int atan2i(int y, int x) -+{ -+ int angle; -+ int abs_y = abs(y); -+ if( abs_y == 0 ) -+ abs_y = 1; -+ if (x>=0) -+ { -+ angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); -+ } -+ else -+ { -+ angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); -+ } -+ if (y < 0) -+ return(-angle); // negate if in quad III or IV -+ else -+ return(angle); -+} -+ -+ -+BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player) -+{ -+ BATTLE_INPUT_STATE InputState = 0; -+ static BOOLEAN JoystickThrust[NUM_PLAYERS] = { FALSE, FALSE }; -+ static BOOLEAN JoystickTapFlag[NUM_PLAYERS] = { FALSE, FALSE }; -+ static TimeCount JoystickTapTime[NUM_PLAYERS] = { 0, 0 }; -+ -+ if (CurrentInputState.key[PlayerControls[player]][KEY_THRUST]) -+ InputState |= BATTLE_THRUST; -+ -+ if(VControl_GetJoysticksAmount() <= 0 || !optDirectionalJoystick) -+ { -+ if (CurrentInputState.key[PlayerControls[player]][KEY_LEFT]) -+ InputState |= BATTLE_LEFT; -+ if (CurrentInputState.key[PlayerControls[player]][KEY_RIGHT]) -+ InputState |= BATTLE_RIGHT; -+ if (CurrentInputState.key[PlayerControls[player]][KEY_UP]) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ int axisX = VControl_GetJoyAxis(0, player * 2), axisY = VControl_GetJoyAxis(0, player * 2 + 1); -+ -+ if( axisX == 0 && axisY == 0 ) -+ { -+ // Some basic gamepad input support -+ axisX = VControl_GetJoyAxis(2, player * 2); -+ axisY = VControl_GetJoyAxis(2, player * 2 + 1); -+ if( axisX != 0 || axisY != 0 ) -+ { -+ if( !JoystickTapFlag[player] ) -+ TFB_SetOnScreenKeyboard_Hidden (); // Gamepad used - hide on-screen keys -+ JoystickTapFlag[player] = TRUE; -+ JoystickThrust[player] = FALSE; -+ } -+ } -+ -+ if( axisX != 0 || axisY != 0 ) -+ { -+ int angle = atan2i(axisY, axisX), diff; -+ // Convert it to 16 directions used by Melee -+ angle += atan2i_PI / SHIP_DIRECTIONS; -+ if( angle < 0 ) -+ angle += atan2i_PI * 2; -+ if( angle > atan2i_PI * 2 ) -+ angle -= atan2i_PI * 2; -+ angle = angle * SHIP_DIRECTIONS / atan2i_PI / 2; -+ -+ diff = angle - direction - SHIP_DIRECTIONS / 4; -+ while( diff >= SHIP_DIRECTIONS ) -+ diff -= SHIP_DIRECTIONS; -+ while( diff < 0 ) -+ diff += SHIP_DIRECTIONS; -+ -+ if( diff < SHIP_DIRECTIONS / 2 ) -+ InputState |= BATTLE_LEFT; -+ if( diff > SHIP_DIRECTIONS / 2 ) -+ InputState |= BATTLE_RIGHT; -+ -+ if( !JoystickTapFlag[player] ) -+ { -+ JoystickTapFlag[player] = TRUE; -+ if( GetTimeCounter() < JoystickTapTime[player] + ONE_SECOND ) -+ JoystickThrust[player] = !JoystickThrust[player]; -+ else -+ JoystickThrust[player] = TRUE; -+ } -+ if( JoystickThrust[player] ) -+ InputState |= BATTLE_THRUST; -+ } -+ else -+ { -+ if( JoystickTapFlag[player] ) -+ { -+ JoystickTapFlag[player] = FALSE; -+ JoystickTapTime[player] = GetTimeCounter(); -+ } -+ } -+ } -+ return InputState; -+} -Index: src/uqm/battle.c -=================================================================== ---- src/uqm/battle.c (revision 3779) -+++ src/uqm/battle.c (working copy) -@@ -16,6 +16,10 @@ - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -+#ifdef ANDROID -+#include -+#endif -+ - #include "battle.h" - - #include "battlecontrols.h" -@@ -44,6 +48,8 @@ - #include "libs/graphics/gfx_common.h" - #include "libs/log.h" - #include "libs/mathlib.h" -+#include "globdata.h" -+#include "libs/input/sdl/vcontrol.h" - - - BYTE battle_counter[NUM_SIDES]; -@@ -138,7 +144,8 @@ - frameInputHuman (HumanInputContext *context, STARSHIP *StarShipPtr) - { - (void) StarShipPtr; -- return CurrentInputToBattleInput (context->playerNr); -+ -+ return CurrentInputToBattleInput (context->playerNr, StarShipPtr ? StarShipPtr->ShipFacing : -1); - } - - static void -@@ -208,8 +215,11 @@ - StarShipPtr->ship_input_state |= SPECIAL; - - if (CanRunAway && cur_player == 0 && -- (InputState & BATTLE_ESCAPE)) -+ ((InputState & BATTLE_ESCAPE) || EmergencyEscapeWarpUnitActivatedFromMenu)) -+ { -+ EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; - DoRunAway (StarShipPtr); -+ } - } - } - -@@ -397,6 +407,10 @@ - { - SIZE num_ships; - -+ TFB_SetOnScreenKeyboard_Melee (); -+ if (PlayerControl[1] & HUMAN_CONTROL) { -+ TFB_SetOnScreenKeyboard_TwoPlayersMelee (); -+ } - - #if !(DEMO_MODE || CREATE_JOURNAL) - if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) { -@@ -506,7 +520,7 @@ - UninitShips (); - FreeBattleSong (); - -- -+ TFB_SetOnScreenKeyboard_Menu (); - return (BOOLEAN) (num_ships < 0); - } - -Index: src/uqm/menu.c -=================================================================== ---- src/uqm/menu.c (revision 3779) -+++ src/uqm/menu.c (working copy) -@@ -503,7 +503,7 @@ - s.origin.x = RADAR_X - r.corner.x; - s.origin.y = RADAR_Y - r.corner.y; - r.corner.x = s.origin.x - 1; -- r.corner.y = s.origin.y - 11; -+ r.corner.y = s.origin.y - 40; - r.extent.width = RADAR_WIDTH + 2; - BatchGraphics (); - SetContextForeGroundColor ( Index: src/uqm/shipstat.c =================================================================== --- src/uqm/shipstat.c (revision 3779) @@ -1573,254 +912,279 @@ Index: src/uqm/shipstat.c } } -Index: src/uqm/status.c +Index: src/uqm/gameinp.c =================================================================== ---- src/uqm/status.c (revision 3779) -+++ src/uqm/status.c (working copy) -@@ -323,7 +323,7 @@ - StarShipPtr->RaceDescPtr->characteristics.energy_wait; +--- src/uqm/gameinp.c (revision 3779) ++++ src/uqm/gameinp.c (working copy) +@@ -16,6 +16,7 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ - DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], -- 0, energy_delta); -+ 0, energy_delta, StarShipPtr->playerNr); - } ++#include + #include "controls.h" + #include "battlecontrols.h" + #include "init.h" +@@ -33,11 +34,14 @@ + #include "libs/timelib.h" + #include "libs/threadlib.h" - return (retval); -@@ -365,7 +365,7 @@ - } +- ++#ifdef ANDROID ++#define ACCELERATION_INCREMENT (ONE_SECOND) ++#define MENU_REPEAT_DELAY (ONE_SECOND) ++#else + #define ACCELERATION_INCREMENT (ONE_SECOND / 12) + #define MENU_REPEAT_DELAY (ONE_SECOND / 2) ++#endif - DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], -- crew_delta, 0); -+ crew_delta, 0, StarShipPtr->playerNr); - - return (retval); - } -Index: src/uqm/status.h -=================================================================== ---- src/uqm/status.h (revision 3779) -+++ src/uqm/status.h (working copy) -@@ -38,9 +38,15 @@ - #define CAPTAIN_YOFFS (SHIP_INFO_HEIGHT + 4) - #define CAPTAIN_WIDTH 55 - #define CAPTAIN_HEIGHT 30 --#define SHIP_STATUS_HEIGHT (STATUS_HEIGHT >> 1) --#define BAD_GUY_YOFFS 0 --#define GOOD_GUY_YOFFS SHIP_STATUS_HEIGHT -+#define SHIP_STATUS_HEIGHT ((STATUS_HEIGHT >> 1) - 17) -+#define BAD_GUY_YOFFS (-1) -+#define GOOD_GUY_YOFFS (STATUS_HEIGHT - SHIP_STATUS_HEIGHT) -+#define HORIZ_CREW_ENERGY_SIZE 18 -+#define HORIZ_CREW_XOFFS 2 -+#define BAD_GUY_HORIZ_CREW_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT + (HORIZ_CREW_ENERGY_SIZE >> 1)) -+#define GOOD_GUY_HORIZ_CREW_YOFFS (GOOD_GUY_YOFFS - HORIZ_CREW_ENERGY_SIZE + 1) -+#define BAD_GUY_HORIZ_ENERGY_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT) -+#define GOOD_GUY_HORIZ_ENERGY_YOFFS (GOOD_GUY_YOFFS - (HORIZ_CREW_ENERGY_SIZE >> 1) + 1) - #define STARCON_TEXT_HEIGHT 7 - #define TINY_TEXT_HEIGHT 9 - -@@ -58,7 +64,7 @@ - RECT *pClipRect); - // StarShipPtr or pClipRect can be NULL - extern void DeltaStatistics (SHIP_INFO *ShipInfoPtr, COORD y_offs, -- SIZE crew_delta, SIZE energy_delta); -+ SIZE crew_delta, SIZE energy_delta, SIZE player_num); - extern void DrawBattleCrewAmount (SHIP_INFO *ShipInfoPtr, COORD y_offs); - - extern void DrawCaptainsWindow (STARSHIP *StarShipPtr); -Index: src/uqm/confirm.c -=================================================================== ---- src/uqm/confirm.c (revision 3779) -+++ src/uqm/confirm.c (working copy) -@@ -32,9 +32,11 @@ - #include - - --#define CONFIRM_WIN_WIDTH 80 -+#define CONFIRM_WIN_WIDTH 160 - #define CONFIRM_WIN_HEIGHT 22 - -+BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; -+ - static void - DrawConfirmationWindow (BOOLEAN answer) +- + typedef struct { -@@ -65,6 +67,8 @@ - font_DrawText (&t); - t.baseline.x += (r.extent.width >> 1); - t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 2); // "No" -+ if (GLOBAL (CurrentActivity) & IN_BATTLE) -+ t.pStr = "Escape unit"; // GAME_STRING (QUITMENU_STRING_BASE + 3); // TODO: modify gamestrings.txt - SetContextForeGroundColor (answer ? MENU_TEXT_COLOR : MENU_HIGHLIGHT_COLOR); - font_DrawText (&t); + BOOLEAN (*InputFunc) (void *pInputState); +@@ -67,6 +71,7 @@ -@@ -110,8 +114,16 @@ + volatile BOOLEAN ExitRequested; + volatile BOOLEAN GamePaused; ++volatile BOOLEAN OnScreenKeyboardLocked; - FlushInput (); - done = FALSE; -+ -+ #ifdef ANDROID -+ if ( !(GLOBAL (CurrentActivity) & IN_BATTLE) ) { -+ /* Abort immediately */ -+ response = TRUE; -+ done = TRUE; -+ } -+ #endif - -- do { -+ while (!done) { - // Forbid recursive calls or pausing here! - ExitRequested = FALSE; - GamePaused = FALSE; -@@ -138,7 +150,7 @@ - PlayMenuSound (MENU_SOUND_MOVE); - } - SleepThread (ONE_SECOND / 30); -- } while (!done); -+ } + static InputFrameCallback *inputCallback; - // Restore the screen under the confirmation window - DrawStamp (&s); -@@ -151,6 +163,8 @@ - } - else - { -+ if (GLOBAL (CurrentActivity) & IN_BATTLE) -+ EmergencyEscapeWarpUnitActivatedFromMenu = TRUE; - result = FALSE; - } - ExitRequested = FALSE; -Index: src/uqm/starcon.c -=================================================================== ---- src/uqm/starcon.c (revision 3779) -+++ src/uqm/starcon.c (working copy) -@@ -218,6 +218,7 @@ - InitGameClock (); - AddInitialGameEvents(); - -+ TFB_SetOnScreenKeyboard_Melee (); - do - { - #ifdef DEBUG -Index: src/uqm/planets/solarsys.c -=================================================================== ---- src/uqm/planets/solarsys.c (revision 3779) -+++ src/uqm/planets/solarsys.c (working copy) -@@ -837,18 +837,19 @@ - static void - ProcessShipControls (void) - { -- COUNT index; -+ COUNT index = GetFrameIndex (GLOBAL (ShipStamp.frame));; - SIZE delta_x, delta_y; -+ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); - -- if (CurrentInputState.key[PlayerControls[0]][KEY_UP]) -+ if (InputState & BATTLE_THRUST) - delta_y = -1; - else - delta_y = 0; - - delta_x = 0; -- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) -+ if (InputState & BATTLE_LEFT) - delta_x -= 1; -- if (CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) -+ if (InputState & BATTLE_RIGHT) - delta_x += 1; - - if (delta_x || delta_y < 0) -@@ -861,7 +862,6 @@ - else - delta_y = 0; - -- index = GetFrameIndex (GLOBAL (ShipStamp.frame)); - if (pSolarSysState->turn_counter) - --pSolarSysState->turn_counter; - else if (delta_x) -@@ -1739,7 +1739,9 @@ - InitSolarSys (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - SolarSysState.InputFunc = DoIpFlight; -+ TFB_SetOnScreenKeyboard_Melee (); - DoInput (&SolarSysState, FALSE); -+ TFB_SetOnScreenKeyboard_Menu (); - UninitSolarSys (); - pSolarSysState = 0; +@@ -416,16 +421,10 @@ } -@@ -1997,13 +1999,17 @@ - if (pSS->InOrbit) - { // CheckShipLocation() or InitSolarSys() sent us to orbital -+ TFB_SetOnScreenKeyboard_Menu (); - EnterPlanetOrbit (); -+ TFB_SetOnScreenKeyboard_Melee (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - pSS->InOrbit = FALSE; - } - else if (cancel || LastActivity == CHECK_LOAD) - { -+ TFB_SetOnScreenKeyboard_Menu (); - SolarSysMenu (); -+ TFB_SetOnScreenKeyboard_Melee (); - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - } - else -Index: src/uqm/planets/pstarmap.c + static BATTLE_INPUT_STATE +-ControlInputToBattleInput (const int *keyState) ++ControlInputToBattleInput (const int *keyState, COUNT player, int direction) + { + BATTLE_INPUT_STATE InputState = 0; + +- if (keyState[KEY_UP]) +- InputState |= BATTLE_THRUST; +- if (keyState[KEY_LEFT]) +- InputState |= BATTLE_LEFT; +- if (keyState[KEY_RIGHT]) +- InputState |= BATTLE_RIGHT; + if (keyState[KEY_WEAPON]) + InputState |= BATTLE_WEAPON; + if (keyState[KEY_SPECIAL]) +@@ -435,21 +434,35 @@ + if (keyState[KEY_DOWN]) + InputState |= BATTLE_DOWN; + ++ if(direction < 0) ++ { ++ if (keyState[KEY_LEFT]) ++ InputState |= BATTLE_LEFT; ++ if (keyState[KEY_RIGHT]) ++ InputState |= BATTLE_RIGHT; ++ if (keyState[KEY_UP]) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ InputState |= GetDirectionalJoystickInput(direction, player); ++ } ++ + return InputState; + } + + BATTLE_INPUT_STATE +-CurrentInputToBattleInput (COUNT player) ++CurrentInputToBattleInput (COUNT player, int direction) + { + return ControlInputToBattleInput( +- CurrentInputState.key[PlayerControls[player]]); ++ CurrentInputState.key[PlayerControls[player]], player, direction); + } + + BATTLE_INPUT_STATE + PulsedInputToBattleInput (COUNT player) + { + return ControlInputToBattleInput( +- PulsedInputState.key[PlayerControls[player]]); ++ PulsedInputState.key[PlayerControls[player]], player, -1); + } + + BOOLEAN +@@ -494,3 +507,121 @@ + return result; + } + ++// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits ++// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads ++ ++#ifndef M_PI ++#define M_PI 3.14159265358979323846 ++#endif ++enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0), SHIP_DIRECTIONS = 16 }; ++ ++static inline int atan2i(int y, int x) ++{ ++ int angle; ++ int abs_y = abs(y); ++ if( abs_y == 0 ) ++ abs_y = 1; ++ if (x>=0) ++ { ++ angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); ++ } ++ else ++ { ++ angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); ++ } ++ if (y < 0) ++ return(-angle); // negate if in quad III or IV ++ else ++ return(angle); ++} ++ ++ ++BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player) ++{ ++ BATTLE_INPUT_STATE InputState = 0; ++ static BOOLEAN JoystickThrust[NUM_PLAYERS] = { FALSE, FALSE }; ++ static BOOLEAN JoystickTapFlag[NUM_PLAYERS] = { FALSE, FALSE }; ++ static TimeCount JoystickTapTime[NUM_PLAYERS] = { 0, 0 }; ++ ++ if (CurrentInputState.key[PlayerControls[player]][KEY_THRUST]) ++ InputState |= BATTLE_THRUST; ++ ++ if(VControl_GetJoysticksAmount() <= 0 || !optDirectionalJoystick) ++ { ++ if (CurrentInputState.key[PlayerControls[player]][KEY_LEFT]) ++ InputState |= BATTLE_LEFT; ++ if (CurrentInputState.key[PlayerControls[player]][KEY_RIGHT]) ++ InputState |= BATTLE_RIGHT; ++ if (CurrentInputState.key[PlayerControls[player]][KEY_UP]) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ int axisX = VControl_GetJoyAxis(0, player * 2), axisY = VControl_GetJoyAxis(0, player * 2 + 1); ++ ++ if( axisX == 0 && axisY == 0 ) ++ { ++ // Some basic gamepad input support ++ axisX = VControl_GetJoyAxis(2, player * 2); ++ axisY = VControl_GetJoyAxis(2, player * 2 + 1); ++ if( abs( axisX ) > 5000 || abs( axisY ) > 5000 ) ++ { ++ if( !JoystickTapFlag[player] ) ++ TFB_SetOnScreenKeyboard_Hidden (); // Gamepad used - hide on-screen keys ++ JoystickTapFlag[player] = TRUE; ++ JoystickThrust[player] = FALSE; ++ // Turning thrust with joystick is uncomfortable ++ //if( abs( axisX ) > 25000 || abs( axisY ) > 25000 ) ++ // JoystickThrust[player] = TRUE; ++ } ++ else ++ { ++ axisX = 0; ++ axisY = 0; ++ } ++ } ++ ++ if( axisX != 0 || axisY != 0 ) ++ { ++ int angle = atan2i(axisY, axisX), diff; ++ // Convert it to 16 directions used by Melee ++ angle += atan2i_PI / SHIP_DIRECTIONS; ++ if( angle < 0 ) ++ angle += atan2i_PI * 2; ++ if( angle > atan2i_PI * 2 ) ++ angle -= atan2i_PI * 2; ++ angle = angle * SHIP_DIRECTIONS / atan2i_PI / 2; ++ ++ diff = angle - direction - SHIP_DIRECTIONS / 4; ++ while( diff >= SHIP_DIRECTIONS ) ++ diff -= SHIP_DIRECTIONS; ++ while( diff < 0 ) ++ diff += SHIP_DIRECTIONS; ++ ++ if( diff < SHIP_DIRECTIONS / 2 ) ++ InputState |= BATTLE_LEFT; ++ if( diff > SHIP_DIRECTIONS / 2 ) ++ InputState |= BATTLE_RIGHT; ++ ++ if( !JoystickTapFlag[player] ) ++ { ++ JoystickTapFlag[player] = TRUE; ++ if( GetTimeCounter() < JoystickTapTime[player] + ONE_SECOND ) ++ JoystickThrust[player] = !JoystickThrust[player]; ++ else ++ JoystickThrust[player] = TRUE; ++ } ++ if( JoystickThrust[player] ) ++ InputState |= BATTLE_THRUST; ++ } ++ else ++ { ++ if( JoystickTapFlag[player] ) ++ { ++ JoystickTapFlag[player] = FALSE; ++ JoystickTapTime[player] = GetTimeCounter(); ++ } ++ } ++ } ++ return InputState; ++} +Index: src/uqm/hyper.c =================================================================== ---- src/uqm/planets/pstarmap.c (revision 3779) -+++ src/uqm/planets/pstarmap.c (working copy) -@@ -1613,7 +1613,9 @@ - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, - TRUE); -+ TFB_SetOnScreenKeyboard_Starmap (); - DoInput (&MenuState, FALSE); -+ TFB_SetOnScreenKeyboard_Menu (); - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - SetDefaultMenuRepeatDelay (); +--- src/uqm/hyper.c (revision 3779) ++++ src/uqm/hyper.c (working copy) +@@ -1685,7 +1685,6 @@ + Color OldColor; + CONTEXT OldContext; + MENU_STATE MenuState; +- + UnbatchGraphics (); -Index: src/uqm/planets/lander.c + OldContext = SetContext (SpaceContext); +Index: src/uqm/intro.c =================================================================== ---- src/uqm/planets/lander.c (revision 3779) -+++ src/uqm/planets/lander.c (working copy) -@@ -1591,15 +1591,15 @@ - if (crew_left) - { - SIZE index = GetFrameIndex (LanderFrame[0]); -+ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); - if (turn_wait) - --turn_wait; -- else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] || -- CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) -+ else if ((InputState & BATTLE_LEFT) || (InputState & BATTLE_RIGHT)) - { - COUNT landerSpeedNumer; - COUNT angle; +--- src/uqm/intro.c (revision 3779) ++++ src/uqm/intro.c (working copy) +@@ -751,7 +751,9 @@ + pis.MovieFrame = -1; + pis.StartTime = GetTimeCounter (); + pis.LastSyncTime = pis.StartTime; ++ TFB_SetOnScreenKeyboard_Hidden (); + DoInput (&pis, TRUE); ++ TFB_SetOnScreenKeyboard_Menu(); -- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) -+ if (InputState & BATTLE_LEFT) - --index; - else - ++index; -@@ -1623,7 +1623,7 @@ - turn_wait = SHUTTLE_TURN_WAIT; - } - -- if (!CurrentInputState.key[PlayerControls[0]][KEY_UP]) -+ if (!(InputState & BATTLE_THRUST)) - { - dx = 0; - dy = 0; -@@ -1938,7 +1938,9 @@ - landerInputState.Initialized = FALSE; - landerInputState.InputFunc = DoPlanetSide; + SleepThreadUntil (FadeMusic (0, ONE_SECOND)); + StopMusic (); +@@ -839,7 +841,9 @@ + vis.InputFunc = DoVideoInput; + vis.CurVideo = ref; SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); -+ TFB_SetOnScreenKeyboard_Melee (); - DoInput (&landerInputState, FALSE); ++ TFB_SetOnScreenKeyboard_Hidden (); + DoInput (&vis, TRUE); + TFB_SetOnScreenKeyboard_Menu (); - if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + StopLegacyVideo (ref); + FadeClearScreen (); +@@ -855,6 +859,7 @@ { + return FALSE; + } ++ + if (!strcmp (resType, "STRTAB")) + { + STRING pres = CaptureStringTable (LoadStringTable (res)); +Index: src/uqm/sis.c +=================================================================== +--- src/uqm/sis.c (revision 3779) ++++ src/uqm/sis.c (working copy) +@@ -1640,7 +1640,7 @@ + GetContextClipRect (&clip_r); + pRect = &temp_r; + temp_r.corner.x = RADAR_X - clip_r.corner.x; +- temp_r.corner.y = RADAR_Y - clip_r.corner.y; ++ temp_r.corner.y = RADAR_Y_LIFTED_UP - clip_r.corner.y; + temp_r.extent.width = RADAR_WIDTH; + temp_r.extent.height = RADAR_HEIGHT; + SetContext (OldContext); Index: src/uqm/setupmenu.c =================================================================== --- src/uqm/setupmenu.c (revision 3779) @@ -1903,6 +1267,834 @@ Index: src/uqm/setupmenu.h OPT_CONSOLETYPE menu, text, cscan, scroll, intro, meleezoom, shield; CONTROL_TEMPLATE player1, player2; int speechvol, musicvol, sfxvol; +Index: src/uqm/intel.c +=================================================================== +--- src/uqm/intel.c (revision 3779) ++++ src/uqm/intel.c (working copy) +@@ -45,10 +45,10 @@ + // Allow a player to warp-escape in cyborg mode + if (StarShipPtr->playerNr == RPG_PLAYER_NUM) + InputState |= CurrentInputToBattleInput ( +- context->playerNr) & BATTLE_ESCAPE; ++ context->playerNr, -1) & BATTLE_ESCAPE; + } + else +- InputState = CurrentInputToBattleInput (context->playerNr); ++ InputState = CurrentInputToBattleInput (context->playerNr, -1); + } + else if (!(PlayerControl[context->playerNr] & PSYTRON_CONTROL)) + InputState = 0; +Index: src/uqm/confirm.c +=================================================================== +--- src/uqm/confirm.c (revision 3779) ++++ src/uqm/confirm.c (working copy) +@@ -32,9 +32,11 @@ + #include + + +-#define CONFIRM_WIN_WIDTH 80 ++#define CONFIRM_WIN_WIDTH 160 + #define CONFIRM_WIN_HEIGHT 22 + ++BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; ++ + static void + DrawConfirmationWindow (BOOLEAN answer) + { +@@ -65,6 +67,8 @@ + font_DrawText (&t); + t.baseline.x += (r.extent.width >> 1); + t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 2); // "No" ++ if (GLOBAL (CurrentActivity) & IN_BATTLE) ++ t.pStr = "Escape unit"; // GAME_STRING (QUITMENU_STRING_BASE + 3); // TODO: modify gamestrings.txt + SetContextForeGroundColor (answer ? MENU_TEXT_COLOR : MENU_HIGHLIGHT_COLOR); + font_DrawText (&t); + +@@ -110,8 +114,16 @@ + + FlushInput (); + done = FALSE; ++ ++ #ifdef ANDROID ++ if ( !(GLOBAL (CurrentActivity) & IN_BATTLE) ) { ++ /* Abort immediately */ ++ response = TRUE; ++ done = TRUE; ++ } ++ #endif + +- do { ++ while (!done) { + // Forbid recursive calls or pausing here! + ExitRequested = FALSE; + GamePaused = FALSE; +@@ -138,7 +150,7 @@ + PlayMenuSound (MENU_SOUND_MOVE); + } + SleepThread (ONE_SECOND / 30); +- } while (!done); ++ } + + // Restore the screen under the confirmation window + DrawStamp (&s); +@@ -151,6 +163,8 @@ + } + else + { ++ if (GLOBAL (CurrentActivity) & IN_BATTLE) ++ EmergencyEscapeWarpUnitActivatedFromMenu = TRUE; + result = FALSE; + } + ExitRequested = FALSE; +Index: src/uqm/battle.c +=================================================================== +--- src/uqm/battle.c (revision 3779) ++++ src/uqm/battle.c (working copy) +@@ -16,6 +16,10 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#ifdef ANDROID ++#include ++#endif ++ + #include "battle.h" + + #include "battlecontrols.h" +@@ -44,6 +48,8 @@ + #include "libs/graphics/gfx_common.h" + #include "libs/log.h" + #include "libs/mathlib.h" ++#include "globdata.h" ++#include "libs/input/sdl/vcontrol.h" + + + BYTE battle_counter[NUM_SIDES]; +@@ -138,7 +144,8 @@ + frameInputHuman (HumanInputContext *context, STARSHIP *StarShipPtr) + { + (void) StarShipPtr; +- return CurrentInputToBattleInput (context->playerNr); ++ ++ return CurrentInputToBattleInput (context->playerNr, StarShipPtr ? StarShipPtr->ShipFacing : -1); + } + + static void +@@ -208,8 +215,11 @@ + StarShipPtr->ship_input_state |= SPECIAL; + + if (CanRunAway && cur_player == 0 && +- (InputState & BATTLE_ESCAPE)) ++ ((InputState & BATTLE_ESCAPE) || EmergencyEscapeWarpUnitActivatedFromMenu)) ++ { ++ EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; + DoRunAway (StarShipPtr); ++ } + } + } + +@@ -397,6 +407,10 @@ + { + SIZE num_ships; + ++ TFB_SetOnScreenKeyboard_Melee (); ++ if (PlayerControl[1] & HUMAN_CONTROL) { ++ TFB_SetOnScreenKeyboard_TwoPlayersMelee (); ++ } + + #if !(DEMO_MODE || CREATE_JOURNAL) + if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) { +@@ -506,7 +520,7 @@ + UninitShips (); + FreeBattleSong (); + +- ++ TFB_SetOnScreenKeyboard_Menu (); + return (BOOLEAN) (num_ships < 0); + } + +Index: src/uqm/globdata.c +=================================================================== +--- src/uqm/globdata.c (revision 3779) ++++ src/uqm/globdata.c (working copy) +@@ -131,7 +131,7 @@ + OldContext = SetContext (RadarContext); + SetContextFGFrame (Screen); + r.corner.x = RADAR_X; +- r.corner.y = RADAR_Y; ++ r.corner.y = RADAR_Y_LIFTED_UP; + r.extent.width = RADAR_WIDTH; + r.extent.height = RADAR_HEIGHT; + SetContextClipRect (&r); +Index: src/uqm/shipyard.c +=================================================================== +--- src/uqm/shipyard.c (revision 3779) ++++ src/uqm/shipyard.c (working copy) +@@ -201,9 +201,9 @@ + OldContext = SetContext (StatusContext); + GetContextClipRect (&r); + s.origin.x = RADAR_X - r.corner.x; +- s.origin.y = RADAR_Y - r.corner.y; ++ s.origin.y = RADAR_Y_LIFTED_UP - r.corner.y; + r.corner.x = s.origin.x - 1; +- r.corner.y = s.origin.y - 11; ++ r.corner.y = s.origin.y - 1; + r.extent.width = RADAR_WIDTH + 2; + r.extent.height = 11; + BatchGraphics (); +@@ -227,10 +227,6 @@ + NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q), + hStarShip); + +- // Draw the ship name, above the ship image. +- s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem); +- DrawStamp (&s); +- + // Draw the ship image. + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); + s.frame = FleetPtr->melee_icon; +@@ -241,6 +237,12 @@ + s.origin.y += (RADAR_HEIGHT >> 1); + DrawStamp (&s); + ++ // Draw the ship name, above the ship image. ++ s.origin.x -= (RADAR_WIDTH >> 1); ++ s.origin.y -= (RADAR_HEIGHT >> 2); ++ s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem); ++ DrawStamp (&s); ++ + // Print the ship cost. + t.align = ALIGN_RIGHT; + t.CharCount = (COUNT)~0; +Index: src/uqm/outfit.c +=================================================================== +--- src/uqm/outfit.c (revision 3779) ++++ src/uqm/outfit.c (working copy) +@@ -55,7 +55,7 @@ + OldContext = SetContext (StatusContext); + GetContextClipRect (&r); + s.origin.x = RADAR_X - r.corner.x; +- s.origin.y = RADAR_Y - r.corner.y; ++ s.origin.y = RADAR_Y_LIFTED_UP - r.corner.y + 10; + r.corner.x = s.origin.x - 1; + r.corner.y = s.origin.y - 11; + r.extent.width = RADAR_WIDTH + 2; +Index: src/uqm/starcon.c +=================================================================== +--- src/uqm/starcon.c (revision 3779) ++++ src/uqm/starcon.c (working copy) +@@ -218,6 +218,7 @@ + InitGameClock (); + AddInitialGameEvents(); + ++ TFB_SetOnScreenKeyboard_Melee (); + do + { + #ifdef DEBUG +Index: src/uqm/status.c +=================================================================== +--- src/uqm/status.c (revision 3779) ++++ src/uqm/status.c (working copy) +@@ -323,7 +323,7 @@ + StarShipPtr->RaceDescPtr->characteristics.energy_wait; + + DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], +- 0, energy_delta); ++ 0, energy_delta, StarShipPtr->playerNr); + } + + return (retval); +@@ -365,7 +365,7 @@ + } + + DeltaStatistics (ShipInfoPtr, status_y_offsets[StarShipPtr->playerNr], +- crew_delta, 0); ++ crew_delta, 0, StarShipPtr->playerNr); + + return (retval); + } +Index: src/uqm/status.h +=================================================================== +--- src/uqm/status.h (revision 3779) ++++ src/uqm/status.h (working copy) +@@ -38,9 +38,15 @@ + #define CAPTAIN_YOFFS (SHIP_INFO_HEIGHT + 4) + #define CAPTAIN_WIDTH 55 + #define CAPTAIN_HEIGHT 30 +-#define SHIP_STATUS_HEIGHT (STATUS_HEIGHT >> 1) +-#define BAD_GUY_YOFFS 0 +-#define GOOD_GUY_YOFFS SHIP_STATUS_HEIGHT ++#define SHIP_STATUS_HEIGHT ((STATUS_HEIGHT >> 1) - 17) ++#define BAD_GUY_YOFFS (-1) ++#define GOOD_GUY_YOFFS (STATUS_HEIGHT - SHIP_STATUS_HEIGHT) ++#define HORIZ_CREW_ENERGY_SIZE 18 ++#define HORIZ_CREW_XOFFS 2 ++#define BAD_GUY_HORIZ_CREW_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT + (HORIZ_CREW_ENERGY_SIZE >> 1)) ++#define GOOD_GUY_HORIZ_CREW_YOFFS (GOOD_GUY_YOFFS - HORIZ_CREW_ENERGY_SIZE + 1) ++#define BAD_GUY_HORIZ_ENERGY_YOFFS (BAD_GUY_YOFFS + SHIP_STATUS_HEIGHT) ++#define GOOD_GUY_HORIZ_ENERGY_YOFFS (GOOD_GUY_YOFFS - (HORIZ_CREW_ENERGY_SIZE >> 1) + 1) + #define STARCON_TEXT_HEIGHT 7 + #define TINY_TEXT_HEIGHT 9 + +@@ -58,7 +64,7 @@ + RECT *pClipRect); + // StarShipPtr or pClipRect can be NULL + extern void DeltaStatistics (SHIP_INFO *ShipInfoPtr, COORD y_offs, +- SIZE crew_delta, SIZE energy_delta); ++ SIZE crew_delta, SIZE energy_delta, SIZE player_num); + extern void DrawBattleCrewAmount (SHIP_INFO *ShipInfoPtr, COORD y_offs); + + extern void DrawCaptainsWindow (STARSHIP *StarShipPtr); +Index: src/uqm/controls.h +=================================================================== +--- src/uqm/controls.h (revision 3779) ++++ src/uqm/controls.h (working copy) +@@ -36,6 +36,7 @@ + KEY_WEAPON, + KEY_SPECIAL, + KEY_ESCAPE, ++ KEY_THRUST, + NUM_KEYS + }; + enum { +@@ -90,13 +91,14 @@ + #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5)) + #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) + +-BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player); ++BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */); + BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player); + + extern CONTROLLER_INPUT_STATE CurrentInputState; + extern CONTROLLER_INPUT_STATE PulsedInputState; + extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; + extern CONTROL_TEMPLATE PlayerControls[]; ++extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu; + + void UpdateInputState (void); + extern void FlushInput (void); +@@ -116,6 +118,8 @@ + BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput); + BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); + ++extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction, int player); ++ + void DoPopupWindow(const char *msg); + + typedef void (InputFrameCallback) (void); +Index: src/uqm/supermelee/melee.c +=================================================================== +--- src/uqm/supermelee/melee.c (revision 3779) ++++ src/uqm/supermelee/melee.c (working copy) +@@ -2074,7 +2074,7 @@ + PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING; + Melee_LocalChange_team (&MenuState, 0, + MenuState.load.preBuiltList[0]); +- PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING; ++ PlayerControl[1] = HUMAN_CONTROL | STANDARD_RATING; // COMPUTER_CONTROL | STANDARD_RATING; + Melee_LocalChange_team (&MenuState, 1, + MenuState.load.preBuiltList[1]); + } +Index: src/uqm/menu.c +=================================================================== +--- src/uqm/menu.c (revision 3779) ++++ src/uqm/menu.c (working copy) +@@ -503,7 +503,7 @@ + s.origin.x = RADAR_X - r.corner.x; + s.origin.y = RADAR_Y - r.corner.y; + r.corner.x = s.origin.x - 1; +- r.corner.y = s.origin.y - 11; ++ r.corner.y = s.origin.y - 40; + r.extent.width = RADAR_WIDTH + 2; + BatchGraphics (); + SetContextForeGroundColor ( +Index: src/uqm/units.h +=================================================================== +--- src/uqm/units.h (revision 3779) ++++ src/uqm/units.h (working copy) +@@ -52,6 +52,7 @@ + #define RADAR_WIDTH (STATUS_WIDTH - 8) + #define RADAR_HEIGHT 53 + #define RADAR_Y (SIS_ORG_Y + SIS_SCREEN_HEIGHT - RADAR_HEIGHT) ++#define RADAR_Y_LIFTED_UP (RADAR_Y - 40) + + #define SIS_TITLE_BOX_WIDTH 57 + #define SIS_TITLE_WIDTH (SIS_TITLE_BOX_WIDTH - 2) +Index: src/uqm/planets/lander.c +=================================================================== +--- src/uqm/planets/lander.c (revision 3779) ++++ src/uqm/planets/lander.c (working copy) +@@ -1591,15 +1591,15 @@ + if (crew_left) + { + SIZE index = GetFrameIndex (LanderFrame[0]); ++ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); + if (turn_wait) + --turn_wait; +- else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] || +- CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) ++ else if ((InputState & BATTLE_LEFT) || (InputState & BATTLE_RIGHT)) + { + COUNT landerSpeedNumer; + COUNT angle; + +- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) ++ if (InputState & BATTLE_LEFT) + --index; + else + ++index; +@@ -1623,7 +1623,7 @@ + turn_wait = SHUTTLE_TURN_WAIT; + } + +- if (!CurrentInputState.key[PlayerControls[0]][KEY_UP]) ++ if (!(InputState & BATTLE_THRUST)) + { + dx = 0; + dy = 0; +@@ -1938,7 +1938,9 @@ + landerInputState.Initialized = FALSE; + landerInputState.InputFunc = DoPlanetSide; + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); ++ TFB_SetOnScreenKeyboard_Melee (); + DoInput (&landerInputState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + + if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) + { +Index: src/uqm/planets/solarsys.c +=================================================================== +--- src/uqm/planets/solarsys.c (revision 3779) ++++ src/uqm/planets/solarsys.c (working copy) +@@ -837,18 +837,19 @@ + static void + ProcessShipControls (void) + { +- COUNT index; ++ COUNT index = GetFrameIndex (GLOBAL (ShipStamp.frame));; + SIZE delta_x, delta_y; ++ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); + +- if (CurrentInputState.key[PlayerControls[0]][KEY_UP]) ++ if (InputState & BATTLE_THRUST) + delta_y = -1; + else + delta_y = 0; + + delta_x = 0; +- if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT]) ++ if (InputState & BATTLE_LEFT) + delta_x -= 1; +- if (CurrentInputState.key[PlayerControls[0]][KEY_RIGHT]) ++ if (InputState & BATTLE_RIGHT) + delta_x += 1; + + if (delta_x || delta_y < 0) +@@ -861,7 +862,6 @@ + else + delta_y = 0; + +- index = GetFrameIndex (GLOBAL (ShipStamp.frame)); + if (pSolarSysState->turn_counter) + --pSolarSysState->turn_counter; + else if (delta_x) +@@ -1739,7 +1739,9 @@ + InitSolarSys (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + SolarSysState.InputFunc = DoIpFlight; ++ TFB_SetOnScreenKeyboard_Melee (); + DoInput (&SolarSysState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + UninitSolarSys (); + pSolarSysState = 0; + } +@@ -1997,13 +1999,17 @@ + + if (pSS->InOrbit) + { // CheckShipLocation() or InitSolarSys() sent us to orbital ++ TFB_SetOnScreenKeyboard_Menu (); + EnterPlanetOrbit (); ++ TFB_SetOnScreenKeyboard_Melee (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + pSS->InOrbit = FALSE; + } + else if (cancel || LastActivity == CHECK_LOAD) + { ++ TFB_SetOnScreenKeyboard_Menu (); + SolarSysMenu (); ++ TFB_SetOnScreenKeyboard_Melee (); + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + } + else +Index: src/uqm/planets/pstarmap.c +=================================================================== +--- src/uqm/planets/pstarmap.c (revision 3779) ++++ src/uqm/planets/pstarmap.c (working copy) +@@ -1613,7 +1613,9 @@ + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, + TRUE); ++ TFB_SetOnScreenKeyboard_Starmap (); + DoInput (&MenuState, FALSE); ++ TFB_SetOnScreenKeyboard_Menu (); + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + SetDefaultMenuRepeatDelay (); + +Index: src/uqm/comm/blackur/blackurc.c +=================================================================== +--- src/uqm/comm/blackur/blackurc.c (revision 3779) ++++ src/uqm/comm/blackur/blackurc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../blackur/strings.h" + + static LOCDATA blackurq_desc = + { +Index: src/uqm/comm/comandr/comandr.c +=================================================================== +--- src/uqm/comm/comandr/comandr.c (revision 3779) ++++ src/uqm/comm/comandr/comandr.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../comandr/strings.h" + + #include "uqm/setup.h" + #include "uqm/sis.h" +Index: src/uqm/comm/mycon/myconc.c +=================================================================== +--- src/uqm/comm/mycon/myconc.c (revision 3779) ++++ src/uqm/comm/mycon/myconc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../mycon/strings.h" + + #include "uqm/gameev.h" + #include "libs/mathlib.h" +Index: src/uqm/comm/spathi/spathic.c +=================================================================== +--- src/uqm/comm/spathi/spathic.c (revision 3779) ++++ src/uqm/comm/spathi/spathic.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../spathi/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/druuge/druugec.c +=================================================================== +--- src/uqm/comm/druuge/druugec.c (revision 3779) ++++ src/uqm/comm/druuge/druugec.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../druuge/strings.h" + + #include "uqm/build.h" + #include "uqm/setup.h" +Index: src/uqm/comm/syreen/syreenc.c +=================================================================== +--- src/uqm/comm/syreen/syreenc.c (revision 3779) ++++ src/uqm/comm/syreen/syreenc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../syreen/strings.h" + + #include "uqm/build.h" + #include "uqm/setup.h" +Index: src/uqm/comm/slyland/slyland.c +=================================================================== +--- src/uqm/comm/slyland/slyland.c (revision 3779) ++++ src/uqm/comm/slyland/slyland.c (working copy) +@@ -16,10 +16,10 @@ + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + ++#include "../slyland/strings.h" ++#include + #include "../commall.h" +-#include + #include "resinst.h" +-#include "strings.h" + + #include "options.h" + #include "uqm/battle.h" +Index: src/uqm/comm/chmmr/chmmrc.c +=================================================================== +--- src/uqm/comm/chmmr/chmmrc.c (revision 3779) ++++ src/uqm/comm/chmmr/chmmrc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../chmmr/strings.h" + + #include "uqm/build.h" + #include "uqm/hyper.h" +Index: src/uqm/comm/ilwrath/ilwrathc.c +=================================================================== +--- src/uqm/comm/ilwrath/ilwrathc.c (revision 3779) ++++ src/uqm/comm/ilwrath/ilwrathc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../ilwrath/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/supox/supoxc.c +=================================================================== +--- src/uqm/comm/supox/supoxc.c (revision 3779) ++++ src/uqm/comm/supox/supoxc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../supox/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/vux/vuxc.c +=================================================================== +--- src/uqm/comm/vux/vuxc.c (revision 3779) ++++ src/uqm/comm/vux/vuxc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../vux/strings.h" + + static LOCDATA vux_desc = + { +Index: src/uqm/comm/zoqfot/zoqfotc.c +=================================================================== +--- src/uqm/comm/zoqfot/zoqfotc.c (revision 3779) ++++ src/uqm/comm/zoqfot/zoqfotc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../zoqfot/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/shofixt/shofixt.c +=================================================================== +--- src/uqm/comm/shofixt/shofixt.c (revision 3779) ++++ src/uqm/comm/shofixt/shofixt.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../shofixt/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/pkunk/pkunkc.c +=================================================================== +--- src/uqm/comm/pkunk/pkunkc.c (revision 3779) ++++ src/uqm/comm/pkunk/pkunkc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../pkunk/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/rebel/rebel.c +=================================================================== +--- src/uqm/comm/rebel/rebel.c (revision 3779) ++++ src/uqm/comm/rebel/rebel.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../yehat/resinst.h" +-#include "strings.h" ++#include "../rebel/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/arilou/arilouc.c +=================================================================== +--- src/uqm/comm/arilou/arilouc.c (revision 3779) ++++ src/uqm/comm/arilou/arilouc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../arilou/strings.h" + + #include "uqm/gameev.h" + +Index: src/uqm/comm/spahome/spahome.c +=================================================================== +--- src/uqm/comm/spahome/spahome.c (revision 3779) ++++ src/uqm/comm/spahome/spahome.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../spathi/resinst.h" +-#include "strings.h" ++#include "../spahome/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/starbas/starbas.c +=================================================================== +--- src/uqm/comm/starbas/starbas.c (revision 3779) ++++ src/uqm/comm/starbas/starbas.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "../comandr/resinst.h" +-#include "strings.h" ++#include "../starbas/strings.h" + + #include "uqm/build.h" + #include "uqm/setup.h" +Index: src/uqm/comm/utwig/utwigc.c +=================================================================== +--- src/uqm/comm/utwig/utwigc.c (revision 3779) ++++ src/uqm/comm/utwig/utwigc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../utwig/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/umgah/umgahc.c +=================================================================== +--- src/uqm/comm/umgah/umgahc.c (revision 3779) ++++ src/uqm/comm/umgah/umgahc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../umgah/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/talkpet/talkpet.c +=================================================================== +--- src/uqm/comm/talkpet/talkpet.c (revision 3779) ++++ src/uqm/comm/talkpet/talkpet.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../talkpet/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/thradd/thraddc.c +=================================================================== +--- src/uqm/comm/thradd/thraddc.c (revision 3779) ++++ src/uqm/comm/thradd/thraddc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../thradd/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/melnorm/melnorm.c +=================================================================== +--- src/uqm/comm/melnorm/melnorm.c (revision 3779) ++++ src/uqm/comm/melnorm/melnorm.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../melnorm/strings.h" + + #include "uqm/gameev.h" + #include "uqm/shipcont.h" +Index: src/uqm/comm/yehat/yehatc.c +=================================================================== +--- src/uqm/comm/yehat/yehatc.c (revision 3779) ++++ src/uqm/comm/yehat/yehatc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../yehat/strings.h" + + #include "uqm/build.h" + #include "uqm/gameev.h" +Index: src/uqm/comm/orz/orzc.c +=================================================================== +--- src/uqm/comm/orz/orzc.c (revision 3779) ++++ src/uqm/comm/orz/orzc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../orz/strings.h" + + #include "uqm/build.h" + +Index: src/uqm/comm/urquan/urquanc.c +=================================================================== +--- src/uqm/comm/urquan/urquanc.c (revision 3779) ++++ src/uqm/comm/urquan/urquanc.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../urquan/strings.h" + + static LOCDATA urquan_desc = + { +Index: src/uqm/comm/slyhome/slyhome.c +=================================================================== +--- src/uqm/comm/slyhome/slyhome.c (revision 3779) ++++ src/uqm/comm/slyhome/slyhome.c (working copy) +@@ -18,7 +18,7 @@ + + #include "../commall.h" + #include "resinst.h" +-#include "strings.h" ++#include "../slyhome/strings.h" + + #include "uqm/gameev.h" + Index: src/options.c =================================================================== --- src/options.c (revision 3779) @@ -1923,96 +2115,3 @@ Index: src/options.c if (uio_mountDir (repository, mountPoint, uio_FSTYPE_ZIP, dirHandle, dirList->names[i], "/", autoMount, relativeFlags | uio_MOUNT_RDONLY, -Index: src/options.h -=================================================================== ---- src/options.h (revision 3779) -+++ src/options.h (working copy) -@@ -41,6 +41,7 @@ - extern int optWhichShield; - extern int optSmoothScroll; - extern int optMeleeScale; -+extern int optDirectionalJoystick; - - extern BOOLEAN opt3doMusic; - extern BOOLEAN optRemixMusic; -Index: src/uqm.c -=================================================================== ---- src/uqm.c (revision 3779) -+++ src/uqm.c (working copy) -@@ -62,6 +62,22 @@ - // Including this is actually necessary on OSX. - #endif - -+#if defined (ANDROID) -+# include -+static void AndroidAppPutToBackgroundCallback (void) -+{ -+ SDL_ANDROID_PauseAudioPlayback (); -+ GameActive = FALSE; -+ //GamePaused = TRUE; -+} -+static void SDLCALL AndroidAppRestoredCallback (void) -+{ -+ SDL_ANDROID_ResumeAudioPlayback (); -+ GameActive = TRUE; -+ //GamePaused = FALSE; -+} -+#endif -+ - struct bool_option - { - bool value; -@@ -129,6 +145,7 @@ - DECL_CONFIG_OPTION(float, sfxVolumeScale); - DECL_CONFIG_OPTION(float, speechVolumeScale); - DECL_CONFIG_OPTION(bool, safeMode); -+ DECL_CONFIG_OPTION(bool, directionalJoystick); - - #define INIT_CONFIG_OPTION(name, val) \ - { val, false } -@@ -247,8 +264,8 @@ - INIT_CONFIG_OPTION( gamma, 1.0f ), - INIT_CONFIG_OPTION( soundDriver, audio_DRIVER_MIXSDL ), - INIT_CONFIG_OPTION( soundQuality, audio_QUALITY_MEDIUM ), -- INIT_CONFIG_OPTION( use3doMusic, true ), -- INIT_CONFIG_OPTION( useRemixMusic, false ), -+ INIT_CONFIG_OPTION( use3doMusic, false ), -+ INIT_CONFIG_OPTION( useRemixMusic, true ), - INIT_CONFIG_OPTION( useSpeech, true ), - INIT_CONFIG_OPTION( whichCoarseScan, OPT_PC ), - INIT_CONFIG_OPTION( whichMenu, OPT_PC ), -@@ -263,6 +280,7 @@ - INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ), - INIT_CONFIG_OPTION( speechVolumeScale, 1.0f ), - INIT_CONFIG_OPTION( safeMode, false ), -+ INIT_CONFIG_OPTION( directionalJoystick, true ), - }; - struct options_struct defaults = options; - int optionsResult; -@@ -390,6 +408,7 @@ - sfxVolumeScale = options.sfxVolumeScale.value; - speechVolumeScale = options.speechVolumeScale.value; - optAddons = options.addons; -+ optDirectionalJoystick = options.directionalJoystick.value; - - prepareContentDir (options.contentDir, options.addonDir, argv[0]); - prepareMeleeDir (); -@@ -439,6 +458,10 @@ - (volatile int *)ImmediateInputState.key, NUM_TEMPLATES, NUM_KEYS); - TFB_InitInput (TFB_INPUTDRIVER_SDL, 0); - -+#if defined (ANDROID) -+ SDL_ANDROID_SetApplicationPutToBackgroundCallback (AndroidAppPutToBackgroundCallback, AndroidAppRestoredCallback); -+#endif -+ - StartThread (Starcon2Main, NULL, 1024, "Starcon2Main"); - - for (i = 0; i < 2000 && !MainExited; ) -@@ -637,6 +660,7 @@ - getBoolConfigValue (&options->fullscreen, "config.fullscreen"); - getBoolConfigValue (&options->scanlines, "config.scanlines"); - getBoolConfigValue (&options->showFps, "config.showfps"); -+ getBoolConfigValue (&options->directionalJoystick, "config.directionaljoystick"); - getBoolConfigValue (&options->keepAspectRatio, "config.keepaspectratio"); - getGammaConfigValue (&options->gamma, "config.gamma"); -