From 600be30fc2b9140dcc8bf401d4e184635b0cf2f5 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Wed, 12 Feb 2014 18:59:34 +0200 Subject: [PATCH] UQM-HD: better gamepad detection --- .../application/uqm-hd/AndroidAppSettings.cfg | 4 +- project/jni/application/uqm-hd/android.diff | 2028 +++++++++-------- 2 files changed, 1022 insertions(+), 1010 deletions(-) diff --git a/project/jni/application/uqm-hd/AndroidAppSettings.cfg b/project/jni/application/uqm-hd/AndroidAppSettings.cfg index a12f7f616..2376428cd 100644 --- a/project/jni/application/uqm-hd/AndroidAppSettings.cfg +++ b/project/jni/application/uqm-hd/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="Ur-Quan Masters HD" AppFullName=com.googlecode.uqm.hd # Application version code (integer) -AppVersionCode=07005 +AppVersionCode=07006 # Application user-visible version name (string) -AppVersionName="0.7.0.05" +AppVersionName="0.7.0.06" # Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' # If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu diff --git a/project/jni/application/uqm-hd/android.diff b/project/jni/application/uqm-hd/android.diff index bf10d2381..25cf68acf 100644 --- a/project/jni/application/uqm-hd/android.diff +++ b/project/jni/application/uqm-hd/android.diff @@ -1,84 +1,156 @@ -Index: uqm/battle.c +Index: svnversion.h =================================================================== ---- uqm/battle.c (revision 1353) -+++ 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: uqm/outfit.c +--- svnversion.h (revision 1353) ++++ svnversion.h (working copy) +@@ -1 +1 @@ +-#define UQMHD_SVN_REVISION "1337M" ++#define UQMHD_SVN_REVISION "1351M" +Index: config_unix.h =================================================================== ---- uqm/outfit.c (revision 1353) -+++ uqm/outfit.c (working copy) -@@ -59,7 +59,7 @@ - OldContext = SetContext (StatusContext); - GetContextClipRect (&r); +--- config_unix.h (revision 0) ++++ 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: uqm/menu.c +=================================================================== +--- uqm/menu.c (revision 1353) ++++ 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 - 19 * RESOLUTION_FACTOR; // JMS_GFX; -+ s.origin.y = RADAR_Y_LIFTED_UP - r.corner.y + RES_CASE(10,6,12); // JMS_GFX; + 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 - (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: uqm/comm/zoqfot/zoqfotc.c +=================================================================== +--- uqm/comm/zoqfot/zoqfotc.c (revision 1353) ++++ 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: uqm/comm/comandr/comandr.c +=================================================================== +--- uqm/comm/comandr/comandr.c (revision 1353) ++++ 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: uqm/comm/blackur/blackurc.c +=================================================================== +--- uqm/comm/blackur/blackurc.c (revision 1353) ++++ 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: uqm/comm/mycon/myconc.c +=================================================================== +--- uqm/comm/mycon/myconc.c (revision 1353) ++++ 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: uqm/comm/arilou/arilouc.c +=================================================================== +--- uqm/comm/arilou/arilouc.c (revision 1353) ++++ 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: uqm/comm/chmmr/chmmrc.c =================================================================== --- uqm/comm/chmmr/chmmrc.c (revision 1353) @@ -369,93 +441,201 @@ Index: uqm/comm/slyhome/slyhome.c #include "uqm/gameev.h" -Index: uqm/comm/zoqfot/zoqfotc.c +Index: uqm/units.h =================================================================== ---- uqm/comm/zoqfot/zoqfotc.c (revision 1353) -+++ uqm/comm/zoqfot/zoqfotc.c (working copy) -@@ -18,7 +18,7 @@ +--- uqm/units.h (revision 1353) ++++ 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)) - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../zoqfot/strings.h" - - #include "uqm/build.h" - #include "uqm/gameev.h" -Index: uqm/comm/comandr/comandr.c + /* Blue boxes which display messages and the green date box. */ + #define SIS_TITLE_BOX_WIDTH (57 << RESOLUTION_FACTOR) // JMS_GFX +Index: uqm/controls.h =================================================================== ---- uqm/comm/comandr/comandr.c (revision 1353) -+++ uqm/comm/comandr/comandr.c (working copy) -@@ -20,7 +20,7 @@ +--- uqm/controls.h (revision 1353) ++++ 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)) - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../comandr/strings.h" +-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); - #include "uqm/setup.h" - #include "uqm/sis.h" -Index: uqm/comm/blackur/blackurc.c + 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: uqm/planets/solarsys.c =================================================================== ---- uqm/comm/blackur/blackurc.c (revision 1353) -+++ 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 = +--- uqm/planets/solarsys.c (revision 1353) ++++ uqm/planets/solarsys.c (working copy) +@@ -1245,18 +1245,19 @@ + static void + ProcessShipControls (void) { -Index: uqm/comm/mycon/myconc.c -=================================================================== ---- uqm/comm/mycon/myconc.c (revision 1353) -+++ uqm/comm/mycon/myconc.c (working copy) -@@ -18,7 +18,7 @@ +- COUNT index; ++ COUNT index = GetFrameIndex (GLOBAL (ShipStamp.frame));; + SIZE delta_x, delta_y; ++ BATTLE_INPUT_STATE InputState = GetDirectionalJoystickInput(index, 0); - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../mycon/strings.h" +- if (CurrentInputState.key[PlayerControls[0]][KEY_UP]) ++ if (InputState & BATTLE_THRUST) + delta_y = -1; + else + delta_y = 0; - #include "uqm/gameev.h" - #include "libs/mathlib.h" -Index: uqm/comm/arilou/arilouc.c -=================================================================== ---- uqm/comm/arilou/arilouc.c (revision 1353) -+++ uqm/comm/arilou/arilouc.c (working copy) -@@ -18,7 +18,7 @@ + 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; - #include "../commall.h" - #include "resinst.h" --#include "strings.h" -+#include "../arilou/strings.h" - - #include "uqm/gameev.h" - -Index: uqm/status.c -=================================================================== ---- uqm/status.c (revision 1353) -+++ 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 = 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: uqm/planets/pstarmap.c +=================================================================== +--- uqm/planets/pstarmap.c (revision 1353) ++++ 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: uqm/planets/lander.c +=================================================================== +--- uqm/planets/lander.c (revision 1353) ++++ 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: uqm/supermelee/melee.c +=================================================================== +--- uqm/supermelee/melee.c (revision 1353) ++++ 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: uqm/sis.c +=================================================================== +--- uqm/sis.c (revision 1353) ++++ 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: uqm/hyper.c =================================================================== --- uqm/hyper.c (revision 1353) @@ -468,38 +648,6 @@ Index: uqm/hyper.c UnbatchGraphics (); OldContext = SetContext (SpaceContext); -Index: uqm/status.h -=================================================================== ---- uqm/status.h (revision 1353) -+++ 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: uqm/intro.c =================================================================== --- uqm/intro.c (revision 1353) @@ -640,87 +788,6 @@ Index: uqm/intro.c DestroyStringTable (ReleaseStringTable (pres)); return result; } -Index: uqm/menu.c -=================================================================== ---- uqm/menu.c (revision 1353) -+++ 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: uqm/globdata.c -=================================================================== ---- uqm/globdata.c (revision 1353) -+++ 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: uqm/shipyard.c -=================================================================== ---- uqm/shipyard.c (revision 1353) -+++ 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: uqm/intel.c -=================================================================== ---- uqm/intel.c (revision 1353) -+++ 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: uqm/gameinp.c =================================================================== --- uqm/gameinp.c (revision 1353) @@ -815,7 +882,7 @@ Index: uqm/gameinp.c } BOOLEAN -@@ -500,3 +513,146 @@ +@@ -500,3 +513,144 @@ return result; } @@ -877,8 +944,6 @@ Index: uqm/gameinp.c + axisY = VControl_GetJoyAxis(2, player * 2 + 1); + if( abs( axisX ) > 5000 || abs( axisY ) > 5000 ) // Deadspot at the center + { -+ if( !JoystickTapFlag[player] ) -+ TFB_SetOnScreenKeyboard_HiddenPermanently (); // Gamepad used - hide on-screen keys + JoystickTapFlag[player] = TRUE; + JoystickThrust[player] = FALSE; + // Turning thrust with joystick is uncomfortable @@ -962,406 +1027,6 @@ Index: uqm/gameinp.c + } + return InputState; +} -Index: uqm/controls.h -=================================================================== ---- uqm/controls.h (revision 1353) -+++ 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: uqm/confirm.c -=================================================================== ---- uqm/confirm.c (revision 1353) -+++ uqm/confirm.c (working copy) -@@ -34,9 +34,11 @@ - #include - - --#define CONFIRM_WIN_WIDTH (80 << RESOLUTION_FACTOR) // JMS_GFX -+#define CONFIRM_WIN_WIDTH (160 << RESOLUTION_FACTOR) // JMS_GFX - #define CONFIRM_WIN_HEIGHT (22 << RESOLUTION_FACTOR) // JMS_GFX - -+BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; -+ - static void - DrawConfirmationWindow (BOOLEAN answer) - { -@@ -67,6 +69,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); - -@@ -111,8 +115,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; -@@ -139,7 +151,7 @@ - PlayMenuSound (MENU_SOUND_MOVE); - } - SleepThread (ONE_SECOND / 30); -- } while (!done); -+ } - - // Restore the screen under the confirmation window - DrawStamp (&s); -@@ -152,6 +164,8 @@ - } - else - { -+ if (GLOBAL (CurrentActivity) & IN_BATTLE) -+ EmergencyEscapeWarpUnitActivatedFromMenu = TRUE; - result = FALSE; - } - ExitRequested = FALSE; -Index: uqm/supermelee/melee.c -=================================================================== ---- uqm/supermelee/melee.c (revision 1353) -+++ 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: uqm/getchar.c -=================================================================== ---- uqm/getchar.c (revision 1353) -+++ uqm/getchar.c (working copy) -@@ -27,7 +27,11 @@ - #include "resinst.h" - #include "nameref.h" - -+#ifdef __ANDROID__ -+#include -+#endif - -+ - // TODO: This may be better done with UniChar at the cost of a tiny bit - // of overhead to convert UniChar back to UTF8 string. This overhead - // will probably be offset by removal of looped string-compare overhead ;) -@@ -141,6 +145,11 @@ - { // init basic vars - int lwlen; - -+#ifdef __ANDROID__ -+ SDL_ANDROID_ToggleScreenKeyboardTextInput (pTES->BaseStr); -+ pTES->BaseStr[0] = 0; -+#endif -+ - pTES->InputFunc = DoTextEntry; - pTES->Success = FALSE; - pTES->Initialized = TRUE; -@@ -198,7 +207,6 @@ - CacheInsPt = pTES->InsPt; - CacheCursorPos = pTES->CursorPos; - memcpy (pTES->CacheStr, pTES->BaseStr, pTES->MaxSize); -- - // process the pending character buffer - ch = GetNextCharacter (); - if (!ch && PulsedInputState.menu[KEY_MENU_ANY]) -Index: uqm/setupmenu.c -=================================================================== ---- uqm/setupmenu.c (revision 1353) -+++ uqm/setupmenu.c (working copy) -@@ -83,7 +83,7 @@ - #endif - - #define MENU_COUNT 8 --#define CHOICE_COUNT 29 // JMS: New options added. -+#define CHOICE_COUNT 30 // JMS: New options added. - #define SLIDER_COUNT 3 - #define BUTTON_COUNT 10 - #define LABEL_COUNT 4 -@@ -106,7 +106,7 @@ - static int choice_widths[CHOICE_COUNT] = { - 3, 2, 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 3, 3, 2, 3, 3, -- 3, 2, 3, 2, 2, 2, 2, 2, 2 }; -+ 3, 2, 3, 2, 2, 2, 2, 2, 2, 2 }; - - static HANDLER button_handlers[BUTTON_COUNT] = { - quit_main_menu, quit_sub_menu, do_graphics, do_engine, -@@ -117,7 +117,7 @@ - // JMS: The first 8 was 7 (sound options.) Added mainmenumusic on/off. - // JMS: The HAVE_OPENGL options were 5 and 4. Added cheatMode, mineralSubmenu, nebulae and planet options. - static int menu_sizes[MENU_COUNT] = { -- 7, 6, 8, 8, 2, 5, -+ 7, 6, 8, 8, 2, 6, - #ifdef HAVE_OPENGL - 10, - #else -@@ -185,6 +185,7 @@ - static WIDGET *keyconfig_widgets[] = { - (WIDGET *)(&choices[18]), - (WIDGET *)(&choices[19]), -+ (WIDGET *)(&choices[29]), // Directional joystick - (WIDGET *)(&labels[1]), - (WIDGET *)(&buttons[8]), - (WIDGET *)(&buttons[1]) }; -@@ -293,6 +294,8 @@ - if (event == WIDGET_EVENT_SELECT) - { - next = (WIDGET *)(&menus[5]); -+ if (getenv("OUYA")) -+ next = (WIDGET *)(&menus[4]); - (*next->receiveFocus) (next, WIDGET_EVENT_DOWN); - return TRUE; - } -@@ -414,6 +417,7 @@ - choices[26].selected = opts.rotatingIpPlanets; // JMS - choices[27].selected = opts.texturedIpPlanets || opts.rotatingIpPlanets; // JMS - choices[28].selected = opts.cheatMode; // JMS -+ choices[29].selected = opts.directionalJoystick; - - sliders[0].value = opts.musicvol; - sliders[1].value = opts.sfxvol; -@@ -452,6 +456,7 @@ - opts.rotatingIpPlanets = choices[26].selected; // JMS - opts.texturedIpPlanets = choices[27].selected || opts.rotatingIpPlanets; // JMS - opts.cheatMode = choices[28].selected; // JMS -+ opts.directionalJoystick = choices[29].selected; - - opts.musicvol = sliders[0].value; - opts.sfxvol = sliders[1].value; -@@ -1164,6 +1169,7 @@ - opts->rotatingIpPlanets = optRotatingIpPlanets ? OPTVAL_ENABLED : OPTVAL_DISABLED; - opts->texturedIpPlanets = (optTexturedIpPlanets ? OPTVAL_ENABLED : OPTVAL_DISABLED) || opts->rotatingIpPlanets; - opts->cheatMode = optCheatMode ? OPTVAL_ENABLED : OPTVAL_DISABLED; -+ opts->directionalJoystick = optDirectionalJoystick ? OPTVAL_ENABLED : OPTVAL_DISABLED; - - /* Work out resolution. On the way, try to guess a good default - * for config.alwaysgl, then overwrite it if it was set previously. */ -@@ -1376,6 +1382,9 @@ - res_PutBoolean ("config.cheatMode", opts->cheatMode == OPTVAL_ENABLED); - optCheatMode = opts->cheatMode == OPTVAL_ENABLED; - -+ res_PutBoolean ("config.directionaljoystick", opts->directionalJoystick == OPTVAL_ENABLED); -+ optDirectionalJoystick = (opts->directionalJoystick == OPTVAL_ENABLED) ? TRUE : FALSE; -+ - if (NewWidth == 320 && NewHeight == 240) - { - switch (opts->scaler) -Index: uqm/setupmenu.h -=================================================================== ---- uqm/setupmenu.h (revision 1353) -+++ uqm/setupmenu.h (working copy) -@@ -86,7 +86,7 @@ - OPT_CONSOLETYPE menu, text, cscan, scroll, intro, meleezoom, shield; - CONTROL_TEMPLATE player1, player2; - int speechvol, musicvol, sfxvol; -- BOOLEAN mainmenuMusic, mineralSubmenu, nebulae, rotatingIpPlanets, texturedIpPlanets, cheatMode; // JMS -+ BOOLEAN mainmenuMusic, mineralSubmenu, nebulae, rotatingIpPlanets, texturedIpPlanets, cheatMode, directionalJoystick; // JMS - } GLOBALOPTS; - - void SetupMenu (void); -Index: uqm/starcon.c -=================================================================== ---- uqm/starcon.c (revision 1353) -+++ uqm/starcon.c (working copy) -@@ -240,6 +240,7 @@ - if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) - AskNameForCaptainAndShip(); - -+ TFB_SetOnScreenKeyboard_Melee (); - do - { - #ifdef DEBUG -Index: uqm/units.h -=================================================================== ---- uqm/units.h (revision 1353) -+++ 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: uqm/planets/lander.c -=================================================================== ---- uqm/planets/lander.c (revision 1353) -+++ 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: uqm/planets/solarsys.c -=================================================================== ---- uqm/planets/solarsys.c (revision 1353) -+++ 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: uqm/planets/pstarmap.c -=================================================================== ---- uqm/planets/pstarmap.c (revision 1353) -+++ 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: uqm/sis.c -=================================================================== ---- uqm/sis.c (revision 1353) -+++ 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: uqm/shipstat.c =================================================================== --- uqm/shipstat.c (revision 1353) @@ -1543,13 +1208,414 @@ Index: uqm/shipstat.c } } -Index: svnversion.h +Index: uqm/intel.c =================================================================== ---- svnversion.h (revision 1353) -+++ svnversion.h (working copy) -@@ -1 +1 @@ --#define UQMHD_SVN_REVISION "1337M" -+#define UQMHD_SVN_REVISION "1351M" +--- uqm/intel.c (revision 1353) ++++ 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: uqm/battle.c +=================================================================== +--- uqm/battle.c (revision 1353) ++++ 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: uqm/setupmenu.c +=================================================================== +--- uqm/setupmenu.c (revision 1353) ++++ uqm/setupmenu.c (working copy) +@@ -83,7 +83,7 @@ + #endif + + #define MENU_COUNT 8 +-#define CHOICE_COUNT 29 // JMS: New options added. ++#define CHOICE_COUNT 30 // JMS: New options added. + #define SLIDER_COUNT 3 + #define BUTTON_COUNT 10 + #define LABEL_COUNT 4 +@@ -106,7 +106,7 @@ + static int choice_widths[CHOICE_COUNT] = { + 3, 2, 3, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 3, 3, 2, 3, 3, +- 3, 2, 3, 2, 2, 2, 2, 2, 2 }; ++ 3, 2, 3, 2, 2, 2, 2, 2, 2, 2 }; + + static HANDLER button_handlers[BUTTON_COUNT] = { + quit_main_menu, quit_sub_menu, do_graphics, do_engine, +@@ -117,7 +117,7 @@ + // JMS: The first 8 was 7 (sound options.) Added mainmenumusic on/off. + // JMS: The HAVE_OPENGL options were 5 and 4. Added cheatMode, mineralSubmenu, nebulae and planet options. + static int menu_sizes[MENU_COUNT] = { +- 7, 6, 8, 8, 2, 5, ++ 7, 6, 8, 8, 2, 6, + #ifdef HAVE_OPENGL + 10, + #else +@@ -185,6 +185,7 @@ + static WIDGET *keyconfig_widgets[] = { + (WIDGET *)(&choices[18]), + (WIDGET *)(&choices[19]), ++ (WIDGET *)(&choices[29]), // Directional joystick + (WIDGET *)(&labels[1]), + (WIDGET *)(&buttons[8]), + (WIDGET *)(&buttons[1]) }; +@@ -293,6 +294,8 @@ + if (event == WIDGET_EVENT_SELECT) + { + next = (WIDGET *)(&menus[5]); ++ if (getenv("OUYA")) ++ next = (WIDGET *)(&menus[4]); + (*next->receiveFocus) (next, WIDGET_EVENT_DOWN); + return TRUE; + } +@@ -414,6 +417,7 @@ + choices[26].selected = opts.rotatingIpPlanets; // JMS + choices[27].selected = opts.texturedIpPlanets || opts.rotatingIpPlanets; // JMS + choices[28].selected = opts.cheatMode; // JMS ++ choices[29].selected = opts.directionalJoystick; + + sliders[0].value = opts.musicvol; + sliders[1].value = opts.sfxvol; +@@ -452,6 +456,7 @@ + opts.rotatingIpPlanets = choices[26].selected; // JMS + opts.texturedIpPlanets = choices[27].selected || opts.rotatingIpPlanets; // JMS + opts.cheatMode = choices[28].selected; // JMS ++ opts.directionalJoystick = choices[29].selected; + + opts.musicvol = sliders[0].value; + opts.sfxvol = sliders[1].value; +@@ -1164,6 +1169,7 @@ + opts->rotatingIpPlanets = optRotatingIpPlanets ? OPTVAL_ENABLED : OPTVAL_DISABLED; + opts->texturedIpPlanets = (optTexturedIpPlanets ? OPTVAL_ENABLED : OPTVAL_DISABLED) || opts->rotatingIpPlanets; + opts->cheatMode = optCheatMode ? OPTVAL_ENABLED : OPTVAL_DISABLED; ++ opts->directionalJoystick = optDirectionalJoystick ? OPTVAL_ENABLED : OPTVAL_DISABLED; + + /* Work out resolution. On the way, try to guess a good default + * for config.alwaysgl, then overwrite it if it was set previously. */ +@@ -1376,6 +1382,9 @@ + res_PutBoolean ("config.cheatMode", opts->cheatMode == OPTVAL_ENABLED); + optCheatMode = opts->cheatMode == OPTVAL_ENABLED; + ++ res_PutBoolean ("config.directionaljoystick", opts->directionalJoystick == OPTVAL_ENABLED); ++ optDirectionalJoystick = (opts->directionalJoystick == OPTVAL_ENABLED) ? TRUE : FALSE; ++ + if (NewWidth == 320 && NewHeight == 240) + { + switch (opts->scaler) +Index: uqm/setupmenu.h +=================================================================== +--- uqm/setupmenu.h (revision 1353) ++++ uqm/setupmenu.h (working copy) +@@ -86,7 +86,7 @@ + OPT_CONSOLETYPE menu, text, cscan, scroll, intro, meleezoom, shield; + CONTROL_TEMPLATE player1, player2; + int speechvol, musicvol, sfxvol; +- BOOLEAN mainmenuMusic, mineralSubmenu, nebulae, rotatingIpPlanets, texturedIpPlanets, cheatMode; // JMS ++ BOOLEAN mainmenuMusic, mineralSubmenu, nebulae, rotatingIpPlanets, texturedIpPlanets, cheatMode, directionalJoystick; // JMS + } GLOBALOPTS; + + void SetupMenu (void); +Index: uqm/confirm.c +=================================================================== +--- uqm/confirm.c (revision 1353) ++++ uqm/confirm.c (working copy) +@@ -34,9 +34,11 @@ + #include + + +-#define CONFIRM_WIN_WIDTH (80 << RESOLUTION_FACTOR) // JMS_GFX ++#define CONFIRM_WIN_WIDTH (160 << RESOLUTION_FACTOR) // JMS_GFX + #define CONFIRM_WIN_HEIGHT (22 << RESOLUTION_FACTOR) // JMS_GFX + ++BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; ++ + static void + DrawConfirmationWindow (BOOLEAN answer) + { +@@ -67,6 +69,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); + +@@ -111,8 +115,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; +@@ -139,7 +151,7 @@ + PlayMenuSound (MENU_SOUND_MOVE); + } + SleepThread (ONE_SECOND / 30); +- } while (!done); ++ } + + // Restore the screen under the confirmation window + DrawStamp (&s); +@@ -152,6 +164,8 @@ + } + else + { ++ if (GLOBAL (CurrentActivity) & IN_BATTLE) ++ EmergencyEscapeWarpUnitActivatedFromMenu = TRUE; + result = FALSE; + } + ExitRequested = FALSE; +Index: uqm/outfit.c +=================================================================== +--- uqm/outfit.c (revision 1353) ++++ 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: uqm/getchar.c +=================================================================== +--- uqm/getchar.c (revision 1353) ++++ uqm/getchar.c (working copy) +@@ -27,7 +27,11 @@ + #include "resinst.h" + #include "nameref.h" + ++#ifdef __ANDROID__ ++#include ++#endif + ++ + // TODO: This may be better done with UniChar at the cost of a tiny bit + // of overhead to convert UniChar back to UTF8 string. This overhead + // will probably be offset by removal of looped string-compare overhead ;) +@@ -141,6 +145,11 @@ + { // init basic vars + int lwlen; + ++#ifdef __ANDROID__ ++ SDL_ANDROID_ToggleScreenKeyboardTextInput (pTES->BaseStr); ++ pTES->BaseStr[0] = 0; ++#endif ++ + pTES->InputFunc = DoTextEntry; + pTES->Success = FALSE; + pTES->Initialized = TRUE; +@@ -198,7 +207,6 @@ + CacheInsPt = pTES->InsPt; + CacheCursorPos = pTES->CursorPos; + memcpy (pTES->CacheStr, pTES->BaseStr, pTES->MaxSize); +- + // process the pending character buffer + ch = GetNextCharacter (); + if (!ch && PulsedInputState.menu[KEY_MENU_ANY]) +Index: uqm/globdata.c +=================================================================== +--- uqm/globdata.c (revision 1353) ++++ 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: uqm/status.c +=================================================================== +--- uqm/status.c (revision 1353) ++++ 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: uqm/shipyard.c +=================================================================== +--- uqm/shipyard.c (revision 1353) ++++ 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: uqm/status.h +=================================================================== +--- uqm/status.h (revision 1353) ++++ 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: uqm/starcon.c +=================================================================== +--- uqm/starcon.c (revision 1353) ++++ uqm/starcon.c (working copy) +@@ -240,6 +240,7 @@ + if (LastActivity == (CHECK_LOAD | CHECK_RESTART)) + AskNameForCaptainAndShip(); + ++ TFB_SetOnScreenKeyboard_Melee (); + do + { + #ifdef DEBUG Index: options.c =================================================================== --- options.c (revision 1353) @@ -1679,21 +1745,237 @@ Index: uqm.c if (res_IsInteger ("config.player1control")) { -Index: libs/uio/zip/zip.c +Index: libs/strings/unicode.c =================================================================== ---- libs/uio/zip/zip.c (revision 1353) -+++ 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; +--- libs/strings/unicode.c (revision 1353) ++++ libs/strings/unicode.c (working copy) +@@ -41,7 +41,8 @@ + // function. + UniChar + getCharFromString(const unsigned char **ptr) { +- UniChar result; ++ const unsigned char *origPtr = *ptr; ++ UniChar result, errData; + + if (**ptr < 0x80) { + // 0xxxxxxx, regular ASCII +@@ -121,7 +122,14 @@ + } + + err: +- log_add(log_Warning, "Warning: Invalid UTF8 sequence."); ++ errData = origPtr[0] * 0x1000000; ++ if (origPtr[0] && origPtr[1]) ++ errData &= origPtr[1] * 0x10000; ++ if (origPtr[0] && origPtr[1] && origPtr[2]) ++ errData &= origPtr[2] * 0x100; ++ if (origPtr[0] && origPtr[1] && origPtr[2] && origPtr[3]) ++ errData &= origPtr[3]; ++ log_add(log_Warning, "Warning: Invalid UTF8 sequence: result 0x%x last byte 0x%02x str 0x%08x %s", result, (unsigned)(**ptr), errData, origPtr); + + // Resynchronise (skip everything starting with 0x10xxxxxx): + resyncUTF8(ptr); +Index: libs/input/sdl/vcontrol.h +=================================================================== +--- libs/input/sdl/vcontrol.h (revision 1353) ++++ 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(); + - default: - #ifdef DEBUG - fprintf(stderr, "Debug: Extra field 0x%04x unsupported, " + /* Force the input into the blank state. For preventing "sticky" keys. */ + void VControl_ResetInput (void); + +Index: libs/input/sdl/input.c +=================================================================== +--- libs/input/sdl/input.c (revision 1353) ++++ libs/input/sdl/input.c (working copy) +@@ -88,6 +88,7 @@ + "weapon", + "special", + "escape", ++ "thrust", + NULL + }; + +@@ -188,7 +189,7 @@ + directory. */ + LoadResourceIndex (contentDir, "uqm.key", "keys."); + } +- ++ + register_flight_controls (); + + return; +Index: libs/input/sdl/vcontrol.c +=================================================================== +--- libs/input/sdl/vcontrol.c (revision 1353) ++++ 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) + { +@@ -830,6 +833,13 @@ + joysticks[port].axes[axis].polarity = 1; + activate (joysticks[port].axes[axis].pos); + } ++#ifdef __ANDROID__ ++ if( port == 2 ) ++ { ++ // Gamepad used - hide on-screen keys ++ TFB_SetOnScreenKeyboard_HiddenPermanently (); ++ } ++#endif + } + else if (value < -t) + { +@@ -894,6 +904,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: libs/input/input_common.h +=================================================================== +--- libs/input/input_common.h (revision 1353) ++++ 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: libs/log/uqmlog.c +=================================================================== +--- libs/log/uqmlog.c (revision 1353) ++++ libs/log/uqmlog.c (working copy) +@@ -23,6 +23,9 @@ + #include + #include + #include ++#ifdef ANDROID ++#include ++#endif + #include "libs/threadlib.h" + + #ifndef MAX_LOG_ENTRY_SIZE +@@ -190,6 +193,9 @@ + if ((int)level <= maxStreamLevel) + { + fprintf (streamOut, "%s\n", full_msg); ++#ifdef ANDROID ++ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg ); ++#endif + } + + if ((int)level <= maxLevel) +@@ -226,6 +232,9 @@ + if ((int)level <= maxStreamLevel) + { + fprintf (streamOut, "%s\n", full_msg); ++#ifdef ANDROID ++ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg ); ++#endif + } + + if ((int)level <= maxLevel) +Index: libs/log/msgbox_win.c +=================================================================== +--- libs/log/msgbox_win.c (revision 1353) ++++ 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: libs/log/msgbox_stub.c +=================================================================== +--- libs/log/msgbox_stub.c (revision 1353) ++++ 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: libs/uio/io.c =================================================================== --- libs/uio/io.c (revision 1353) @@ -1761,6 +2043,21 @@ Index: libs/uio/io.c int savedErrno = errno; uio_free(name); uio_PDirHandle_unref(pDirHandle); +Index: libs/uio/zip/zip.c +=================================================================== +--- libs/uio/zip/zip.c (revision 1353) ++++ 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: libs/md5/md5.c =================================================================== --- libs/md5/md5.c (revision 1353) @@ -1774,117 +2071,6 @@ Index: libs/md5/md5.c #include "md5.h" -Index: libs/input/input_common.h -=================================================================== ---- libs/input/input_common.h (revision 1353) -+++ 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: libs/input/sdl/vcontrol.c -=================================================================== ---- libs/input/sdl/vcontrol.c (revision 1353) -+++ 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: libs/input/sdl/vcontrol.h -=================================================================== ---- libs/input/sdl/vcontrol.h (revision 1353) -+++ 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: libs/input/sdl/input.c -=================================================================== ---- libs/input/sdl/input.c (revision 1353) -+++ libs/input/sdl/input.c (working copy) -@@ -88,6 +88,7 @@ - "weapon", - "special", - "escape", -+ "thrust", - NULL - }; - -@@ -188,7 +189,7 @@ - directory. */ - LoadResourceIndex (contentDir, "uqm.key", "keys."); - } -- -+ - register_flight_controls (); - - return; Index: libs/resource/filecntl.c =================================================================== --- libs/resource/filecntl.c (revision 1353) @@ -1921,72 +2107,6 @@ Index: libs/sound/decoders/oggaud.c #else return ova->vf.os.pageno; #endif /* OVCODEC_TREMOR */ -Index: libs/strings/unicode.c -=================================================================== ---- libs/strings/unicode.c (revision 1353) -+++ libs/strings/unicode.c (working copy) -@@ -41,7 +41,8 @@ - // function. - UniChar - getCharFromString(const unsigned char **ptr) { -- UniChar result; -+ const unsigned char *origPtr = *ptr; -+ UniChar result, errData; - - if (**ptr < 0x80) { - // 0xxxxxxx, regular ASCII -@@ -121,7 +122,14 @@ - } - - err: -- log_add(log_Warning, "Warning: Invalid UTF8 sequence."); -+ errData = origPtr[0] * 0x1000000; -+ if (origPtr[0] && origPtr[1]) -+ errData &= origPtr[1] * 0x10000; -+ if (origPtr[0] && origPtr[1] && origPtr[2]) -+ errData &= origPtr[2] * 0x100; -+ if (origPtr[0] && origPtr[1] && origPtr[2] && origPtr[3]) -+ errData &= origPtr[3]; -+ log_add(log_Warning, "Warning: Invalid UTF8 sequence: result 0x%x last byte 0x%02x str 0x%08x %s", result, (unsigned)(**ptr), errData, origPtr); - - // Resynchronise (skip everything starting with 0x10xxxxxx): - resyncUTF8(ptr); -Index: libs/graphics/sdl/pure.c -=================================================================== ---- libs/graphics/sdl/pure.c (revision 1353) -+++ libs/graphics/sdl/pure.c (working copy) -@@ -128,6 +128,7 @@ - { - int i, videomode_flags; - SDL_PixelFormat conv_fmt; -+ int BPP = 32; - - GraphicsDriver = driver; - -@@ -169,6 +170,14 @@ - } - } - -+#ifdef ANDROID -+ videomode_flags = SDL_SWSURFACE; -+ //ScreenWidthActual = 1280; -+ //ScreenHeightActual = 960; -+ graphics_backend = &pure_unscaled_backend; -+ BPP = 24; -+#endif -+ - videomode_flags |= SDL_ANYFORMAT; - if (flags & TFB_GFXFLAGS_FULLSCREEN) - videomode_flags |= SDL_FULLSCREEN; -@@ -176,7 +185,7 @@ - /* We'll ask for a 32bpp frame, but it doesn't really matter, because we've set - SDL_ANYFORMAT */ - SDL_Video = SDL_SetVideoMode (ScreenWidthActual, ScreenHeightActual, -- 32, videomode_flags); -+ BPP, videomode_flags); - - if (SDL_Video == NULL) - { Index: libs/graphics/sdl/sdl_common.c =================================================================== --- libs/graphics/sdl/sdl_common.c (revision 1353) @@ -2190,6 +2310,42 @@ Index: libs/graphics/sdl/sdl_common.h +void TFB_InitOnScreenKeyboard (void); + #endif +Index: libs/graphics/sdl/pure.c +=================================================================== +--- libs/graphics/sdl/pure.c (revision 1353) ++++ libs/graphics/sdl/pure.c (working copy) +@@ -128,6 +128,7 @@ + { + int i, videomode_flags; + SDL_PixelFormat conv_fmt; ++ int BPP = 32; + + GraphicsDriver = driver; + +@@ -169,6 +170,14 @@ + } + } + ++#ifdef ANDROID ++ videomode_flags = SDL_SWSURFACE; ++ //ScreenWidthActual = 1280; ++ //ScreenHeightActual = 960; ++ graphics_backend = &pure_unscaled_backend; ++ BPP = 24; ++#endif ++ + videomode_flags |= SDL_ANYFORMAT; + if (flags & TFB_GFXFLAGS_FULLSCREEN) + videomode_flags |= SDL_FULLSCREEN; +@@ -176,7 +185,7 @@ + /* We'll ask for a 32bpp frame, but it doesn't really matter, because we've set + SDL_ANYFORMAT */ + SDL_Video = SDL_SetVideoMode (ScreenWidthActual, ScreenHeightActual, +- 32, videomode_flags); ++ BPP, videomode_flags); + + if (SDL_Video == NULL) + { Index: libs/graphics/gfx_common.h =================================================================== --- libs/graphics/gfx_common.h (revision 1353) @@ -2206,147 +2362,3 @@ Index: libs/graphics/gfx_common.h +void TFB_SetOnScreenKeyboard_TwoPlayersMelee (void); + #endif -Index: libs/log/uqmlog.c -=================================================================== ---- libs/log/uqmlog.c (revision 1353) -+++ libs/log/uqmlog.c (working copy) -@@ -23,6 +23,9 @@ - #include - #include - #include -+#ifdef ANDROID -+#include -+#endif - #include "libs/threadlib.h" - - #ifndef MAX_LOG_ENTRY_SIZE -@@ -190,6 +193,9 @@ - if ((int)level <= maxStreamLevel) - { - fprintf (streamOut, "%s\n", full_msg); -+#ifdef ANDROID -+ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg ); -+#endif - } - - if ((int)level <= maxLevel) -@@ -226,6 +232,9 @@ - if ((int)level <= maxStreamLevel) - { - fprintf (streamOut, "%s\n", full_msg); -+#ifdef ANDROID -+ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg ); -+#endif - } - - if ((int)level <= maxLevel) -Index: libs/log/msgbox_win.c -=================================================================== ---- libs/log/msgbox_win.c (revision 1353) -+++ 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: libs/log/msgbox_stub.c -=================================================================== ---- libs/log/msgbox_stub.c (revision 1353) -+++ 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: config_unix.h -=================================================================== ---- config_unix.h (revision 0) -+++ 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 */ -+