clipper-dual-control.nas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ###############################################################################
  2. ## Nasal for dual control of the raven over the multiplayer network.
  3. ##
  4. ## Copyright (C) 2007 - 2008 Anders Gidenstam (anders(at)gidenstam.org)
  5. ## This file is licensed under the GPL license version 2 or later.
  6. ##
  7. ## Modified by Clément de l'Hamaide for Robinson R44 Raven II - 02/05/2011
  8. ##
  9. ###############################################################################
  10. ## Renaming (almost :)
  11. var DCT = dual_control_tools;
  12. ## Pilot/copilot aircraft identifiers. Used by dual_control.
  13. var pilot_type = "Aircraft/R44/Models/clipper.xml";
  14. var copilot_type = "Aircraft/R44/Models/clipper-copilot.xml";
  15. ######################### RAVEN PROPERTIES MP ###########################
  16. #####
  17. # pilot properties
  18. ##
  19. var pilot_rudder = "sim/multiplay/generic/float[5]";
  20. var pilot_elevator = "sim/multiplay/generic/float[6]";
  21. var pilot_elevator_trim = "controls/flight/elevator-trim";
  22. var pilot_aileron = "sim/multiplay/generic/float[7]";
  23. var pilot_aileron_trim = "controls/flight/aileron-trim";
  24. var pilot_throttle = "sim/multiplay/generic/float[8]";
  25. var pilot_switches = "sim/multiplay/generic/int[3]";
  26. var pilot_TDM_mpp = "sim/multiplay/generic/string[0]";
  27. #####
  28. # copilot properties
  29. ##
  30. var copilot_rudder = "controls/flight/rudder";
  31. var copilot_elevator = "controls/flight/elevator";
  32. var copilot_elevator_trim = "controls/flight/elevator-trim";
  33. var copilot_aileron = "controls/flight/aileron";
  34. var copilot_aileron_trim = "controls/flight/aileron-trim";
  35. var copilot_throttle = "controls/engines/engine/throttle";
  36. var copilot_switches = "sim/multiplay/generic/int[0]";
  37. var copilot_TDM_mpp = "sim/multiplay/generic/string[0]";
  38. ######################################################################
  39. # Useful instrument related property paths.
  40. # Flight controls
  41. var rudder_cmd = "controls/flight/rudder";
  42. var elevator_cmd = "controls/flight/elevator";
  43. var elevator_trim_cmd = "controls/flight/elevator-trim";
  44. var aileron_cmd = "controls/flight/aileron";
  45. var aileron_trim_cmd = "controls/flight/aileron-trim";
  46. var throttle_cmd = "controls/engines/engine/throttle";
  47. var l_dual_control = "dual-control";
  48. ######################################################################
  49. ###### Used by dual_control to set up the mappings for the pilot #####
  50. ######################## PILOT TO COPILOT ############################
  51. ######################################################################
  52. var pilot_connect_copilot = func (copilot) {
  53. # Make sure dual-control is activated in the FDM FCS.
  54. setprop(l_dual_control, 1);
  55. return [];
  56. }
  57. ##############
  58. var pilot_disconnect_copilot = func {
  59. setprop(l_dual_control, 0);
  60. }
  61. ######################################################################
  62. ##### Used by dual_control to set up the mappings for the copilot ####
  63. ######################## COPILOT TO PILOT ############################
  64. ######################################################################
  65. var copilot_connect_pilot = func (pilot) {
  66. # Make sure dual-control is activated in the FDM FCS.
  67. setprop(l_dual_control, 1);
  68. return [
  69. ##################################################
  70. # Map copilot flight controls to MP properties.
  71. # Map /controls/flight/*
  72. DCT.Translator.new
  73. (pilot.getNode(pilot_rudder),
  74. props.globals.getNode(rudder_cmd)),
  75. DCT.Translator.new
  76. (pilot.getNode(pilot_aileron),
  77. props.globals.getNode(aileron_cmd)),
  78. DCT.Translator.new
  79. (pilot.getNode(pilot_elevator),
  80. props.globals.getNode(elevator_cmd)),
  81. DCT.Translator.new
  82. (pilot.getNode(pilot_throttle),
  83. props.globals.getNode(throttle_cmd)),
  84. # Map /multiplayer[pilot]/controls/flight/*
  85. DCT.Translator.new
  86. (pilot.getNode(pilot_rudder),
  87. pilot.getNode(rudder_cmd)),
  88. DCT.Translator.new
  89. (pilot.getNode(pilot_aileron),
  90. pilot.getNode(aileron_cmd)),
  91. DCT.Translator.new
  92. (pilot.getNode(pilot_elevator),
  93. pilot.getNode(elevator_cmd)),
  94. DCT.Translator.new
  95. (pilot.getNode(pilot_throttle),
  96. pilot.getNode(throttle_cmd)),
  97. ];
  98. }
  99. var copilot_disconnect_pilot = func {
  100. setprop(l_dual_control, 0);
  101. }