示例#1
0
//
// I_SelectDefaultGamePad
//
// Select the gamepad configured in the configuration file, if it can be
// found. Otherwise, nothing will happen and activePad will remain NULL.
//
bool I_SelectDefaultGamePad()
{
   HALGamePad *pad = NULL;

   // Deselect any active device first.
   if(activePad)
   {
      activePad->deselect();
      activePad = NULL;
   }

   if(i_joysticknum >= 0)
   {
      // search through the master directory for a pad with this number
      PODCollection<HALGamePad *>::iterator itr = masterGamePadList.begin();

      for(; itr != masterGamePadList.end(); itr++)
      {
         if((*itr)->num == i_joysticknum)
         {
            pad = *itr; // found it.
            break;
         }
      }
   }

   // Select the device if it was found.
   if(pad)
   {      
      if(pad->select())
         activePad = pad;
   }

   return (activePad != NULL);
}