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
<< "\tName: '" << joystickInfo
[joystick
].Name
.c_str
() << "'" << std
::endl
; std
::cout
<< "\tAxes: " << joystickInfo
[joystick
].Axes
<< std
::endl
; std
::cout
<< "\tButtons: " << joystickInfo
[joystick
].Buttons
<< std
::endl
; std
::cout
<< "\tHat 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 ?