#1 

10-10-2009 16:09:51

aitina
Membres
Date d'inscription:
Messages: 55
IP: 90.14.213.205
Courriel

Bonjour tout le Monde.

J'ai acheté un gamepad (dans une grande surface)pour l'inclure dans une petite demo .

Auriez-vous un tutorial ou une explication ou encore mieux un listing sur le sujet?

Je vous remercie beaucoup.

Cordialement.


Hors ligne


#2 

10-10-2009 16:35:33

tmyke
Administrateurs
Avatar de tmyke
Date d'inscription:
Messages: 1025
IP: 86.204.178.254
Courriel

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


Force et sagesse...

Hors ligne


Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
166 invités en ligne
membre en ligne: -
RSS Feed