Historique des modifications - Message

Message #7127

Sujet: Gamepad


TypeDateAuteurContenu
Création du message10-10-2009 16:35:33tmyke
Pour activer la partie Joy (gamepad je pense que c'est pareil, jamais testé)

Code c++ :


int iActivateJoysticks()
{
	core::array<SJoystickInfo> joystickInfo;
	if(globenv.device->activateJoysticks(joystickInfo))
	{
		std::cout << "Joystick support is enabled and " << joystickInfo.size() << " joystick(s) are present." << std::endl;

		if ( joystickInfo.size() == 0 ) return 0;

		for(u32 joystick = 0; joystick < joystickInfo.size(); ++joystick)
		{
			std::cout << "Joystick " << joystick << ":" << std::endl;
			std::cout << "\	Name: '" << joystickInfo[joystick].Name.c_str() << "'" << std::endl;
			std::cout << "\	Axes: " << joystickInfo[joystick].Axes << std::endl;
			std::cout << "\	Buttons: " << joystickInfo[joystick].Buttons << std::endl;

			std::cout << "\	Hat is: ";

			switch(joystickInfo[joystick].PovHat)
			{
			case SJoystickInfo::POV_HAT_PRESENT:
				std::cout << "present" << std::endl;
				break;

			case SJoystickInfo::POV_HAT_ABSENT:
				std::cout << "absent" << std::endl;
				break;

			case SJoystickInfo::POV_HAT_UNKNOWN:
			default:
				std::cout << "unknown" << std::endl;
				break;
			}
		}
		return 1;
	}
	else
	{
		std::cout << "Joystick support is not enabled." << std::endl;
		return 0;
	}
}



ensuite je dirais que tu pourrais écrire un truc comme cela dans la fonction OnEvent:

Code c++ :


		if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT  && event.JoystickEvent.Joystick == 0)
		{
			JoystickState = event.JoystickEvent;
		}



puis pour récupérer des info, pour un joystick on pourrait écrire

Code c++ :


int iJoysticksAxis(int id)
{
	return (int)globenv.receiver.GetJoystickState().Axis[id];
}
int iJoysticksButtonStates()
{
	return (int)globenv.receiver.GetJoystickState().ButtonStates;
}
int iJoysticksPOV()
{
	return (int)globenv.receiver.GetJoystickState().POV;
}
int iJoysticksJoy()
{
	return (int)globenv.receiver.GetJoystickState().Joystick;
}


Pas trop dur de t'accomoder de ces codes pour un joypad, non ?

wink

Retour

OptionsLiens officielsCaractéristiquesStatistiquesCommunauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1441 sujets
11339 messages
Dernier membre inscrit: Saidov17
324 invités en ligne
membre en ligne: -
RSS Feed