Game Development Community

Joystick question

by Levi · in Torque Game Engine · 10/27/2005 (9:35 am) · 4 replies

I'm not sure if I'm posting this in the right place.

I'm pretty new to T2D. I bought the engine lastweek. I'm trying to get the joystick to work, but I haven't had much luck and I haven't been able to find any resources on how to do this.

Do you have to configure the joystick? It's a USB Gravis gamepad and when I call detectJoystick, I get false. So, I know it's not finding my joystick. Does anyone know how to make this work and what i'm missing?

#1
10/27/2005 (10:11 am)
Theres a few joystick resources on the site... the should woth with T2D...

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6904
#2
10/27/2005 (9:17 pm)
It's a gamepad. are gamepad and joysticks handled differently in Torque?

When I call IsJoystickDetected it returns false...I don't think Torque even sees my gamepad. Any thoughts?
#3
10/27/2005 (9:50 pm)
It's a Joystick\Gamepad resource, people have got it working (with joysticks and gamepads)

Do a site search, theres a number of posts about this subject.
#4
10/28/2005 (12:53 pm)
@BillyJack - If you look at the new 1.4RC2 code you'll see that they've fixed it so that gamepads are treated just like joysticks. You just have to make two little changes to T2D to make that work. In winDirectInput.cc you need to change this...

void DInputManager::enumerateDevices()
{
   if ( mDInputInterface )
   {
#ifdef LOG_INPUT
      Input::log( "Enumerating input devices...\n" );
#endif

      DInputDevice::init();
      DInputDevice::smDInputInterface = mDInputInterface;
      mDInputInterface->EnumDevices( DI8DEVTYPE_KEYBOARD, EnumDevicesProc, this, DIEDFL_ATTACHEDONLY );
      mDInputInterface->EnumDevices( DI8DEVTYPE_MOUSE, EnumDevicesProc, this, DIEDFL_ATTACHEDONLY );
      mDInputInterface->EnumDevices( DI8DEVTYPE_JOYSTICK, EnumDevicesProc, this, DIEDFL_ATTACHEDONLY );
      mDInputInterface->EnumDevices( DI8DEVTYPE_GAMEPAD, EnumDevicesProc, this, DIEDFL_ATTACHEDONLY ); // ADD THIS LINE HERE!
   }
}

.. and in winDInputDevice.cc look for the constructor for DInputDevice add the following to the DI8DEVTYPE_JOYSTICK case...

case DI8DEVTYPE_JOYSTICK:
      case DI8DEVTYPE_GAMEPAD: // ADD THIS LINE HERE!
         mDeviceType = JoystickDeviceType;
         mDeviceID   = smJoystickCount++;
         dSprintf( mName, 29, "joystick%d", mDeviceID );
         break;

That's it... the gamepad will now show up as a joystick. As soon as 1.4RC2 is finalized this code will end up in T2D when they are merged.