Ejemplo n.º 1
0
	////////////////////////
	/// CheckImmediateInput ( )	
	////////////////////////
	/// Check for a given key in the IMMEDIATE input stream.
	///
	/// Input:
	///		DWORD dwInput
	///		This is what we're looking for. 
	///		For the Joystick, use 0-7 for the buttons and the Axis enumeration
	///
	/// Returns:
	///		DWORD		This will be 0 if dwInput was not found in the buffer. 
	///						For on/off inputs (keys, joystick/Joystick buttons) you can simply 
	///						say if (CheckImmediateInput(input)) and that will be good enough.
	///
	///						For things that have ranges, like Joystick/joystick actions, it will return
	///						the -amount- of the movement. For example, if you moved the Joystick
	///						10 pixels up, and asked for JoystickAXIS_X, you'd get -10 back from this
	///						function.
	////////////////////////
	long CInputJoystick::CheckImmediateInput(DWORD dwInput)
	{
		if (!this || !pDevice) return false;

		// What we return will depend on the type of thing we asked for
		switch (dwInput)
		{

		// if we're checking for an axis...
		case JOYSTICK_AXIS_X :
			return JoystickState.lX;
		case JOYSTICK_AXIS_Y :
			return JoystickState.lY;
		case JOYSTICK_AXIS_RX :	//	case JOYSTICK_AXIS_Z: (same thing)
			return JoystickState.lRz;
		case JOYSTICK_AXIS_RY:
			return JoystickState.lZ;

		case JOYSTICK_POV(0):		// case JOYSTICK_DPAD
			return JoystickState.rgdwPOV[0];
		case JOYSTICK_POV(1):
			return JoystickState.rgdwPOV[1];
		case JOYSTICK_POV(2):
			return JoystickState.rgdwPOV[2];
		case JOYSTICK_POV(3):
			return JoystickState.rgdwPOV[3];
		
		// We're checking for a button
		default :
			return (JoystickState.rgbButtons[dwInput - JOYSTICK_BUTTON(0)] & 0x80);
		}
	}
