Torque2D cannot detect a joystick (Windows)
by Thomas Bazin · in Hardware Issues · 02/02/2013 (2:18 pm) · 12 replies
I have made all the modifications detailed in the community thread at this location: http://www.garagegames.com/community/forums/viewthread/32873
I also added the following line for diagnostic purposes after enabling everything:
echoInputState();
but when the game is run the input state is reported as "Joystick is enabled and inactive".
I have tried it with an Xbox 360 controller attached and it reports the joystick as active and everything seems to work, but when I connect my other joystick it can't seem to find it. Both of the devices show up in the Windows Game Controllers window, so I know the computer is recognizing them both.
Any assistance with this matter would be greatly appreciated.
I also added the following line for diagnostic purposes after enabling everything:
echoInputState();
but when the game is run the input state is reported as "Joystick is enabled and inactive".
I have tried it with an Xbox 360 controller attached and it reports the joystick as active and everything seems to work, but when I connect my other joystick it can't seem to find it. Both of the devices show up in the Windows Game Controllers window, so I know the computer is recognizing them both.
Any assistance with this matter would be greatly appreciated.
#2
02/05/2013 (5:36 pm)
Sorry I worded that wrong, my issue isn't binding multiple joysticks. I am using an Arduino Leonardo that is emulating a joystick. Windows recognizes it as a joystick but Torque can't pick it up. I have been able to detect other joysticks (such as the xbox controller) just not the one I want. Sorry for the confusion but thanks for the reply. Any further suggestions would be greatly appreciated.
#3
Does the arduino joystick in fact numerate to a "joystick" Devices and Printers in Windows? If it does what type of joystick does it enumerate as? (enumerate means what does the USB system think the device is)
For example my Arduino Uno has stock firmware and enumerates as a com port.
If your device enumerates as something other than a joystick then it will not be seen by T2D. If it is not enumerating as a joystick perhaps the firmware on the Atmega16u2 is not correctly programmed to HID joystick firmware.
Edit:
Oops the Leonardo is a bit different than the Uno. There is no Atmega16u2.
02/05/2013 (10:59 pm)
Ahh, okay? Does the arduino joystick in fact numerate to a "joystick" Devices and Printers in Windows? If it does what type of joystick does it enumerate as? (enumerate means what does the USB system think the device is)
For example my Arduino Uno has stock firmware and enumerates as a com port.
If your device enumerates as something other than a joystick then it will not be seen by T2D. If it is not enumerating as a joystick perhaps the firmware on the Atmega16u2 is not correctly programmed to HID joystick firmware.
Edit:
Oops the Leonardo is a bit different than the Uno. There is no Atmega16u2.
#4
The Arduino joystick shows up in the Windows Devices and Printers dialogue as "Keyboard; Mouse; Game Controller" with the icon looking like a keyboard. If I go to check the status of Controllers ("Set up USB Game Controllers" menu option in Windows 7) then it shows up as Arduino Leonardo. I can double-click it and it shows the window to test the joystick (Axis and Button information). It seems that if windows can recognize it to the point of allowing me to check the output, Torque should be able to detect it (unless of course I have a gap in my knowledge as to how Torque determines what is and isn't a "Joystick"). One potential problem is that it also shows up as a COM connection, but that is only used for programming.
Any Ideas?
02/06/2013 (7:20 pm)
Thanks for helping me figure this out.The Arduino joystick shows up in the Windows Devices and Printers dialogue as "Keyboard; Mouse; Game Controller" with the icon looking like a keyboard. If I go to check the status of Controllers ("Set up USB Game Controllers" menu option in Windows 7) then it shows up as Arduino Leonardo. I can double-click it and it shows the window to test the joystick (Axis and Button information). It seems that if windows can recognize it to the point of allowing me to check the output, Torque should be able to detect it (unless of course I have a gap in my knowledge as to how Torque determines what is and isn't a "Joystick"). One potential problem is that it also shows up as a COM connection, but that is only used for programming.
Any Ideas?
#5
Did you download a special firmware or is this a stock firmware?
I looked at the Arduino IDE 1.0.1, but I don't see specific gamepad support for the Leonardo. So I am wondering how you got it to work as a gamepad. You are right, if Windows sees it as a gamepad, and you can test it out with the gamepad dialog it should work in any program that supports a gamepad.
Does it work on other games?
02/06/2013 (11:40 pm)
@Thomas,Did you download a special firmware or is this a stock firmware?
I looked at the Arduino IDE 1.0.1, but I don't see specific gamepad support for the Leonardo. So I am wondering how you got it to work as a gamepad. You are right, if Windows sees it as a gamepad, and you can test it out with the gamepad dialog it should work in any program that supports a gamepad.
Does it work on other games?
#6
http://www.imaginaryindustries.com/blog/?p=80
Other programs have been able to detect it and use it, it's only Torque that won't use it. I was going to post on that site where I got the tutorial, but I am almost positive that the problem is on the Torque side because Windows sees the Joystick.
Once again, I appreciate your help and look forward to any further suggestions.
02/07/2013 (11:33 am)
I followed the process in the follwing link to make it recognizable as a joystick:http://www.imaginaryindustries.com/blog/?p=80
Other programs have been able to detect it and use it, it's only Torque that won't use it. I was going to post on that site where I got the tutorial, but I am almost positive that the problem is on the Torque side because Windows sees the Joystick.
Once again, I appreciate your help and look forward to any further suggestions.
#7
02/07/2013 (6:00 pm)
I looked a the routine that detects device type:DInputDevice::DInputDevice( const DIDEVICEINSTANCE* dii )
{
mDeviceInstance = *dii;
mDevice = NULL;
mAcquired = false;
mNeedSync = false;
mObjInstance = NULL;
mObjFormat = NULL;
mObjInfo = NULL;
mObjBuffer1 = NULL;
mObjBuffer2 = NULL;
mPrevObjBuffer = NULL;
mPrevPOVPos = 0;
switch ( GET_DIDEVICE_TYPE( mDeviceInstance.dwDevType ) )
{
case DI8DEVTYPE_KEYBOARD:
mDeviceType = KeyboardDeviceType;
mDeviceID = smKeyboardCount++;
dSprintf( mName, 29, "keyboard%d", mDeviceID );
break;
case DI8DEVTYPE_MOUSE:
mDeviceType = MouseDeviceType;
mDeviceID = smMouseCount++;
dSprintf( mName, 29, "mouse%d", mDeviceID );
break;
case DI8DEVTYPE_JOYSTICK:
case DI8DEVTYPE_GAMEPAD:
mDeviceType = JoystickDeviceType;
mDeviceID = smJoystickCount++;
dSprintf( mName, 29, "joystick%d", mDeviceID );
break;
default:
mDeviceType = UnknownDeviceType;
mDeviceID = smUnknownCount++;
dSprintf( mName, 29, "unknown%d", mDeviceID );
break;
}
}But I cannot tell if the mDeviceInstance.dwDevType is a flag or a number. Maybe if you can get the relevant console logs we can help figure out what Torque is doing with this device.
#8
02/08/2013 (4:14 pm)
I found some firmware that may give me serial, mouse, keyboard, and joystick on the Uno. I have been wanting to convert mine for a while so I in a few days I may be able to see if I run into the same issue with T2D/T3D.
#9
After doing a lot of research, I found that the Arduino wasn't being recognized as a game controller in the dxdiag (Direct X Diagnostic) window. It was not being assigned a controller ID, despite being recognized as a controller. I assumed Torque references Direct X for its controllers, so I figured I'd take another shot at the Arduino side of it.
I hunted around to find other examples of people using the Leonardo as a game controller and found "Leojoy!" (https://github.com/AlanChatham/LeoJoy). The key aspect of this project is that it can perfectly emulate a PS3 controller, which seems like it would be easier for Direct X to find than a generic joystick. I gave it a shot, and it worked perfectly.
I really appreciate all your help with this, and I guess it's safe to say that the problem was with the Arduino despite the fact that Windows recognized it. Either way, I'm glad to say that the problem is resolved.
Thanks again
02/10/2013 (1:38 pm)
Hey, thanks so much for all your help, but I've found an alternative solution to the problem.After doing a lot of research, I found that the Arduino wasn't being recognized as a game controller in the dxdiag (Direct X Diagnostic) window. It was not being assigned a controller ID, despite being recognized as a controller. I assumed Torque references Direct X for its controllers, so I figured I'd take another shot at the Arduino side of it.
I hunted around to find other examples of people using the Leonardo as a game controller and found "Leojoy!" (https://github.com/AlanChatham/LeoJoy). The key aspect of this project is that it can perfectly emulate a PS3 controller, which seems like it would be easier for Direct X to find than a generic joystick. I gave it a shot, and it worked perfectly.
I really appreciate all your help with this, and I guess it's safe to say that the problem was with the Arduino despite the fact that Windows recognized it. Either way, I'm glad to say that the problem is resolved.
Thanks again
#10
I am glad you found a solution. USB devices can be tricky to say the least. This sounds like it might be a bug in DirectX. For Windows Torque does use DInput (DirectX input). It probably is having issues coping with the device being multiple devices. Does the LeoJoy create multiple devices or just one?
02/10/2013 (4:03 pm)
@Thomas,I am glad you found a solution. USB devices can be tricky to say the least. This sounds like it might be a bug in DirectX. For Windows Torque does use DInput (DirectX input). It probably is having issues coping with the device being multiple devices. Does the LeoJoy create multiple devices or just one?
#11
02/14/2013 (9:17 am)
In the dxdiag window, the Leojoy shows up as a Virtual HID Device (which is assigned a Controller ID) and a LeoJoy! (which has no Controller ID). In the Windows Device Manager, it shows up as an HID-compliant game controller.
#12
One potential problem is that it also shows as a COM connection, but this is only used for programming.
09/27/2013 (2:31 am)
If Windows recognizes it allows me to check the output point, the torque should be able to detect itï¼ï¼ï¼ï¼One potential problem is that it also shows as a COM connection, but this is only used for programming.
Torque Owner Demolishun
DemolishunConsulting Rocks!