Example #1
0
//
// I_EnumerateGamePads
//
// Enumerate all gamepads.
//
void I_EnumerateGamePads()
{
   // Have all supported drivers enumerate their gamepads
   halpaddriveritem_t *item = halPadDriverTable;

   while(item->name)
   {
      if(item->driver && item->isInit)
         item->driver->enumerateDevices();
      ++item;
   }

   // build the master pad directory
   masterGamePadList.clear();

   item = halPadDriverTable;
   while(item->name)
   {
      if(item->driver)
      {
         PODCollection<HALGamePad *> &pads = item->driver->devices;

         for(auto itr = pads.begin(); itr != pads.end(); itr++)
            masterGamePadList.add(*itr);
      }
      ++item;
   }
}
Example #2
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);
}
Example #3
0
//
// MN_initMetaDeaths
//
// haleyjd 01/22/12: Pull all meta death states out of the player class
// object's metatable.
//
static void MN_initMetaDeaths()
{
   playerclass_t *pclass = players[consoleplayer].pclass;
   MetaTable     *meta   = mobjinfo[pclass->type]->meta;
   MetaState     *state  = NULL;
   
   skview_metadeaths.clear();

   while((state = meta->getNextTypeEx(state)))
   {
      // NB: also matches XDeath implicitly.
      if(M_StrCaseStr(state->getKey(), "Death."))
         skview_metadeaths.add(state);
   }
}
Example #4
0
//
// MetaKeyForIndex
//
// Given a key index, get the key.
//
static metakey_t &MetaKeyForIndex(size_t index)
{
   if(index >= metaKeys.getLength())
      I_Error("MetaKeyForIndex: illegal key index requested\n");

   return *metaKeys[index];
}
Example #5
0
//
// Process an individual switch
//
static void E_processSwitch(cfg_t *cfg)
{
   const char *title    = cfg_title(cfg);
   ESwitchDef *def      = e_switch_namehash.objectForKey(title);
   const bool  modified = !!def;
   if(!def)
   {
      def = new ESwitchDef;
      def->offpic = title;
      e_switch_namehash.addObject(def);
      eswitches.add(def);
      E_EDFLogPrintf("\t\tDefined switch %s\n", title);
   }
   else
      E_EDFLogPrintf("\t\tModified switch %s\n", title);

   auto isset = [modified, cfg](const char *field) {
      return !modified || cfg_size(cfg, field) > 0;
   };

   if(isset(ITEM_SWITCH_ONPIC))
      def->onpic    = cfg_getstr(cfg, ITEM_SWITCH_ONPIC);
   if(isset(ITEM_SWITCH_ONSOUND))
      def->onsound  = cfg_getstr(cfg, ITEM_SWITCH_ONSOUND);
   if(isset(ITEM_SWITCH_OFFSOUND))
      def->offsound = cfg_getstr(cfg, ITEM_SWITCH_OFFSOUND);
   if(isset(ITEM_SWITCH_GAMEINDEX))
      def->episode  = cfg_getint(cfg, ITEM_SWITCH_GAMEINDEX);
}
Example #6
0
//
// MetaKey
//
// If the given key string is already interned, the metakey_t structure that
// stores it will be returned. If not, it will be added to the collection of
// keys and hashed by name.
//
static metakey_t &MetaKey(const char *key)
{
   metakey_t *keyObj;

   // Do we already have this key?
   if(!(keyObj = metaKeyHash.objectForKey(key)))
   {
      keyObj = &metaKeys.addNew();
      keyObj->key     = estrdup(key);
      keyObj->index   = metaKeys.getLength() - 1;
      keyObj->unmodHC = ENCStringHashKey::HashCode(key);

      // hash it
      metaKeyHash.addObject(keyObj, keyObj->unmodHC);
   }

   return *keyObj;
}
Example #7
0
//
// MetaKey
//
// If the given key string is already interned, the metakey_t structure that
// stores it will be returned. If not, it will be added to the collection of
// keys and hashed by name.
//
static metakey_t &MetaKey(const char *key)
{
   metakey_t *keyObj;
   unsigned int unmodHC = ENCStringHashKey::HashCode(key);

   // Do we already have this key?
   if(!(keyObj = metaKeyHash.objectForKey(key, unmodHC)))
   {
      keyObj = estructalloc(metakey_t, 1);

      // add it to the list
      metaKeys.add(keyObj);

      keyObj->key     = estrdup(key);
      keyObj->index   = metaKeys.getLength() - 1;
      keyObj->unmodHC = unmodHC;

      // check for table overload, and hash it
      MetaHashRebuild<>(metaKeyHash);
      metaKeyHash.addObject(keyObj, keyObj->unmodHC);
   }

   return *keyObj;
}
Example #8
0
//
// Adds a switch defined externally
//
void E_AddSwitchDef(const ESwitchDef &extdef)
{
   if(extdef.offpic.empty())
      return;
   const char *title = extdef.offpic.constPtr();
   ESwitchDef *def   = e_switch_namehash.objectForKey(title);

   // NOTE: by external means, switches can't be modified. EDF takes priority.
   if(def)
      return;

   def = new ESwitchDef(extdef);
   e_switch_namehash.addObject(def);
   eswitches.add(def);
   E_EDFLogPrintf("\t\tDefined switch %s from ANIMDEFS\n", title);
}
Example #9
0
//
// I_GetNumGamePads
//
size_t I_GetNumGamePads()
{
   return masterGamePadList.getLength();
}
Example #10
0
//
// MN_SkinResponder
//
// The skin viewer widget responder function. Sorta long and
// hackish, but cool.
//
static bool MN_SkinResponder(event_t *ev, int action)
{
   // only interested in keydown events
   if(ev->type != ev_keydown)
      return false;

   if(action == ka_menu_toggle || action == ka_menu_previous)
   {
      // kill the widget
      skview_metadeaths.clear();
      S_StartInterfaceSound(GameModeInfo->menuSounds[MN_SND_DEACTIVATE]);
      MN_PopWidget();
      return true;
   }

   if(action == ka_menu_left)
   {
      // rotate sprite left
      if(skview_rot == 7)
         skview_rot = 0;
      else
         skview_rot++;

      return true;
   }

   if(action == ka_menu_right)
   {
      // rotate sprite right
      if(skview_rot == 0)
         skview_rot = 7;
      else
         skview_rot--;

      return true;
   }

   if(action == ka_menu_up)
   {
      // increase light level
      if(skview_light != 0)
         --skview_light;

      return true;
   }

   if(action == ka_menu_down)
   {
      // decrease light level
      if(skview_light != 31)
         ++skview_light;

      return true;
   }

   switch(ev->data1)
   {
   case KEYD_RCTRL:
      // attack!
      if(skview_action == SKV_WALKING)
      {
         S_StartInterfaceSound(GameModeInfo->skvAtkSound);
         MN_SkinSetState(states[skview_atkstate2]);
         skview_action = SKV_FIRING;
      }
      break;
   case 'p':
   case 'P':
      // act hurt
      if(skview_action == SKV_WALKING)
      {
         MN_SkinSetState(states[mobjinfo[skview_typenum]->painstate]);
         skview_action = SKV_PAIN;
      }
      break;
   case 'd':
   case 'D':
      // die normally
      if(skview_action != SKV_DEAD)
      {
         MN_SkinSetState(states[mobjinfo[skview_typenum]->deathstate]);
         skview_action = SKV_DEAD;
      }
      break;
   case 'm':
   case 'M':
      // "meta" death (elemental death states)
      if(skview_action != SKV_DEAD && !skview_metadeaths.isEmpty())
      {
         skview_metadeath = skview_metadeaths.wrapIterator();
         MN_SkinSetState(skview_metadeath->state);
         skview_action = SKV_DEAD;
      }
      break;
   case 'x':
   case 'X':
      // gib
      if(skview_action != SKV_DEAD)
      {
         skview_gibbed = true;
         MN_SkinSetState(states[mobjinfo[skview_typenum]->xdeathstate]);
         skview_action = SKV_DEAD;
      }
      break;
   case 'h':
   case 'H':
      // toggle half-speed animation
      skview_halfspeed ^= true;
      break;
   case ' ':
      // "respawn" the player if dead
      if(skview_action == SKV_DEAD)
      {
         S_StartInterfaceSound(GameModeInfo->teleSound);
         MN_SkinSetState(states[mobjinfo[skview_typenum]->seestate]);
         skview_action = SKV_WALKING;
      }
      break;
   default:
      return false;
   }

   return true;
}