 +
 +#endif  /* _CONFIG_UNIX_H */
 +
+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/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/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/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/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/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/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/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 <stdlib.h>
+ #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,130 @@
+ 	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;
++		return InputState;
++	}
++
++	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 ) // Deadspot at the center
++		{
++			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( !optDirectionalJoystick )
++	{
++		if( axisX < -10000 )
++			InputState |= BATTLE_LEFT;
++		if( axisX > 10000 )
++			InputState |= BATTLE_RIGHT;
++		if( axisY < 0 )
++			InputState |= BATTLE_THRUST;
++		return InputState;
++	}
++
++	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 3779)

 	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 <stdlib.h>
 #include "../commall.h"
-#include <stdlib.h>
 #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)

 			result = FALSE;
 		}
 		ExitRequested = FALSE;
Index: src/uqm/status.c
===================================================================
--- src/uqm/status.c	(revision 3779)
