no
Posted: Thu Oct 09, 2008 5:39 pm
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?.
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
My reaction:Dorth wrote:1: You did research, good for you, that's a nice change in attitude.
And also XWindows only. I thought you were targetting MS Windows?Dorth wrote:2: The first library, QJoyPad is GPL, aka, not compatible with Irrlicht license.
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.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.
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);
}
}
}
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.3DModelerMan wrote:So that does joystick axis controls only