Example #1
0
// extern void G_DemoKeypress();
// extern void CG_SkipCredits(void);
void IN_CommonJoyPress(int controller, fakeAscii_t button, bool pressed)
{
	// Check for special cases for map hack
	// This should be #ifdef'd out in FINAL_BUILD, but I really don't care.
	// If someone wants to copy the retail version to their modded xbox and
	// edit the config file to turn on maphack, let them.
	if (Cvar_VariableIntegerValue("cl_maphack"))
	{
		if (_UIRunning && button == A_JOY11 && pressed)
		{
			// Left trigger -> F1
			Sys_QueEvent( 0, SE_KEY, A_F1, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY12 && pressed)
		{
			// Right trigger -> F2
			Sys_QueEvent( 0, SE_KEY, A_F2, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY4 && pressed)
		{
			// Start button -> F3
			IN_SetMainController(controller);
			Sys_QueEvent( 0, SE_KEY, A_F3, pressed, 0, NULL );
			return;
		}
	}


	if(IN_GetMainController() == controller || _UIRunning)
	{
		// Always map start button to ESCAPE
		if (!_UIRunning && button == A_JOY4 && cls.state != CA_CINEMATIC)
			Sys_QueEvent( 0, SE_KEY, A_ESCAPE, pressed, 0, NULL );

#ifdef DEBUG_CONTROLLER
		if (controller != 3)
#endif
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
	}

#ifdef DEBUG_CONTROLLER
	if (controller == 3 && pressed)
	{
		HandleDebugJoystickPress(button);
		return;
	}
#endif
}
// extern void G_DemoKeypress();
// extern void CG_SkipCredits(void);
void IN_CommonJoyPress(int controller, fakeAscii_t button, bool pressed)
{
	// Check for special cases for map hack
#ifndef FINAL_BUILD
	if (Cvar_VariableIntegerValue("cl_maphack"))
	{
		if (_UIRunning && button == A_JOY11 && pressed)
		{
			// Left trigger -> F1
			Sys_QueEvent( 0, SE_KEY, A_F1, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY12 && pressed)
		{
			// Right trigger -> F2
			Sys_QueEvent( 0, SE_KEY, A_F2, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY4 && pressed)
		{
			// Start button -> F3
			IN_SetMainController(controller);
			Sys_QueEvent( 0, SE_KEY, A_F3, pressed, 0, NULL );
			return;
		}
	}
#endif


	if(IN_GetMainController() == controller || _UIRunning)
	{
		// Always map start button to ESCAPE
		if (!_UIRunning && button == A_JOY4 && cls.state != CA_CINEMATIC)
			Sys_QueEvent( 0, SE_KEY, A_ESCAPE, pressed, 0, NULL );

#ifndef FINAL_BUILD
		if (controller != 3 || !cheatPadEnabled)
#endif
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
	}

/*
	if (pressed)
	{
		G_DemoKeypress();
	}

	//Hacky!  Skip the credits if start is pressed.
	if(button == K_JOY4 && pressed) {
		CG_SkipCredits();
	}
*/

#ifndef FINAL_BUILD
	if (controller == 3 && pressed && cheatPadEnabled) {
		HandleDebugJoystickPress(button);
		return;
	}
#endif

/*
	extern int player1ControllerId;
	extern int player2ControllerId;
	extern bool checkForPlayerControllers;
	extern bool controllerUnplugged;


	// If the game isn't started yet
	if ((ClientManager::Shared().cls.cgameStarted == qfalse) &&
		(!controllerUnplugged))
	{
		// and player1 doesnt have a controllerid, then assign client 1 to this controller
		if (player1ControllerId == -1)
		{
			ClientManager::ActivateClient(0);
			if (ClientManager::ActiveController() != controller)
				ClientManager::SetActiveController(controller);
		}
		// player1 has a controller that is different then input recieved, and player2 doesnt have a controller and there are 2 clients
		else if (player1ControllerId != controller && player2ControllerId == -1 && ClientManager::NumClients() > 1)
		{
			ClientManager::ActivateClient(1);
			if (ClientManager::ActiveController() != controller)
				ClientManager::SetActiveController(controller);			
		}
	}

	if (ClientManager::ActivateByControllerId(controller))
	{

	#ifdef _XBOX
		//Check the status of the white or black buttons.
		if (button == K_JOY9) {
			ClientManager::ActiveClient().whiteButtonDown = pressed;
		} else if(button == K_JOY10) {
			ClientManager::ActiveClient().blackButtonDown = pressed;
		}

		//Ignore white/black button presses if inv/force/weap select is up. 
		//This is ugly.  It basically says return if the UI isn't running, if 
		//we got a white or black button, and if the inv/force/weapon select is 
		//running. 
		if(!_UIRunning && 
			(button == K_JOY9 ||  
			button == K_JOY10) && 
			(ClientManager::ActiveClient().cg.inventorySelectTime +  
			WEAPON_SELECT_TIME > ClientManager::ActiveClient().cg.time || 
			ClientManager::ActiveClient().cg.forcepowerSelectTime +  
			WEAPON_SELECT_TIME > ClientManager::ActiveClient().cg.time || 
			ClientManager::ActiveClient().cg.weaponSelectTime +  
			WEAPON_SELECT_TIME > ClientManager::ActiveClient().cg.time)) { 

			if(!pressed) {
				//And it just gets hackier!  Is that a word?  It is now!
				//If we've released the button and it wasn't down too long...
				if((button == K_JOY9 && 
						ClientManager::ActiveClient().whiteButtonHoldTime < 
						MAX_WB_HOLD_TIME) ||
					(button == K_JOY10 &&
						ClientManager::ActiveClient().whiteButtonHoldTime < 
						MAX_WB_HOLD_TIME)) {
					//If we've already let the button press through previously,
					//just send a release message.  Otherwise send both a press
					//and release.
					if(ClientManager::ActiveClient().keys[button].down) {
						Sys_QueEvent( 0, SE_KEY, button, false, 0, NULL );
					} else {
						Sys_QueEvent( 0, SE_KEY, button, true, 0, NULL );
						Sys_QueEvent( 0, SE_KEY, button, false, 0, NULL );
					}
				}
			}
			return; 
		} 
	#endif

		if (!_UIRunning)
		{
			Sys_QueEvent( 0, SE_KEY, button, pressed, 0, NULL );
		}
		else
		{
//			int clientNum = ClientManager::ActiveClientNum();
			int clientNum = 0; // VVFIXME
			int qL = uiQueueLen[clientNum];
			if(qL < 5) {
				uiKeyQueue[clientNum][qL].button = UIJoy2Key(button);
				uiKeyQueue[clientNum][qL].pressed = pressed;
				uiQueueLen[clientNum]++;
			}
			//Sys_QueEvent(0, SE_KEY, UIJoy2Key(button), pressed, 0, NULL);
		}
*/
/*
	}
*/

}
Example #3
0
void IN_CommonJoyPress(int controller, fakeAscii_t button, bool pressed)
{
#ifdef XBOX_DEMO
	// Reset the demo timer so that we don't auto-reboot to CDX
	extern void Demo_TimerKeypress( void );
	Demo_TimerKeypress();
#endif

	lastControllerUsed	= controller;

	// Cheat system hooks. The right thumbstick button has to be held for a cheat:
	if (button == A_JOY3)
	{
		if (pressed)
		{
			// Just pressed the right thumstick in. Reset cheat detector
			enteringCheat = true;
			cheatLength = 0;
		}
		else
		{
			enteringCheat = false;
			if (cheatLength == 6)
			{
				for( int i = 0; i < numCheats; ++i)
				{
					if( memcmp( &cheats[i].buttons[0], &curCheat[0], sizeof(curCheat) ) == 0 )
					{
						if(cheats[i].function())
							S_StartLocalSound( S_RegisterSound( "sound/vehicles/x-wing/s-foil" ), CHAN_AUTO );
					}
				}
			}
		}
	}
	else if (enteringCheat && pressed)
	{
		// Handle all other buttons while entering a cheat
		if (cheatLength == 6 || (button != A_JOY5 && button != A_JOY6 && button != A_JOY7 && button != A_JOY8))
		{
			// If we press too many buttons, or anything but the D-pad, cancel entry:
			enteringCheat = false;
			cheatLength = 0;
		}
		else
		{
			// We pressed a d-pad button, we're entering a cheat, and there's still room
			curCheat[cheatLength++] = button;
		}
	}

	// Check for special cases for map hack
#ifndef FINAL_BUILD
	if (Cvar_VariableIntegerValue("cl_maphack"))
	{
		if (_UIRunning && button == A_JOY11 && pressed)
		{
			// Left trigger -> F1
			Sys_QueEvent( 0, SE_KEY, A_F1, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY12 && pressed)
		{
			// Right trigger -> F2
			Sys_QueEvent( 0, SE_KEY, A_F2, pressed, 0, NULL );
			return;
		}
		else if (_UIRunning && button == A_JOY4 && pressed)
		{
			// Start button -> F3
			//IN_SetMainController(controller);
			Sys_QueEvent( 0, SE_KEY, A_F3, pressed, 0, NULL );
			return;
		}
	}
#endif

	if(inSplashMenu->integer)
	{
		// START always works, A only works if the popup isn't shown:
		if(button == A_JOY4 || (button == A_JOY15 && controllerOut->integer < 0))
		{
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
		}
		return;
	}

	int controllerout	= controllerOut->integer;
	if(controllerout != -1)
	{
		if(controllerout == controller && (button == A_JOY4))// || button == A_JOY15))
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
		return;
	}

	if(IN_GetMainController() == controller )
	{
		// Always map start button to ESCAPE
		if (!_UIRunning && button == A_JOY4 && cls.state != CA_CINEMATIC)
			Sys_QueEvent( 0, SE_KEY, A_ESCAPE, pressed, 0, NULL );

#ifdef DEBUG_CONTROLLER
		if (controller != 3)
#endif
			Sys_QueEvent( 0, SE_KEY, _UIRunning ? UIJoy2Key(button) : button, pressed, 0, NULL );
	}

#ifdef DEBUG_CONTROLLER
	if (controller == 3 && pressed)
	{
		HandleDebugJoystickPress(button);
		return;
	}
#endif
//JLF
	
}