Page 2 of 2

no

Posted: Thu Oct 09, 2008 5:39 pm
by 3DModelerMan
What I meant was that WXwidgets has WXjoystick in it. I can't find any OIS libraries that are prebuilt, and when I try to compile it, it won't find direct input, do I have to have a direct input SDK?.

Posted: Fri Oct 10, 2008 3:36 am
by rooly
http://irrlicht.sourceforge.net/phpBB2/ ... highlight=

there. that's my 'sdl event receiver with joystick support'
i can assure you all the joystick axis controls work.

i can't assure you on keyboard, mouse, or joy buttons because i haven't had any chances to test them.

oh

Posted: Fri Oct 10, 2008 2:15 pm
by 3DModelerMan
Thanks! :D .

hmmm

Posted: Thu Oct 16, 2008 2:35 pm
by 3DModelerMan
I've been doing some research on sourceforge, and I found this
http://qjoypad.sourceforge.net/#features
and this
http://sourceforge.net/projects/glfw/
what do you think of these?.

Posted: Thu Oct 16, 2008 2:47 pm
by Dorth
1: You did research, good for you, that's a nice change in attitude.
2: The first library, QJoyPad is GPL, aka, not compatible with Irrlicht license.
3: The second library seems nice but extremely heavy for the needs of Irrlicht. It'd need to be gutted badly. You're better off starting from Rogerborg's version.

Posted: Thu Oct 16, 2008 3:31 pm
by rogerborg
Dorth wrote:1: You did research, good for you, that's a nice change in attitude.
My reaction:

Image

Dorth wrote:2: The first library, QJoyPad is GPL, aka, not compatible with Irrlicht license.
And also XWindows only. I thought you were targetting MS Windows? :?
Dorth wrote:3: The second library seems nice but extremely heavy for the needs of Irrlicht. It'd need to be gutted badly. You're better off starting from Rogerborg's version.
Aw shucks. If you're targetting MS Windows initially, then joystick / joypad is just a handfull of function calls. This is the entire code that I've proposed adding to CIrrDeviceWin32, that enumerates joysticks (once) to find active ones, then polls the active joysticks. It creates an Irrlicht SEvent; if you use similar code in a user app, you don't even need to do that, you can just use the JOYINFOEX values directly.

Code: Select all

#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")

void CIrrDeviceWin32::initialiseJoysticks()
{
	const u32 numberOfJoysticks = ::joyGetNumDevs();
	JOYINFOEX info;
	info.dwSize = sizeof(info);
	info.dwFlags = JOY_RETURNALL;

	JoystickInfo activeJoystick;

	for(u32 joystick = 0; joystick < numberOfJoysticks; ++joystick)
	{
		if(JOYERR_NOERROR == joyGetPosEx(joystick, &info)
			&&
			JOYERR_NOERROR == joyGetDevCaps(joystick, 
											&activeJoystick.Caps,
											sizeof(activeJoystick.Caps)))
		{
			activeJoystick.Index = joystick;
			ActiveJoysticks.push_back(activeJoystick);
		}
	}
}

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

	u32 joystick;
	JOYINFOEX info;
	info.dwSize = sizeof(info);
	info.dwFlags = JOY_RETURNALL;

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

			event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
			event.JoystickEvent.Joystick = joystick;

			event.JoystickEvent.POV = (u16)info.dwPOV;
			if(event.JoystickEvent.POV > 35900)
				event.JoystickEvent.POV = 65535;

			for(int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis)
				event.JoystickEvent.Axis[axis] = 32767;

			switch(caps.wNumAxes)
			{
			default:
			case 6:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V] = 
					(u16)((65535 * (info.dwVpos - caps.wVmin)) / (caps.wVmax - caps.wVmin));

			case 5:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U] = 
					(u16)((65535 * (info.dwUpos - caps.wUmin)) / (caps.wUmax - caps.wUmin));

			case 4:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R] =
					(u16)((65535 * (info.dwRpos - caps.wRmin)) / (caps.wRmax - caps.wRmin));

			case 3:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z] = 
					(u16)((65535 * (info.dwZpos - caps.wZmin)) / (caps.wZmax - caps.wZmin));
			
			case 2:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y] =
					(u16)((65535 * (info.dwYpos - caps.wYmin)) / (caps.wYmax - caps.wYmin));

			case 1:
				event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X] = 
					(u16)((65535 * (info.dwXpos - caps.wXmin)) / (caps.wXmax - caps.wXmin));
			}
			
			event.JoystickEvent.ButtonStates = info.dwButtons;

			(void)postEventFromUser(event);
		}
	}
}

so

Posted: Thu Oct 16, 2008 5:54 pm
by 3DModelerMan
So that does joystick axis controls only I noticed from the code, I don't know what I'll do yet, but I'm definitely going to keep an eye on rogerborgs joystick thing for the event receiver, it looks nice, maybe in the meantime I'll do a little more research and check out MSDN's direct input tutorial. And I'm yeah I'm actually doing MSwindows.

Re: so

Posted: Thu Oct 16, 2008 6:05 pm
by rogerborg
3DModelerMan wrote:So that does joystick axis controls only
All axes, including 2nd analogue stick / throttle / rudder, and POV hat, and up to 32 buttons. Is there anything commonly available on a joystick / gamepad that's not on that list? WinMM doesn't present force feedback or rumble APIs though. If you want that functionality, I'd recommend just going straight to DirectInput. I haven't used that for years though, so I don't know how easy it is to use in its current state.