Ejemplo n.º 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);
    }
  }
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------
//  Init the button list for the requested joystick
//----------------------------------------------------------------------
void CFuiAxis::ButtonList(int No)
{ jsp = jsm->GetJoystickNo(No);
  if (0 == jsp)     return;
  devPOP->SetButtonText(devMENU[No]);
  butBOX.EmptyIt();
  //-----Locate joystick descriptor
	int       end = jsp->nbt;
  char      txt[128];
  char     *ktx = "";
  CButLine *btl = 0;
  for (int k=0; k<end; k++)
  { CSimButton     *but = jsp->GetButton(k);
    CKeyDefinition *kdf = (but)?(but->GetKey()):(0);
    ktx = (kdf)?(kdf->GetName()):("");
    sprintf(txt,"Button %02d",k);
    btl = new CButLine;
    btl->SetName(txt);
    btl->SetKeyText(ktx);
    butBOX.AddSlot(btl);
  }
  butBOX.Display();
	//--- Set Hat control ---------------------------
	sprintf(txt,"This device has %d HAT",jsp->hNumber());
	SetChildText('labH',txt);
	char	use = jsp->HatUsed();
	chkHAT->SetState(use);
	HatControl();
  return;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------
//  Save keyboard mapping to file
//--------------------------------------------------------------------------
void CKeyMap::SaveCurrentConfig()
{ char codk[128];
  char stag[8];
  int i;
  CStreamFile sf;
  std::map<Tag,CKeySet*>::const_iterator it;
  std::map<Tag,CKeyDefinition*>::const_iterator kit;
  CKeySet        * pset;
  CKeyDefinition * pkey;
  sf.OpenWrite("System/Keymap.txt");
  //
  // file header and version
  //
  sf.WriteString("//=================================================");
  sf.WriteString("// Please note that Keyset are ordered by name     ");
  sf.WriteString("// Menus should come first as they intercept keys  ");
  sf.WriteString("// that may be dispatched to lower entity such as  ");
  sf.WriteString("// Aircraft or ground vehicles                     ");
  sf.WriteString("//=================================================");
  sf.DebObject();
  sf.WriteTag('vers', "---- configuration version ----");
  sf.WriteInt(vers);
  for(it = kset.begin(); it != kset.end(); it++)
  {	pset = it->second;
    sf.WriteTag('kset', "=== KeySet Definition File ===");
    TagToString(stag, it->first);
    sf.WriteString(stag);
    sf.WriteTag('bgno', "========== BEGIN OBJECT ==========");
    sf.WriteTag('name', "---- key set name ----");
    sf.WriteString(pset->GetName());
    sf.WriteTag('user', "---- user can modify ----");
    sf.WriteInt(pset->GetUserModifiableState());
    sf.WriteTag('enab', "---- enabled ----");
    sf.WriteInt(pset->GetEnabledState());
    for(kit = pset->dkey.begin(); kit != pset->dkey.end(); kit++)
      { pkey = kit->second;
        sf.WriteTag('kkey', "---- key definition ----");
        sf.DebObject();
        sf.WriteTag('kyid', "---- key ID ----");
        TagToString(stag, kit->first);
        sf.WriteString(stag);
        sf.WriteTag('name', "---- key name ----");
        sf.WriteString(pkey->GetName());
        sf.WriteTag('code', "---- key code & modifier ----");
				i = pkey->GetCode();
				formatKeyCode(codk,i,0);
				sf.WriteString(codk);
        sf.WriteTag('user', "---- user definable ----");
        sf.WriteInt(pkey->IsUserMod());
        sf.WriteTag('enab', "---- enabled ----");
        sf.WriteInt(pkey->IsEnabled());
        sf.EndObject();
      }
      sf.EndObject();
    }
  // File end
  //
  sf.EndObject();
  sf.Close();
	return;
}