Exemplo n.º 1
0
//
// G_BoundKeys
//
// Get an ascii description of the keys bound to a particular action
//
const char *G_BoundKeys(const char *action)
{
   int i;
   static char ret[1024];   // store list of keys bound to this   
   keyaction_t *ke;
   
   if(!(ke = G_KeyActionForName(action)))
      return "unknown action";
   
   ret[0] = '\0';   // clear ret
   
   // sequential search -ugh

   // FIXME: buffer overflow possible!
   
   for(i = 0; i < NUM_KEYS; ++i)
   {
      if(keybindings[i].bindings[ke->bclass] == ke)
      {
         if(ret[0])
            strcat(ret, " + ");
         strcat(ret, keybindings[i].name);
      }
   }
   
   return ret[0] ? ret : "none";
}
Exemplo n.º 2
0
//
// G_BindResponder
//
// Responder for widget
//
bool G_BindResponder(event_t *ev)
{
   keyaction_t *action;
   
   if(ev->type != ev_keydown)
      return false;

   // do not index out of bounds
   if(ev->data1 >= NUM_KEYS)
      return false;
   
   // got a key - close box
   MN_PopWidget();

   if(action_menu_toggle) // cancel
   {
      action_menu_toggle = false;
      return true;
   }
   
   if(!(action = G_KeyActionForName(binding_action)))
   {
      C_Printf(FC_ERROR "unknown action '%s'\n", binding_action);
      return true;
   }

   // bind new key to action, if it is not already bound -- if it is,
   // remove it
   
   if(keybindings[ev->data1].bindings[action->bclass] != action)
      keybindings[ev->data1].bindings[action->bclass] = action;
   else
      keybindings[ev->data1].bindings[action->bclass] = NULL;

   // haleyjd 10/16/05: clear state of action involved
   keybindings[ev->data1].keydown[action->bclass] = false;
   if(action->type == at_variable)
      *(action->value.variable) = 0;
   
   return true;
}
Exemplo n.º 3
0
//
// G_BindKeyToAction
//
static void G_BindKeyToAction(const char *key_name, const char *action_name)
{
   int key;
   keyaction_t *action;
   
   // get key
   if((key = G_KeyForName(key_name)) < 0)
   {
      C_Printf("unknown key '%s'\n", key_name);
      return;
   }

   // get action   
   if(!(action = G_KeyActionForName(action_name)))
   {
      C_Printf("unknown action '%s'\n", action_name);
      return;
   }

   // haleyjd 07/03/04: support multiple binding classes
   keybindings[key].bindings[action->bclass] = action;
}
Exemplo n.º 4
0
//
// G_BindResponder
//
// Responder for widget
//
static bool G_BindResponder(event_t *ev, int mnaction)
{
   keyaction_t *action;
   
   if(ev->type != ev_keydown)
      return false;

   // do not index out of bounds
   if(ev->data1 >= NUMKEYS)
      return false;
   
   // got a key - close box
   MN_PopWidget();

   if(mnaction == ka_menu_toggle) // cancel
      return true;
   
   if(!(action = G_KeyActionForName(binding_action)))
   {
      C_Printf(FC_ERROR "unknown action '%s'\n", binding_action);
      return true;
   }

   // bind new key to action, if it is not already bound -- if it is,
   // remove it
   
   if(keybindings[ev->data1].bindings[action->bclass] != action)
      keybindings[ev->data1].bindings[action->bclass] = action;
   else
      keybindings[ev->data1].bindings[action->bclass] = NULL;

   // haleyjd 10/16/05: clear state of action involved
   bool wasdown = keybindings[ev->data1].keydown[action->bclass];
   keybindings[ev->data1].keydown[action->bclass] = false;
   if(wasdown)
      --gGameKeyCount[action->bclass][action->num];
   
   return true;
}
Exemplo n.º 5
0
//
// G_FirstBoundKey
//
// Get an ascii description of the first key bound to a particular 
// action.
//
const char *G_FirstBoundKey(const char *action)
{
   static char ret[1024];
   keyaction_t *ke;

   if(!(ke = G_KeyActionForName(action)))
      return "unknown action";

   ret[0] = '\0';   // clear ret

   // sequential search -ugh

   for(doomkey_t &keybinding : keybindings)
   {
      if(keybinding.bindings[ke->bclass] == ke)
      {
         strcpy(ret, keybinding.name);
         break;
      }
   }

   return ret[0] ? ret : "none";
}
Exemplo n.º 6
0
//
// G_BoundKeys
//
// Get an ascii description of the keys bound to a particular action
//
void G_BoundKeys(const char *action, qstring &outstr)
{
   keyaction_t *ke;

   if(!(ke = G_KeyActionForName(action)))
   {
      outstr = "unknown action";
      return;
   }

   // sequential search -ugh
   for(doomkey_t &keybinding : keybindings)
   {
      if(keybinding.bindings[ke->bclass] == ke)
      {
         if(outstr.length() > 0)
            outstr += " + ";
         outstr += keybinding.name;
      }
   }

   if(!outstr.length())
      outstr = "none";
}