Beispiel #1
0
//--------------------------------------------------------------------------
//  Print all keys
//--------------------------------------------------------------------------
void CKeyMap::Print (FILE* f)
{
  // Iterate over keysets
  std::map<Tag,CKeySet*>::iterator i;
  for (i=kset.begin(); i!=kset.end(); i++) {
    CKeySet *pKeySet = i->second;

    // Format key set unique ID
    char s[8];
    TagToString (s, pKeySet->GetTag());
    fprintf (f, "KeySet '%s' %s\n", s, pKeySet->GetName());

    // Iterate over key definitions within the keyset
    std::map<Tag,CKeyDefinition*>::iterator j;
    for (j=pKeySet->dkey.begin(); j!=pKeySet->dkey.end(); j++) {
      CKeyDefinition *pKeyDef = j->second;

      // Format key definition unique ID
      char sId[8];
      TagToString (sId, pKeyDef->GetTag());

      // Format key code
      char sCode[32];
      formatKeyCode (sCode, pKeyDef->GetCode());

      fprintf (f, "  '%s' %-40s  %s\n", sId, pKeyDef->GetName(), sCode);
    }
  }
}
Beispiel #2
0
//-------------------------------------------------------------------------
// Reset the default key
//  NOTE:  
//    The actual code of the key should be removed from the code table
//    The new code key should be entered into the code table
//-------------------------------------------------------------------------
void CKeySet::SetDefaultValues(CKeyFile *def)
{ std::map<Tag,CKeyDefinition*>::iterator kd = dkey.begin();
  for (kd = dkey.begin(); kd != dkey.end(); kd++)
  { CKeyDefinition* kdf = kd->second;
    int cde = (def)?(def->GetDefault(kset,kdf->GetTag())):(0);
    if (cde) globals->kbd->SwapCode(kdf,cde);
  }
  return;
}
Beispiel #3
0
//-------------------------------------------------------------------------
//  Enter a key definition
//  The key is registered in 2 maps
//  dkey by the generic tag
//  ckey by the keyboard code (for fast access)
//-------------------------------------------------------------------------
void CKeySet::Enter(CKeyDefinition *kdf)
{ Tag gen   = kdf->GetTag();
  int cod   = kdf->GetCode();
	dkey[gen] = kdf;							// Register by Tag
  //---Check that the code is unique in the set --
  std::map<int,CKeyDefinition *>::iterator it = ckey.find(cod);
	//---Register if key is unic in set ------
  if (it == ckey.end())	{ ckey[cod] = kdf; return;	}
  //----Can't have same code for 2 key ------
  if (0 == cod)              return;
  if ((*it).second == kdf)   return; 
  //----------------------------------------------
	kdf->SetCode(0);							// Clear Keyboard key
  CKeyDefinition *pvk = (*it).second;
  char tag1[8];
  TagToString(tag1,kdf->GetTag());
  char tag2[8];
  TagToString(tag2,pvk->GetTag());
  WARNINGLOG("<Kyid> %s ignored (same keyboard code than <Kyid> %s)",tag1,tag2);
  return;
}