Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
config_xml.cpp
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 /*
23  * xml Configuration written by Alexander Rawass <alexannika@users.sourceforge.net>
24  */
25 
26 #include <expat.h>
27 #include "xml_support.h"
28 #include "vegastrike.h"
29 #include <assert.h>
30 #include "config_xml.h"
31 #include "easydom.h"
32 #include "cmd/ai/flykeyboard.h"
33 #include "cmd/ai/firekeyboard.h"
34 #include "cmd/music.h"
35 #include "gfx/loc_select.h"
36 #include "audiolib.h"
37 #include "in_joystick.h"
38 #include "main_loop.h" //for CockpitKeys
39 #include "gfx/cockpit.h"
40 #include "in_kb_data.h"
41 #include "python/python_compile.h"
42 #include "gfx/screenshot.h"
43 using std::cout;
44 using std::endl;
45 using std::cerr;
46 
47 /* *********************************************************** */
48 
49 GameVegaConfig::GameVegaConfig( const char *configfile ) : VegaConfig( configfile )
50 {
51  initCommandMap();
52  initKeyMap();
53  //set hatswitches to off
54  for (int h = 0; h < MAX_HATSWITCHES; h++) {
55  hatswitch_margin[h] = 2.0;
56  for (int v = 0; v < MAX_VALUES; v++)
57  hatswitch[h][v] = 2.0;
58  }
59  for (int i = 0; i < MAX_AXES; i++) {
60  axis_axis[i] = -1;
61  axis_joy[i] = -1;
62  }
63 }
64 
65 /* *********************************************************** */
66 
67 #if 1
68 
69 const float volinc = 1;
70 const float dopinc = .1;
71 void RunPythonPress( const KBData &, KBSTATE );
72 void RunPythonRelease( const KBData &, KBSTATE );
73 void RunPythonToggle( const KBData &, KBSTATE );
74 void RunPythonPhysicsFrame( const KBData &, KBSTATE );
75 void incmusicvol( const KBData&, KBSTATE a );
76 void decmusicvol( const KBData&, KBSTATE a );
77 bool screenshotkey = false;
78 
79 void doReloadShader( const KBData&, KBSTATE a )
80 {
81  if (a == PRESS)
83 }
84 
85 void doScreenshot( const KBData&, KBSTATE a )
86 {
87  if (a == PRESS)
88  screenshotkey = true;
89 }
90 
91 void incvol( const KBData&, KBSTATE a )
92 {
93 #ifdef HAVE_AL
94  if (a == DOWN)
96 #endif
97 }
98 
99 void decvol( const KBData&, KBSTATE a )
100 {
101 #ifdef HAVE_AL
102  if (a == DOWN)
104 #endif
105 }
106 
107 void mute( const KBData&, KBSTATE a )
108 {
109 #ifdef HAVE_AL
110 #endif
111 }
112 
113 void incdop( const KBData&, KBSTATE a )
114 {
115 #ifdef HAVE_AL
116  if (a == DOWN)
118 #endif
119 }
120 void decdop( const KBData&, KBSTATE a )
121 {
122 #ifdef HAVE_AL
123  if (a == DOWN)
125 #endif
126 }
127 
128 #endif //1
129 /* *********************************************************** */
130 
131 void GameVegaConfig::initKeyMap()
132 {
133  //mapping from special key string to glut key
134  key_map["space"] = ' ';
135  key_map["return"] = WSK_RETURN;
136  key_map["enter"] = WSK_KP_ENTER;
137  key_map["function-1"] = WSK_F1;
138  key_map["function-2"] = WSK_F2;
139  key_map["function-3"] = WSK_F3;
140  key_map["function-4"] = WSK_F4;
141  key_map["function-5"] = WSK_F5;
142  key_map["function-6"] = WSK_F6;
143  key_map["function-7"] = WSK_F7;
144  key_map["function-8"] = WSK_F8;
145  key_map["function-9"] = WSK_F9;
146  key_map["function-10"] = WSK_F10;
147  key_map["function-11"] = WSK_F11;
148  key_map["function-12"] = WSK_F12;
149  key_map["function-13"] = WSK_F13;
150  key_map["function-14"] = WSK_F14;
151  key_map["function-15"] = WSK_F15;
152  key_map["keypad-insert"] = WSK_KP0;
153  key_map["keypad-0"] = WSK_KP0;
154  key_map["keypad-1"] = WSK_KP1;
155  key_map["keypad-2"] = WSK_KP2;
156  key_map["keypad-3"] = WSK_KP3;
157  key_map["keypad-4"] = WSK_KP4;
158  key_map["keypad-5"] = WSK_KP5;
159  key_map["keypad-6"] = WSK_KP6;
160  key_map["keypad-7"] = WSK_KP7;
161  key_map["keypad-8"] = WSK_KP8;
162  key_map["keypad-9"] = WSK_KP9;
163  key_map["less-than"] = '<';
164  key_map["greater-than"] = '>';
165  key_map["keypad-numlock"] = WSK_NUMLOCK;
166  key_map["keypad-period"] = WSK_KP_PERIOD;
167  key_map["keypad-delete"] = WSK_KP_PERIOD;
168  key_map["keypad-divide"] = WSK_KP_DIVIDE;
169  key_map["keypad-multiply"] = WSK_KP_MULTIPLY;
170  key_map["keypad-minus"] = WSK_KP_MINUS;
171  key_map["keypad-plus"] = WSK_KP_PLUS;
172  key_map["keypad-enter"] = WSK_KP_ENTER;
173  key_map["keypad-equals"] = WSK_KP_EQUALS;
174  key_map["scrollock"] = WSK_SCROLLOCK;
175  key_map["right-ctrl"] = WSK_RCTRL;
176  key_map["left-ctrl"] = WSK_LCTRL;
177  key_map["right-alt"] = WSK_RALT;
178  key_map["left-alt"] = WSK_LALT;
179  key_map["right-meta"] = WSK_RMETA;
180  key_map["left-meta"] = WSK_LMETA;
181  key_map["cursor-left"] = WSK_LEFT;
182  key_map["cursor-up"] = WSK_UP;
183  key_map["cursor-right"] = WSK_RIGHT;
184  key_map["cursor-down"] = WSK_DOWN;
185  key_map["cursor-pageup"] = WSK_PAGEUP;
186  key_map["cursor-pagedown"] = WSK_PAGEDOWN;
187  key_map["cursor-home"] = WSK_HOME;
188  key_map["cursor-end"] = WSK_END;
189  key_map["cursor-insert"] = WSK_INSERT;
190  key_map["backspace"] = WSK_BACKSPACE;
191  key_map["capslock"] = WSK_CAPSLOCK;
192  key_map["cursor-delete"] = WSK_DELETE;
193  key_map["tab"] = WSK_TAB;
194  key_map["esc"] = WSK_ESCAPE;
195  key_map["break"] = WSK_BREAK;
196  key_map["pause"] = WSK_PAUSE;
197 }
198 
199 /* *********************************************************** */
200 extern void inc_time_compression( const KBData&, KBSTATE a );
201 extern void JoyStickToggleKey( const KBData&, KBSTATE a );
202 extern void SuicideKey( const KBData&, KBSTATE a );
203 extern void dec_time_compression( const KBData&, KBSTATE a );
204 extern void reset_time_compression( const KBData&, KBSTATE a );
205 extern void MapKey( const KBData&, KBSTATE a );
206 extern void VolUp( const KBData&, KBSTATE a );
207 extern void VolDown( const KBData&, KBSTATE a );
208 
209 using namespace CockpitKeys;
212 
213 static void ComposeFunctions( const KBData &composition, KBSTATE k )
214 {
215  std::string s = composition.data;
216  while ( s.length() ) {
217  std::string::size_type where = s.find( " " );
218  std::string t = s.substr( 0, where );
219  if (where != std::string::npos)
220  s = s.substr( where+1 );
221  else
222  s = "";
223  where = t.find( "(" );
224  std::string args;
225  if (where != string::npos) {
226  args = t.substr( where+1 );
227  std::string::size_type paren = args.find( ")" );
228  if (paren != string::npos)
229  args = args.substr( 0, paren );
230  t = t.substr( 0, where );
231  }
232  CommandMap::iterator i = commandMap.find( t );
233  if ( i != commandMap.end() )
234  (*i).second( args, k );
235  }
236 }
237 
238 static void ComposeFunctionsToggle( const KBData &composition, KBSTATE k )
239 {
240  if (k == PRESS || k == RELEASE)
241  ComposeFunctions( composition, k );
242 }
243 
244 void GameVegaConfig::initCommandMap() // DELETE ME
245 {
246 }
247 
248 /* *********************************************************** */
249 
250 void GameVegaConfig::doBindings( configNode *node )
251 {
252  vector< easyDomNode* >::const_iterator siter;
253  for (siter = node->subnodes.begin(); siter != node->subnodes.end(); siter++) {
254  configNode *cnode = (configNode*) (*siter);
255  if ( (cnode)->Name() == "bind" )
256  checkBind( cnode );
257  else if ( ( (cnode)->Name() == "axis" ) )
258  doAxis( cnode );
259  else
260  cout<<"Unknown tag: "<<(cnode)->Name()<<endl;
261  }
262 }
263 
264 /* *********************************************************** */
265 
266 void GameVegaConfig::doAxis( configNode *node )
267 {
268  string name = node->attr_value( "name" );
269  string myjoystick = node->attr_value( "joystick" );
270  string axis = node->attr_value( "axis" );
271  string invertstr = node->attr_value( "inverse" );
272  string mouse_str = node->attr_value( "mouse" );
273  if ( name.empty() || ( mouse_str.empty() && myjoystick.empty() ) || axis.empty() ) {
274  cout<<"no correct axis desription given "<<endl;
275  return;
276  }
277  int joy_nr = atoi( myjoystick.c_str() );
278  if ( !mouse_str.empty() )
279  joy_nr = MOUSE_JOYSTICK;
280  int axis_nr = atoi( axis.c_str() );
281 
282  //no checks for correct number yet
283 
284  bool inverse = false;
285  if ( !invertstr.empty() )
286  inverse = XMLSupport::parse_bool( invertstr );
287  if (name == "x") {
288  axis_joy[0] = joy_nr;
289  joystick[joy_nr]->axis_axis[0] = axis_nr;
290  joystick[joy_nr]->axis_inverse[0] = inverse;
291  } else if (name == "y") {
292  axis_joy[1] = joy_nr;
293  joystick[joy_nr]->axis_axis[1] = axis_nr;
294  joystick[joy_nr]->axis_inverse[1] = inverse;
295  } else if (name == "z") {
296  axis_joy[2] = joy_nr;
297  joystick[joy_nr]->axis_axis[2] = axis_nr;
298  joystick[joy_nr]->axis_inverse[2] = inverse;
299  } else if (name == "throttle") {
300  axis_joy[3] = joy_nr;
301  joystick[joy_nr]->axis_axis[3] = axis_nr;
302  joystick[joy_nr]->axis_inverse[3] = inverse;
303  } else if (name == "hatswitch") {
304  string nr_str = node->attr_value( "nr" );
305  string margin_str = node->attr_value( "margin" );
306  if ( nr_str.empty() || margin_str.empty() ) {
307  cout<<"you have to assign a number and a margin to the hatswitch"<<endl;
308  return;
309  }
310  int nr = atoi( nr_str.c_str() );
311 
312  float margin = atof( margin_str.c_str() );
313  hatswitch_margin[nr] = margin;
314 
315  hatswitch_axis[nr] = axis_nr;
316  hatswitch_joystick[nr] = joy_nr;
317 
318  vector< easyDomNode* >::const_iterator siter;
319 
320  hs_value_index = 0;
321  for (siter = node->subnodes.begin(); siter != node->subnodes.end(); siter++) {
322  configNode *cnode = (configNode*) (*siter);
323  checkHatswitch( nr, cnode );
324  }
325  } else {
326  cout<<"unknown axis "<<name<<endl;
327  return;
328  }
329 }
330 
331 /* *********************************************************** */
332 
333 void GameVegaConfig::checkHatswitch( int nr, configNode *node )
334 {
335  if (node->Name() != "hatswitch") {
336  cout<<"not a hatswitch node "<<endl;
337  return;
338  }
339  string strval = node->attr_value( "value" );
340  float val = atof( strval.c_str() );
341  if (val > 1.0 || val < -1.0) {
342  cout<<"only hatswitch values from -1.0 to 1.0 allowed"<<endl;
343  return;
344  }
345  hatswitch[nr][hs_value_index] = val;
346  cout<<"setting hatswitch nr "<<nr<<" "<<hs_value_index<<" = "<<val<<endl;
347  hs_value_index++;
348 }
349 
350 /* *********************************************************** */
351 
352 void GameVegaConfig::checkBind( configNode *node )
353 {
354  if (node->Name() != "bind") {
355  cout<<"not a bind node "<<endl;
356  return;
357  }
358  std::string tmp = node->attr_value( "modifier" );
359  int modifier = getModifier( tmp.c_str() );
360 
361  string cmdstr = node->attr_value( "command" );
362  string player_bound = node->attr_value( "player" );
363  if ( player_bound.empty() )
364  player_bound = "0";
365  KBHandler handler = commandMap[cmdstr];
366  if (handler == NULL) {
367  cout<<"No such command: "<<cmdstr<<endl;
368  return;
369  }
370  string player_str = node->attr_value( "player" );
371  string joy_str = node->attr_value( "joystick" );
372  string mouse_str = node->attr_value( "mouse" );
373  string keystr = node->attr_value( "key" );
374  string additional_data = node->attr_value( "data" );
375  string buttonstr = node->attr_value( "button" );
376  string hat_str = node->attr_value( "hatswitch" );
377  string dighswitch = node->attr_value( "digital-hatswitch" );
378  string direction = node->attr_value( "direction" );
379  if ( !player_str.empty() ) {
380  if ( !joy_str.empty() ) {
381  int jn = atoi( joy_str.c_str() );
382  if (jn < MAX_JOYSTICKS)
383  joystick[jn]->player = atoi( player_str.c_str() );
384  } else if ( !mouse_str.empty() ) {
385  joystick[MOUSE_JOYSTICK]->player = atoi( player_str.c_str() );
386  }
387  }
388  if ( !keystr.empty() ) {
389  //normal keyboard key
390  //now map the command to a callback function and bind it
391  if (keystr.length() == 1) {
392  BindKey( keystr[0], modifier, XMLSupport::parse_int( player_bound ), handler, KBData( additional_data ) );
393  } else {
394  int glut_key = key_map[keystr];
395  if (glut_key == 0) {
396  cout<<"No such special key: "<<keystr<<endl;
397  return;
398  }
399  BindKey( glut_key, modifier, XMLSupport::parse_int( player_bound ), handler, KBData( additional_data ) );
400  }
401  } else if ( !buttonstr.empty() ) {
402  //maps a joystick button or analogue hatswitch button
403  int button_nr = atoi( buttonstr.c_str() );
404  if ( joy_str.empty() && mouse_str.empty() ) {
405  //it has to be the analogue hatswitch
406  if ( hat_str.empty() ) {
407  cout<<"you got to give a analogue hatswitch number"<<endl;
408  return;
409  }
410  int hatswitch_nr = atoi( hat_str.c_str() );
411 
412  BindHatswitchKey( hatswitch_nr, button_nr, handler, KBData( additional_data ) );
413 
414  } else {
415  //joystick button
416  int joystick_nr;
417  if ( mouse_str.empty() )
418  joystick_nr = atoi( joy_str.c_str() );
419  else
420  joystick_nr = (MOUSE_JOYSTICK);
421  if ( joystick[joystick_nr]->isAvailable() ) {
422  //now map the command to a callback function and bind it
423 
424  //yet to check for correct buttons/joy-nr
425 
426  BindJoyKey( joystick_nr, button_nr, handler, KBData( additional_data ) );
427  }
428  else {
429  static bool first = true;
430  if (first) {
431  cout<<"\nrefusing to bind command to joystick (joy-nr too high)"<<endl;
432  first = false;
433  }
434  }
435  }
436  } else if ( !( dighswitch.empty() || direction.empty() || ( mouse_str.empty() && joy_str.empty() ) ) ) {
437  //digital hatswitch or ...
438  if ( dighswitch.empty() || direction.empty() || ( mouse_str.empty() && joy_str.empty() ) ) {
439  cout<<"you have to specify joystick,digital-hatswitch,direction"<<endl;
440  return;
441  }
442  int hsw_nr = atoi( dighswitch.c_str() );
443 
444  int joy_nr;
445  if ( mouse_str.empty() )
446  joy_nr = atoi( joy_str.c_str() );
447  else
448  joy_nr = MOUSE_JOYSTICK;
449  if ( !(joystick[joy_nr]->isAvailable() && hsw_nr < joystick[joy_nr]->nr_of_hats) ) {
450  cout<<"refusing to bind digital hatswitch: no such hatswitch"<<endl;
451  return;
452  }
453  int dir_index;
454  if (direction == "center") {
455  dir_index = VS_HAT_CENTERED;
456  } else if (direction == "up") {
457  dir_index = VS_HAT_UP;
458  } else if (direction == "right") {
459  dir_index = VS_HAT_RIGHT;
460  } else if (direction == "left") {
461  dir_index = VS_HAT_LEFT;
462  } else if (direction == "down") {
463  dir_index = VS_HAT_DOWN;
464  } else if (direction == "rightup") {
465  dir_index = VS_HAT_RIGHTUP;
466  } else if (direction == "rightdown") {
467  dir_index = VS_HAT_RIGHTDOWN;
468  } else if (direction == "leftup") {
469  dir_index = VS_HAT_LEFTUP;
470  } else if (direction == "leftdown") {
471  dir_index = VS_HAT_LEFTDOWN;
472  } else {
473  cout<<"no valid direction string"<<endl;
474  return;
475  }
476  BindDigitalHatswitchKey( joy_nr, hsw_nr, dir_index, handler, KBData( additional_data ) );
477  cout<<"Bound joy "<<joy_nr<<" hatswitch "<<hsw_nr<<" dir_index "<<dir_index<<" to command "<<cmdstr<<endl;
478  }
479 #if 1
480  else {
481  return;
482  }
483 #endif
484 }
485 
486 /* *********************************************************** */
487 
488 void GameVegaConfig::bindKeys()
489 {
490  doBindings( bindings );
491 }
492 
493 /* *********************************************************** */
495 {
496  //I don't knwo why this gives linker errors!
498  commandMap["NoPositionalKey"] = mute;
499  commandMap["DopplerInc"] = incdop;
500  commandMap["Cockpit::NavScreen"] = GameCockpit::NavScreen;
501  commandMap["DopplerDec"] = decdop;
502  commandMap["VolumeInc"] = VolUp;
503  commandMap["VolumeDec"] = VolDown;
504  commandMap["MusicVolumeInc"] = incmusicvol;
505  commandMap["MusicVolumeDec"] = decmusicvol;
506  commandMap["SetShieldsOneThird"] = FireKeyboard::SetShieldsOneThird;
507  commandMap["SetShieldsOff"] = FireKeyboard::SetShieldsOff;
508  commandMap["SetShieldsTwoThird"] = FireKeyboard::SetShieldsTwoThird;
509  commandMap["SwitchControl"] = GameCockpit::SwitchControl;
510  commandMap["Respawn"] = GameCockpit::Respawn;
511  commandMap["TurretControl"] = GameCockpit::TurretControl;
512 
513  commandMap["TimeInc"] = inc_time_compression;
514  commandMap["TimeDec"] = dec_time_compression;
515  commandMap["TimeReset"] = reset_time_compression;
516  //mapping from command string to keyboard handler
517  //Networking bindings
518 
519  commandMap["SwitchWebcam"] = FlyByKeyboard::SwitchWebcam;
520  commandMap["SwitchSecured"] = FlyByKeyboard::SwitchSecured;
521  commandMap["ChangeCommStatus"] = FlyByKeyboard::ChangeCommStatus;
522  commandMap["UpFreq"] = FlyByKeyboard::UpFreq;
523  commandMap["DownFreq"] = FlyByKeyboard::DownFreq;
524 
525  commandMap["ThrustModeKey"] = FlyByKeyboard::KSwitchFlightMode;
526  commandMap["ThrustRight"] = FlyByKeyboard::KThrustRight;
527  commandMap["ThrustLeft"] = FlyByKeyboard::KThrustLeft;
528  commandMap["ThrustBack"] = FlyByKeyboard::KThrustBack;
529  commandMap["ThrustFront"] = FlyByKeyboard::KThrustFront;
530  commandMap["ThrustDown"] = FlyByKeyboard::KThrustDown;
531  commandMap["ThrustUp"] = FlyByKeyboard::KThrustUp;
532  commandMap["TextMessage"] = CockpitKeys::TextMessageKey;
533  commandMap["JoyStickToggleKey"] = JoyStickToggleKey;
534  commandMap["ToggleAutotracking"] = FireKeyboard::ToggleAutotracking;
535  commandMap["SheltonKey"] = FlyByKeyboard::SheltonKey;
536  commandMap["MatchSpeedKey"] = FlyByKeyboard::MatchSpeedKey;
537  commandMap["PauseKey"] = FireKeyboard::TogglePause;
538  commandMap["JumpKey"] = FlyByKeyboard::JumpKey;
539  commandMap["AutoKey"] = FlyByKeyboard::AutoKey;
540  commandMap["SwitchCombatMode"] = FlyByKeyboard::SwitchCombatModeKey;
541  commandMap["StartKey"] = FlyByKeyboard::StartKey;
542  commandMap["StopKey"] = FlyByKeyboard::StopKey;
543  commandMap["Screenshot"] = doScreenshot;
544  commandMap["UpKey"] = FlyByKeyboard::UpKey;
545  commandMap["DownKey"] = FlyByKeyboard::DownKey;
546  commandMap["LeftKey"] = FlyByKeyboard::LeftKey;
547  commandMap["RightKey"] = FlyByKeyboard::RightKey;
548  commandMap["ABKey"] = FlyByKeyboard::ABKey;
549  commandMap["AccelKey"] = FlyByKeyboard::AccelKey;
550  commandMap["DecelKey"] = FlyByKeyboard::DecelKey;
551  commandMap["RollLeftKey"] = FlyByKeyboard::RollLeftKey;
552  commandMap["RollRightKey"] = FlyByKeyboard::RollRightKey;
553  commandMap["SetVelocityRefKey"] = FlyByKeyboard::SetVelocityRefKey;
554  commandMap["SetVelocityNullKey"] = FlyByKeyboard::SetNullVelocityRefKey;
555  commandMap["ToggleGlow"] = FireKeyboard::ToggleGlow;
556  commandMap["ToggleWarpDrive"] = FireKeyboard::ToggleWarpDrive;
557  commandMap["ToggleAnimation"] = FireKeyboard::ToggleAnimation;
558  commandMap["CommAttackTarget"] = FireKeyboard::AttackTarget;
559  commandMap["ASAP"] = FlyByKeyboard::EngageSpecAuto;
560 
561  commandMap["CommHelpMeOutCrit"] = FireKeyboard::HelpMeOutCrit;
562  commandMap["CommHelpMeOutFaction"] = FireKeyboard::HelpMeOutFaction;
563  commandMap["JoinFlightgroup"] = FireKeyboard::JoinFg;
564  commandMap["CommAttackTarget"] = FireKeyboard::AttackTarget;
565  commandMap["CommHelpMeOut"] = FireKeyboard::HelpMeOut;
566  commandMap["CommFormUp"] = FireKeyboard::FormUp;
567  commandMap["CommDockWithMe"] = FireKeyboard::DockWithMe;
568  commandMap["CommDefendTarget"] = FireKeyboard::DefendTarget;
569  commandMap["CommDockAtTarget"] = FireKeyboard::DockTarget;
570  commandMap["CommHoldPosition"] = FireKeyboard::HoldPosition;
571  //Added for nearest unit targeting -ch
572  commandMap["NearestHostileTargetKey"] = FireKeyboard::NearestHostileTargetKey;
573  commandMap["NearestDangerousHostileKey"] = FireKeyboard::NearestDangerousHostileKey;
574  commandMap["NearestFriendlyKey"] = FireKeyboard::NearestFriendlyKey;
575  commandMap["NearestBaseKey"] = FireKeyboard::NearestBaseKey;
576  commandMap["NearestPlanetKey"] = FireKeyboard::NearestPlanetKey;
577  commandMap["NearestJumpKey"] = FireKeyboard::NearestJumpKey;
578 
579 #ifdef CAR_SIM
580  commandMap["BlinkLeftKey"] = FireKeyboard::BlinkLeftKey;
581  commandMap["BlinkRightKey"] = FireKeyboard::BlinkRightKey;
582  commandMap["HeadlightKey"] = FireKeyboard::HeadlightKey;
583  commandMap["SirenKey"] = FireKeyboard::SirenKey;
584 #endif
585  commandMap["CommBreakForm"] = FireKeyboard::BreakFormation;
586 
587  commandMap["Comm1Key"] = FireKeyboard::PressComm1Key;
588  commandMap["Comm2Key"] = FireKeyboard::PressComm2Key;
589  commandMap["Comm3Key"] = FireKeyboard::PressComm3Key;
590  commandMap["Comm4Key"] = FireKeyboard::PressComm4Key;
591  commandMap["Comm5Key"] = FireKeyboard::PressComm5Key;
592  commandMap["Comm6Key"] = FireKeyboard::PressComm6Key;
593  commandMap["Comm7Key"] = FireKeyboard::PressComm7Key;
594  commandMap["Comm8Key"] = FireKeyboard::PressComm8Key;
595  commandMap["Comm9Key"] = FireKeyboard::PressComm9Key;
596  commandMap["Comm10Key"] = FireKeyboard::PressComm10Key;
597 
598  commandMap["SaveTarget1"] = FireKeyboard::SaveTarget1Key;
599  commandMap["SaveTarget2"] = FireKeyboard::SaveTarget2Key;
600  commandMap["SaveTarget3"] = FireKeyboard::SaveTarget3Key;
601  commandMap["SaveTarget4"] = FireKeyboard::SaveTarget4Key;
602  commandMap["SaveTarget5"] = FireKeyboard::SaveTarget5Key;
603  commandMap["SaveTarget6"] = FireKeyboard::SaveTarget6Key;
604  commandMap["SaveTarget7"] = FireKeyboard::SaveTarget7Key;
605  commandMap["SaveTarget8"] = FireKeyboard::SaveTarget8Key;
606  commandMap["SaveTarget9"] = FireKeyboard::SaveTarget9Key;
607  commandMap["SaveTarget10"] = FireKeyboard::SaveTarget10Key;
608 
609  commandMap["RestoreTarget1"] = FireKeyboard::RestoreTarget1Key;
610  commandMap["RestoreTarget2"] = FireKeyboard::RestoreTarget2Key;
611  commandMap["RestoreTarget3"] = FireKeyboard::RestoreTarget3Key;
612  commandMap["RestoreTarget4"] = FireKeyboard::RestoreTarget4Key;
613  commandMap["RestoreTarget5"] = FireKeyboard::RestoreTarget5Key;
614  commandMap["RestoreTarget6"] = FireKeyboard::RestoreTarget6Key;
615  commandMap["RestoreTarget7"] = FireKeyboard::RestoreTarget7Key;
616  commandMap["RestoreTarget8"] = FireKeyboard::RestoreTarget8Key;
617  commandMap["RestoreTarget9"] = FireKeyboard::RestoreTarget9Key;
618  commandMap["RestoreTarget10"] = FireKeyboard::RestoreTarget10Key;
619 
620  commandMap["FreeSlaves"] = FireKeyboard::FreeSlaveKey;
621  commandMap["Enslave"] = FireKeyboard::EnslaveKey;
622  commandMap["EjectCargoKey"] = FireKeyboard::EjectCargoKey;
623  commandMap["EjectNonMissionCargoKey"] = FireKeyboard::EjectNonMissionCargoKey;
624  commandMap["EjectKey"] = FireKeyboard::EjectKey;
625  commandMap["EjectDockKey"] = FireKeyboard::EjectDockKey;
626  commandMap["SuicideKey"] = SuicideKey;
627  commandMap["TurretAIOn"] = FireKeyboard::TurretAIOn;
628  commandMap["TurretAIOff"] = FireKeyboard::TurretAIOff;
629  commandMap["TurretAIFireAtWill"] = FireKeyboard::TurretFireAtWill;
630 
631  commandMap["DockKey"] = FireKeyboard::DockKey;
632  commandMap["UnDockKey"] = FireKeyboard::UnDockKey;
633  commandMap["RequestClearenceKey"] = FireKeyboard::RequestClearenceKey;
634  commandMap["FireKey"] = FireKeyboard::FireKey;
635  commandMap["MissileKey"] = FireKeyboard::MissileKey;
636  commandMap["TargetKey"] = FireKeyboard::TargetKey;
637  commandMap["LockTargetKey"] = FireKeyboard::LockKey;
638  commandMap["ReverseTargetKey"] = FireKeyboard::ReverseTargetKey;
639  commandMap["PickTargetKey"] = FireKeyboard::PickTargetKey;
640  commandMap["SubUnitTargetKey"] = FireKeyboard::SubUnitTargetKey;
641  commandMap["NearestTargetKey"] = FireKeyboard::NearestTargetKey;
642  commandMap["MissileTargetKey"] = FireKeyboard::MissileTargetKey;
643  commandMap["IncomingMissileTargetKey"] = FireKeyboard::IncomingMissileTargetKey;
644  commandMap["ReverseMissileTargetKey"] = FireKeyboard::ReverseMissileTargetKey;
645  commandMap["ReverseIncomingMissileTargetKey"] = FireKeyboard::ReverseIncomingMissileTargetKey;
646  commandMap["ThreatTargetKey"] = FireKeyboard::ThreatTargetKey;
647  commandMap["SigTargetKey"] = FireKeyboard::SigTargetKey;
648  commandMap["UnitTargetKey"] = FireKeyboard::UnitTargetKey;
649  commandMap["ReversePickTargetKey"] = FireKeyboard::ReversePickTargetKey;
650  commandMap["ReverseNearestTargetKey"] = FireKeyboard::ReverseNearestTargetKey;
651  commandMap["ReverseThreatTargetKey"] = FireKeyboard::ReverseThreatTargetKey;
652  commandMap["ReverseSigTargetKey"] = FireKeyboard::ReverseSigTargetKey;
653  commandMap["ReverseUnitTargetKey"] = FireKeyboard::ReverseUnitTargetKey;
654  commandMap["MissionTargetKey"] = FireKeyboard::MissionTargetKey;
655  commandMap["ReverseMissionTargetKey"] = FireKeyboard::ReverseMissionTargetKey;
656  commandMap["TurretTargetKey"] = FireKeyboard::TargetTurretKey;
657  commandMap["TurretPickTargetKey"] = FireKeyboard::PickTargetTurretKey;
658  commandMap["TurretNearestTargetKey"] = FireKeyboard::NearestTargetTurretKey;
659  commandMap["TurretThreatTargetKey"] = FireKeyboard::ThreatTargetTurretKey;
660  commandMap["WeapSelKey"] = FireKeyboard::WeapSelKey;
661  commandMap["MisSelKey"] = FireKeyboard::MisSelKey;
662  commandMap["ReverseWeapSelKey"] = FireKeyboard::ReverseWeapSelKey;
663  commandMap["ReverseMisSelKey"] = FireKeyboard::ReverseMisSelKey;
664  commandMap["CloakKey"] = FireKeyboard::CloakKey;
665  commandMap["ECMKey"] = FireKeyboard::ECMKey;
666 
667  commandMap["RunPythonPress"] = RunPythonPress;
668  commandMap["RunPythonRelease"] = RunPythonRelease;
669  commandMap["RunPythonToggle"] = RunPythonToggle;
670  commandMap["RunPythonPhysicsFrame"] = RunPythonPhysicsFrame;
671  commandMap["ComposeFunctions"] = ComposeFunctions;
672  commandMap["ComposeFunctionsToggle"] = ComposeFunctionsToggle;
673  commandMap["Cockpit::ScrollDown"] = CockpitKeys::ScrollDown;
674  commandMap["Cockpit::ScrollUp"] = CockpitKeys::ScrollUp;
675 
676  commandMap["Cockpit::PitchDown"] = CockpitKeys::PitchDown;
677  commandMap["Cockpit::PitchUp"] = CockpitKeys::PitchUp;
678  commandMap["Cockpit::YawLeft"] = CockpitKeys::YawLeft;
679  commandMap["Cockpit::YawRight"] = CockpitKeys::YawRight;
680  commandMap["Cockpit::LookDown"] = CockpitKeys::LookDown;
681  commandMap["Cockpit::LookUp"] = CockpitKeys::LookUp;
682  commandMap["Cockpit::LookLeft"] = CockpitKeys::LookLeft;
683  commandMap["Cockpit::LookRight"] = CockpitKeys::LookRight;
684  commandMap["Cockpit::ViewTarget"] = CockpitKeys::ViewTarget;
685  commandMap["Cockpit::OutsideTarget"] = CockpitKeys::OutsideTarget;
686  commandMap["Cockpit::PanTarget"] = CockpitKeys::PanTarget;
687  commandMap["Cockpit::ZoomOut"] = CockpitKeys::ZoomOut;
688  commandMap["Cockpit::ZoomIn"] = CockpitKeys::ZoomIn;
689  commandMap["Cockpit::ZoomReset"] = CockpitKeys::ZoomReset;
690  commandMap["Cockpit::Inside"] = CockpitKeys::Inside;
691  commandMap["Cockpit::InsideLeft"] = CockpitKeys::InsideLeft;
692  commandMap["Cockpit::InsideRight"] = CockpitKeys::InsideRight;
693  commandMap["Cockpit::InsideBack"] = CockpitKeys::InsideBack;
694  commandMap["Cockpit::SwitchLVDU"] = CockpitKeys::SwitchLVDU;
695 
696  commandMap["Cockpit::CommMode"] = CockpitKeys::CommModeVDU;
697  commandMap["Cockpit::TargetMode"] = CockpitKeys::TargetModeVDU;
698  commandMap["Cockpit::ManifestMode"] = CockpitKeys::ManifestModeVDU;
699  commandMap["Cockpit::ViewMode"] = CockpitKeys::ViewModeVDU;
700  commandMap["Cockpit::DamageMode"] = CockpitKeys::DamageModeVDU;
701  commandMap["Cockpit::GunMode"] = CockpitKeys::GunModeVDU;
702  commandMap["Cockpit::ReverseGunMode"] = CockpitKeys::ReverseGunModeVDU;
703  commandMap["Cockpit::MissileMode"] = CockpitKeys::MissileModeVDU;
704  commandMap["Cockpit::ReverseMissileMode"] = CockpitKeys::ReverseMissileModeVDU;
705  commandMap["Cockpit::ObjectiveMode"] = CockpitKeys::ObjectiveModeVDU;
706  commandMap["Cockpit::ScanningMode"] = CockpitKeys::ScanningModeVDU;
707 
708  commandMap["Cockpit::MapKey"] = MapKey;
709  commandMap["Cockpit::SwitchRVDU"] = CockpitKeys::SwitchRVDU;
710  commandMap["Cockpit::SwitchMVDU"] = CockpitKeys::SwitchMVDU;
711  commandMap["Cockpit::SwitchURVDU"] = CockpitKeys::SwitchURVDU;
712  commandMap["Cockpit::SwitchULVDU"] = CockpitKeys::SwitchULVDU;
713  commandMap["Cockpit::SwitchUMVDU"] = CockpitKeys::SwitchUMVDU;
714  commandMap["Cockpit::Behind"] = CockpitKeys::Behind;
715  commandMap["Cockpit::Pan"] = CockpitKeys::Pan;
716  commandMap["Cockpit::SkipMusicTrack"] = CockpitKeys::SkipMusicTrack;
717 
718  commandMap["Cockpit::Quit"] = CockpitKeys::Quit;
719 
720  commandMap["Joystick::Mode::InertialXY"] = FlyByKeyboard::JoyInertialXYPulsorKey;
721  commandMap["Joystick::Mode::InertialXYToggle"] = FlyByKeyboard::JoyInertialXYToggleKey;
722  commandMap["Joystick::Mode::InertialXZ"] = FlyByKeyboard::JoyInertialXYPulsorKey;
723  commandMap["Joystick::Mode::InertialXZToggle"] = FlyByKeyboard::JoyInertialXYToggleKey;
724  commandMap["Joystick::Mode::Roll"] = FlyByKeyboard::JoyRollPulsorKey;
725  commandMap["Joystick::Mode::RollToggle"] = FlyByKeyboard::JoyRollToggleKey;
726  commandMap["Joystick::Mode::Bank"] = FlyByKeyboard::JoyBankPulsorKey;
727  commandMap["Joystick::Mode::BankToggle"] = FlyByKeyboard::JoyBankToggleKey;
728 
729  commandMap["Flight::Mode::InertialPulsor"] = FlyByKeyboard::InertialPulsorKey;
730  commandMap["Flight::Mode::InertialToggle"] = FlyByKeyboard::InertialToggleKey;
731 
732  commandMap["ConsoleKeys::BringConsole"] = ConsoleKeys::BringConsole;
733  commandMap["NewShader"] = doReloadShader;
734 
735  return commandMap;
736 }
737