ButtonCode_t ButtonCode_StringToButtonCode( const char *pString, bool bXController )
{
	if ( !pString || !pString[0] )
		return BUTTON_CODE_INVALID;

	// Backward compat for screwed up previous joystick button names
	if ( !Q_strnicmp( pString, "aux", 3 ) )
	{
		int nIndex = atoi( &pString[3] );
		if ( nIndex < 29 )
			return JOYSTICK_BUTTON( 0, nIndex );
		if ( ( nIndex >= 29 ) && ( nIndex <= 32 ) )
			return JOYSTICK_POV_BUTTON( 0, nIndex - 29 );
		return BUTTON_CODE_INVALID;
	}

	for ( int i = 0; i < BUTTON_CODE_LAST; ++i )
	{
		if ( !Q_stricmp( s_pButtonCodeName[i], pString ) )
			return (ButtonCode_t)i;
	}

#if !defined ( _X360 )
	if ( bXController )
	{
		for ( int i = 0; i < ARRAYSIZE(s_pXControllerButtonCodeNames); ++i )
		{
			if ( !Q_stricmp( s_pXControllerButtonCodeNames[i], pString ) )
				return (ButtonCode_t)(JOYSTICK_FIRST_BUTTON + i);
		}
	}
#endif

	return BUTTON_CODE_INVALID;
}
ButtonCode_t ButtonCode_XKeyToButtonCode( int nPort, int keyCode )
{
	if ( keyCode < 0 || keyCode >= sizeof( s_pXKeyTrans ) / sizeof( s_pXKeyTrans[0] ) )
	{
		Assert( false );
		return KEY_NONE;
	}

	ButtonCode_t code = s_pXKeyTrans[keyCode];
	if ( IsJoystickButtonCode( code ) )
	{
		int nOffset = code - JOYSTICK_FIRST_BUTTON;
		return JOYSTICK_BUTTON( nPort, nOffset );
	}
	
	if ( IsJoystickPOVCode( code ) )
	{
		int nOffset = code - JOYSTICK_FIRST_POV_BUTTON;
		return JOYSTICK_POV_BUTTON( nPort, nOffset );
	}
	
	if ( IsJoystickAxisCode( code ) )
	{
		int nOffset = code - JOYSTICK_FIRST_AXIS_BUTTON;
		return JOYSTICK_AXIS_BUTTON( nPort, nOffset );
	}

	return code;
}
Ejemplo n.º 4
0
Humanoid::Humanoid(int iType, int iPlayerFlag) : Character(iType, iPlayerFlag) 
{
	bGroundClamped = true;

	SetAcceleration(100);
	SetFriction(35);
	SetJumpStrength(15);


	iSelectedArrow=Arrow::ARROW_TYPE_NORMAL;

	SetWHO(Vector(0, 0.5f, 1.0f));


	//initialize all elements in iActionArray to -1 (-1 is a bogus entry)
	for(int i=0; i< HUMANOID_NUM; ++i)
		iActionArray[i]=-1;

	if(cPlayer==CHARACTER_PLAYER1||cPlayer==CHARACTER_PLAYER2)
	{
		pActionMap->GetJoystick()->SetDeadZone(900);

		iActionArray[HUMANOID_JUMP]=pActionMap->AddAction("Jump", DIK_SPACE, -1, JOYSTICK_BUTTON(2));

		iActionArray[HUMANOID_SHOOT_ARROW]=pActionMap->AddAction("Shoot Arrow", DIK_UP, -1, JOYSTICK_BUTTON(0));

		iActionArray[HUMANOID_SWITCH_ARROW]=pActionMap->AddAction("Switch Arrow", DIK_DOWN, -1, JOYSTICK_BUTTON(3));

		iActionArray[HUMANOID_SWING_CAMERA_LEFT]=pActionMap->AddAction("Camera Left", DIK_LEFT, -1, JOYSTICK_BUTTON(4));

		iActionArray[HUMANOID_SWING_CAMERA_RIGHT]=pActionMap->AddAction("Camera Right", DIK_RIGHT, -1, JOYSTICK_BUTTON(5));

		//keyboard movement controls
		//iActionArray[HUMANOID_MOVE_FORWARD]=pActionMap->AddAction("Move Forward", DIK_W, NULL, NULL);
		//iActionArray[HUMANOID_MOVE_BACKWARD]=pActionMap->AddAction("Move Backward", DIK_S, NULL, NULL);
		//iActionArray[HUMANOID_MOVE_RIGHT]=pActionMap->AddAction("Move Right", DIK_D, NULL, NULL);
		//iActionArray[HUMANOID_MOVE_LEFT]=pActionMap->AddAction("Move Left", DIK_A, NULL, NULL);
	}
}
Ejemplo n.º 5
0
void COptions::SetDefaultValues(void)
{
    // Time of a match (TimeStart) and when the arena closing begins (TimeUp)
    m_TimeUpMinutes = TIMEUP_MINUTES;
    m_TimeUpSeconds = TIMEUP_SECONDS;
    m_TimeStartMinutes = TIMESTART_MINUTES;
    m_TimeStartSeconds = TIMESTART_SECONDS;

    // Number of matches for a battle
    m_BattleCount = 3;

    // First level file (index=0) is selected
    m_Level = 0;

    // Default display mode is windowed, not full-screen
#ifdef _DEBUG
    m_DisplayMode = DISPLAYMODE_WINDOWED;
#else
    m_DisplayMode = DISPLAYMODE_FULL3;
#endif

    // Set the bomber types
    m_BomberType[0] = BOMBERTYPE_MAN;
    m_BomberType[1] = BOMBERTYPE_MAN;
    m_BomberType[2] = BOMBERTYPE_OFF;
    m_BomberType[3] = BOMBERTYPE_OFF;
    m_BomberType[4] = BOMBERTYPE_OFF;

    // Set the bomber teams
    m_BomberTeam[0] = BOMBERTEAM_A;
    m_BomberTeam[1] = BOMBERTEAM_A;
    m_BomberTeam[2] = BOMBERTEAM_B;
    m_BomberTeam[3] = BOMBERTEAM_B;
    m_BomberTeam[4] = BOMBERTEAM_B;

    // Initialise player inputs
    for (int i = 0 ; i < MAX_PLAYERS ; i++)
        m_PlayerInput[i] = CONFIGURATION_KEYBOARD_1 + i;

    // Set default keyboard keys and joystick buttons
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_UP]      = KEYBOARD_UP;
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_DOWN]    = KEYBOARD_DOWN;
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_LEFT]    = KEYBOARD_LEFT;
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_RIGHT]   = KEYBOARD_RIGHT;
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_ACTION1] = KEYBOARD_X;
    m_Control[CONFIGURATION_KEYBOARD_1][CONTROL_ACTION2] = KEYBOARD_Z;

    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_UP]      = KEYBOARD_NUMPAD8;
    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_DOWN]    = KEYBOARD_NUMPAD5;
    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_LEFT]    = KEYBOARD_NUMPAD4;
    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_RIGHT]   = KEYBOARD_NUMPAD6;
    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_ACTION1] = KEYBOARD_Y;
    m_Control[CONFIGURATION_KEYBOARD_2][CONTROL_ACTION2] = KEYBOARD_T;

    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_UP]      = KEYBOARD_I;
    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_DOWN]    = KEYBOARD_K;
    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_LEFT]    = KEYBOARD_J;
    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_RIGHT]   = KEYBOARD_L;
    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_ACTION1] = KEYBOARD_8;
    m_Control[CONFIGURATION_KEYBOARD_3][CONTROL_ACTION2] = KEYBOARD_7;

    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_UP]      = KEYBOARD_H;
    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_DOWN]    = KEYBOARD_N;
    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_LEFT]    = KEYBOARD_B;
    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_RIGHT]   = KEYBOARD_M;
    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_ACTION1] = KEYBOARD_5;
    m_Control[CONFIGURATION_KEYBOARD_4][CONTROL_ACTION2] = KEYBOARD_4;

    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_UP]      = KEYBOARD_R;
    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_DOWN]    = KEYBOARD_F;
    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_LEFT]    = KEYBOARD_D;
    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_RIGHT]   = KEYBOARD_G;
    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_ACTION1] = KEYBOARD_1;
    m_Control[CONFIGURATION_KEYBOARD_5][CONTROL_ACTION2] = KEYBOARD_2;

    for ( unsigned int j = CONFIGURATION_JOYSTICK_1 ; j < MAX_PLAYER_INPUT ; j++)
    {
        m_Control[j][CONTROL_UP]      = JOYSTICK_UP;
        m_Control[j][CONTROL_DOWN]    = JOYSTICK_DOWN;
        m_Control[j][CONTROL_LEFT]    = JOYSTICK_LEFT;
        m_Control[j][CONTROL_RIGHT]   = JOYSTICK_RIGHT;
        m_Control[j][CONTROL_ACTION1] = JOYSTICK_BUTTON(0);
        m_Control[j][CONTROL_ACTION2] = JOYSTICK_BUTTON(1);
    }
}