[fixed] win32 joystick POV

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
mavhod
Posts: 3
Joined: Tue Sep 22, 2009 5:05 am

[fixed] win32 joystick POV

Post by mavhod »

Code: Select all

// main.cpp
// class MyEventReceiver : public IEventReceiver

virtual bool OnEvent(const SEvent& event)
{
    if(event.EventType == irr::EET_JOYSTICK_INPUT_EVENT)
    {
        event.JoystickEvent.POV;    //this value
    }
}
if joystick not support POV then event.JoystickEvent.POV = 0 that is "up" direction always

i view sourcecode of SDL and modify by:

Code: Select all

//CIrrDeviceWin32.cpp

void CIrrDeviceWin32::pollJoysticks()
{
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
	if(0 == ActiveJoysticks.size())
		return;

	u32			joystick;
	JOYINFOEX	info;
////////// edit
	//info.dwSize = sizeof(info);
	//info.dwFlags = JOY_RETURNALL|JOY_RETURNPOVCTS;
//////////

	for(joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
	{

////////// edit
		info.dwSize		= sizeof(info);
		info.dwFlags	= JOY_RETURNALL|JOY_RETURNPOVCTS;
		if( !(ActiveJoysticks[joystick].Caps.wCaps & JOYCAPS_HASPOV) )
			info.dwFlags &= ~(JOY_RETURNPOV|JOY_RETURNPOVCTS);
//////////

		if(JOYERR_NOERROR == joyGetPosEx(ActiveJoysticks[joystick].Index, &info))
		{
			SEvent event;
			const JOYCAPS & caps = ActiveJoysticks[joystick].Caps;

////////// edit
			event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
			event.JoystickEvent.Joystick = (u8)joystick;

			if(info.dwFlags & JOY_RETURNPOV)
			{
				event.JoystickEvent.POV = (u16)info.dwPOV;
				if(event.JoystickEvent.POV > 35900)
					event.JoystickEvent.POV = 65535;
			}
			else
			{
				event.JoystickEvent.POV	= 65535;
			}
//////////

			for(int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis)
				event.JoystickEvent.Axis[axis] = 0;
    ......
    ......
    ......
		}
	}
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
}
i found more problem in other thing and i'll post it again later
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Thanks. Added to the tracker
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, MSDN was a bit unclear, but it looks as if this change is pretty safe and also works around some other things. Fixed.
sRc
Posts: 431
Joined: Thu Jul 28, 2005 1:44 am
Location: Salt Lake City, Utah
Contact:

Post by sRc »

hybrid wrote: MSDN was a bit unclear
that goes without saying :lol:
The Bard sRc

Blog | Twitter
Post Reply