| 1 |
<?xml version="1.0"?> |
| 2 |
|
| 3 |
<PropertyList> |
| 4 |
<nasal> |
| 5 |
<open> |
| 6 |
<![CDATA[ |
| 7 |
|
| 8 |
|
| 9 |
var dlgRoot = cmdarg(); |
| 10 |
|
| 11 |
var DIALOG_ROOT = "/sim/gui/dialogs/joystick-config"; |
| 12 |
|
| 13 |
# Read the current bindings |
| 14 |
joystick.readConfig(); |
| 15 |
|
| 16 |
# Fill in the joystick names combo box. |
| 17 |
var joysticks = props.globals.getNode("/input/joysticks").getChildren("js"); |
| 18 |
|
| 19 |
if (size(joysticks) == 0) { |
| 20 |
# No joysticks found - no point filling in rest of dialog |
| 21 |
setprop(DIALOG_ROOT ~ "joystick-count", 0); |
| 22 |
} else { |
| 23 |
|
| 24 |
var jsselect = gui.findElementByName(dlgRoot, "jsselect" ); |
| 25 |
|
| 26 |
forindex (var joystick_index; joysticks) { |
| 27 |
var js = joysticks[joystick_index]; |
| 28 |
var js_id = "unknown"; |
| 29 |
if ((js.getNode("id") != nil) and (js.getNode("id").getValue() != nil)) |
| 30 |
{ |
| 31 |
js_id = js.getNode("id").getValue(); |
| 32 |
} |
| 33 |
|
| 34 |
jsselect.getNode("value[" ~ joystick_index ~ "]", 1).setValue(js_id); |
| 35 |
} |
| 36 |
|
| 37 |
var joystick_index = getprop(DIALOG_ROOT ~ "/selected-joystick-index"); |
| 38 |
|
| 39 |
var table = gui.findElementByName(dlgRoot, "axistable"); |
| 40 |
table.removeChildren("checkbox"); |
| 41 |
table.removeChildren("combo"); |
| 42 |
|
| 43 |
# Fill in the valid axis bindings |
| 44 |
for (var i = 0; i < joystick.MAX_AXES; i = i + 1) { |
| 45 |
|
| 46 |
# Label |
| 47 |
var t = table.getChild("text", 2*i + 4, 1); |
| 48 |
|
| 49 |
t.getNode("row", 1).setValue(i + 1); |
| 50 |
|
| 51 |
t.getNode("col", 1).setValue(0); |
| 52 |
t.getNode("label", 1).setValue("Axis " ~ i); |
| 53 |
|
| 54 |
# Raw data |
| 55 |
t = table.getChild("text", 2*i + 5, 1); |
| 56 |
t.getNode("property", 1).setValue("/devices/status/joysticks/joystick[" ~ joystick_index ~ "]/axis[" ~ i ~ "]"); |
| 57 |
t.getNode("row", 1).setValue(i +1 ); |
| 58 |
t.getNode("col", 1).setValue(1); |
| 59 |
t.getNode("label", 1).setValue("01234"); |
| 60 |
t.getNode("format", 1).setValue("%2.2f"); |
| 61 |
t.getNode("halign", 1).setValue("right"); |
| 62 |
t.getNode("live", 1).setValue(1); |
| 63 |
|
| 64 |
# Axis Binding. Changed for 2018.1 to have a button rather than a dropdown as this |
| 65 |
# allows us to have a nicer UI and to keep compatible with the old engine bindings |
| 66 |
t = table.getChild("button", i, 1); |
| 67 |
t.getNode("name", 1).setValue("axis" ~ i ~ "binding"); |
| 68 |
t.getNode("row", 1).setValue(i + 1); |
| 69 |
t.getNode("col", 1).setValue("2"); |
| 70 |
t.getNode("halign", 1).setValue("fill"); |
| 71 |
t.getNode("pref-width", 1).setValue("150"); |
| 72 |
t.getNode("live", 1).setValue(1); |
| 73 |
t.getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding"); |
| 74 |
t.getNode("legend", 1).setValue(getprop(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding")); |
| 75 |
|
| 76 |
var b = t.getChild("binding", 0, 1); |
| 77 |
b.getNode("command", 1).setValue("property-assign"); |
| 78 |
b.getNode("property", 1).setValue("/sim/gui/dialogs/joystick-config/current-axis"); |
| 79 |
b.getNode("value", 1).setValue(i); |
| 80 |
|
| 81 |
b = t.getChild("binding", 1, 1); |
| 82 |
b.getNode("command", 1).setValue("dialog-show"); |
| 83 |
b.getNode("dialog-name", 1).setValue("button-axis-config"); |
| 84 |
|
| 85 |
# Inverted |
| 86 |
t = table.getChild("checkbox", i, 1); |
| 87 |
t.getNode("name", 1).setValue("axis" ~ i ~ "inverted"); |
| 88 |
t.getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/inverted"); |
| 89 |
t.getNode("row", 1).setValue(i +1 ); |
| 90 |
t.getNode("col", 1).setValue(3); |
| 91 |
t.getNode("visible", 1).getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/invertable"); |
| 92 |
t.getNode("live", 1).setValue(1); |
| 93 |
|
| 94 |
var b = t.getChild("binding", 0, 1); |
| 95 |
b.getNode("command", 1).setValue("dialog-apply"); |
| 96 |
b.getNode("object-name", 1).setValue("axis" ~ i ~ "inverted"); |
| 97 |
|
| 98 |
b = t.getChild("binding", 1, 1); |
| 99 |
b.getNode("command", 1).setValue("nasal"); |
| 100 |
b.getNode("script", 1).setValue("updateConfig();"); |
| 101 |
} |
| 102 |
|
| 103 |
# Set up the buttons. |
| 104 |
table = gui.findElementByName(dlgRoot, "buttontable"); |
| 105 |
table.removeChildren("checkbox"); |
| 106 |
table.removeChildren("button"); |
| 107 |
var row = 1; |
| 108 |
var col = 0; |
| 109 |
|
| 110 |
for (var button = 0; button < joystick.MAX_BUTTONS; button = button + 1) { |
| 111 |
|
| 112 |
t = table.getChild("checkbox", button, 1); |
| 113 |
t.getNode("property", 1).setValue("/devices/status/joysticks/joystick[" ~ joystick_index ~ "]/button[" ~ button ~ "]"); |
| 114 |
t.getNode("row", 1).setValue(row ); |
| 115 |
t.getNode("col", 1).setValue(col); |
| 116 |
t.getNode("live", 1).setValue(1); |
| 117 |
t.getNode("label", 1).setValue(button); |
| 118 |
|
| 119 |
t = table.getChild("button", button, 1); |
| 120 |
t.getNode("name", 1).setValue("button" ~ button); |
| 121 |
t.getNode("pref-width", 1).setValue(140); |
| 122 |
t.getNode("halign", 1).setValue("fill"); |
| 123 |
t.getNode("live", 1).setValue("fill"); |
| 124 |
t.getNode("row", 1).setValue(row ); |
| 125 |
t.getNode("col", 1).setValue(col +1); |
| 126 |
t.getNode("legend", 1).setValue(getprop(DIALOG_ROOT ~ "/button[" ~ button ~ "]/binding")); |
| 127 |
|
| 128 |
var b = t.getChild("binding", 0, 1); |
| 129 |
b.getNode("command", 1).setValue("property-assign"); |
| 130 |
b.getNode("property", 1).setValue("/sim/gui/dialogs/joystick-config/current-button"); |
| 131 |
b.getNode("value", 1).setValue(button); |
| 132 |
|
| 133 |
b = t.getChild("binding", 1, 1); |
| 134 |
b.getNode("command", 1).setValue("dialog-show"); |
| 135 |
b.getNode("dialog-name", 1).setValue("button-config"); |
| 136 |
|
| 137 |
col = col + 2; |
| 138 |
|
| 139 |
if (col > 5) { |
| 140 |
row = row +1; |
| 141 |
col = 0; |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
var updateConfig = func() { |
| 147 |
joystick.writeConfig(); |
| 148 |
fgcommand("reinit", props.Node.new({"subsystem": "input"})); |
| 149 |
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"})); |
| 150 |
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"})); |
| 151 |
} |
| 152 |
]]></open> |
| 153 |
|
| 154 |
<close><![CDATA[ |
| 155 |
]]></close> |
| 156 |
</nasal> |
| 157 |
|
| 158 |
|
| 159 |
<name>joystick-config</name> |
| 160 |
<layout>vbox</layout> |
| 161 |
<resizable>true</resizable> |
| 162 |
<default-padding>3</default-padding> |
| 163 |
|
| 164 |
<group> |
| 165 |
<layout>hbox</layout> |
| 166 |
<default-padding>1</default-padding> |
| 167 |
|
| 168 |
<text> |
| 169 |
<label>Joystick Configuration</label> |
| 170 |
</text> |
| 171 |
|
| 172 |
<empty><stretch>true</stretch></empty> |
| 173 |
|
| 174 |
<button> |
| 175 |
<legend>X</legend> |
| 176 |
<key>Esc</key> |
| 177 |
<pref-width>20</pref-width> |
| 178 |
<pref-height>20</pref-height> |
| 179 |
<binding> |
| 180 |
<command>dialog-close</command> |
| 181 |
</binding> |
| 182 |
</button> |
| 183 |
</group> |
| 184 |
|
| 185 |
<hrule/> |
| 186 |
|
| 187 |
<text> |
| 188 |
<halign>left</halign> |
| 189 |
<label> To configure your joystick/yoke/pedals:</label> |
| 190 |
</text> |
| 191 |
|
| 192 |
<text> |
| 193 |
<halign>left</halign> |
| 194 |
<label> 1) Select the device your wish to configure from the drop-down.</label> |
| 195 |
</text> |
| 196 |
|
| 197 |
<text> |
| 198 |
<halign>left</halign> |
| 199 |
<label> 2) Identify the control you wish to configure by moving the joystick or pressing the button. The result is shown in the Input column.</label> |
| 200 |
</text> |
| 201 |
|
| 202 |
<text> |
| 203 |
<halign>left</halign> |
| 204 |
<label> 3) Using the drop-down or dialog button, select what you want the control to do. "Custom" indicates a manually configured command.</label> |
| 205 |
</text> |
| 206 |
|
| 207 |
<text> |
| 208 |
<halign>left</halign> |
| 209 |
<label> Your selection will take effect immediately.</label> |
| 210 |
</text> |
| 211 |
|
| 212 |
<text> |
| 213 |
<halign>left</halign> |
| 214 |
<label> 4) Test your control. Some joystick controls can be "inverted" if you wish the control to take effect in the opposite direction.</label> |
| 215 |
</text> |
| 216 |
|
| 217 |
<text> |
| 218 |
<halign>left</halign> |
| 219 |
<label> Your modified joystick configuration is saved automatically. You can reset the configuration to the default by pressing Reset Configuration. </label> |
| 220 |
</text> |
| 221 |
|
| 222 |
<hrule/> |
| 223 |
|
| 224 |
|
| 225 |
<group> |
| 226 |
<layout>table</layout> |
| 227 |
<halign>left</halign> |
| 228 |
|
| 229 |
<text> |
| 230 |
<row>0</row> |
| 231 |
<col>0</col> |
| 232 |
<halign>right</halign> |
| 233 |
<label>Joystick:</label> |
| 234 |
</text> |
| 235 |
|
| 236 |
<combo> |
| 237 |
<name>jsselect</name> |
| 238 |
<row>0</row> |
| 239 |
<col>1</col> |
| 240 |
<halign>left</halign> |
| 241 |
<property>/sim/gui/dialogs/joystick-config/selected-joystick</property> |
| 242 |
<pref-width>350</pref-width> |
| 243 |
<binding> |
| 244 |
<command>dialog-apply</command> |
| 245 |
<object-name>jsselect</object-name> |
| 246 |
</binding> |
| 247 |
<binding> |
| 248 |
<command>nasal</command> |
| 249 |
<script> |
| 250 |
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"})); |
| 251 |
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"})); |
| 252 |
</script> |
| 253 |
</binding> |
| 254 |
</combo> |
| 255 |
|
| 256 |
<button> |
| 257 |
<row>0</row> |
| 258 |
<col>2</col> |
| 259 |
<halign>center</halign> |
| 260 |
<legend>Reset Configuration</legend> |
| 261 |
<binding> |
| 262 |
<command>nasal</command> |
| 263 |
<script> |
| 264 |
joystick.resetConfig(); |
| 265 |
fgcommand("reinit", props.Node.new({"subsystem": "input"})); |
| 266 |
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"})); |
| 267 |
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"})); |
| 268 |
</script> |
| 269 |
</binding> |
| 270 |
</button> |
| 271 |
|
| 272 |
<button> |
| 273 |
<row>0</row> |
| 274 |
<col>3</col> |
| 275 |
<halign>center</halign> |
| 276 |
<legend>Refresh Joysticks</legend> |
| 277 |
<binding> |
| 278 |
<command>nasal</command> |
| 279 |
<script> |
| 280 |
fgcommand("reinit", props.Node.new({"subsystem": "input"})); |
| 281 |
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"})); |
| 282 |
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"})); |
| 283 |
</script> |
| 284 |
</binding> |
| 285 |
</button> |
| 286 |
|
| 287 |
|
| 288 |
<text> |
| 289 |
<row>1</row> |
| 290 |
<col>0</col> |
| 291 |
<halign>right</halign> |
| 292 |
<label> Configuration File:</label> |
| 293 |
</text> |
| 294 |
|
| 295 |
<text> |
| 296 |
<row>1</row> |
| 297 |
<col>1</col> |
| 298 |
<colspan>3</colspan> |
| 299 |
<halign>left</halign> |
| 300 |
<label>Joystick Confgig</label> |
| 301 |
<property>/sim/gui/dialogs/joystick-config/selected-joystick-config</property> |
| 302 |
</text> |
| 303 |
|
| 304 |
</group> |
| 305 |
|
| 306 |
|
| 307 |
<hrule/> |
| 308 |
|
| 309 |
<group> |
| 310 |
<layout>hbox</layout> |
| 311 |
<valign>top</valign> |
| 312 |
<halign>fill</halign> |
| 313 |
|
| 314 |
|
| 315 |
<group> |
| 316 |
<layout>table</layout> |
| 317 |
<valign>top</valign> |
| 318 |
<name>axistable</name> |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
<text> |
| 323 |
<row>0</row> |
| 324 |
<col>0</col> |
| 325 |
<label>Axis</label> |
| 326 |
</text> |
| 327 |
|
| 328 |
<text> |
| 329 |
<row>0</row> |
| 330 |
<col>1</col> |
| 331 |
<label>Input</label> |
| 332 |
</text> |
| 333 |
|
| 334 |
<text> |
| 335 |
<row>0</row> |
| 336 |
<col>2</col> |
| 337 |
<label>Control</label> |
| 338 |
</text> |
| 339 |
|
| 340 |
<text> |
| 341 |
<row>0</row> |
| 342 |
<col>3</col> |
| 343 |
<label>Invert Axis</label> |
| 344 |
</text> |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
</group> |
| 350 |
|
| 351 |
<vrule/> |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
<group> |
| 356 |
<layout>table</layout> |
| 357 |
<valign>top</valign> |
| 358 |
<name>buttontable</name> |
| 359 |
|
| 360 |
|
| 361 |
<text> |
| 362 |
<row>0</row><col>0</col> |
| 363 |
<label>Input</label> |
| 364 |
</text> |
| 365 |
|
| 366 |
<text> |
| 367 |
<row>0</row><col>1</col> |
| 368 |
<label>Control</label> |
| 369 |
</text> |
| 370 |
|
| 371 |
<text> |
| 372 |
<row>0</row><col>2</col> |
| 373 |
<label>Input</label> |
| 374 |
</text> |
| 375 |
|
| 376 |
<text> |
| 377 |
<row>0</row><col>3</col> |
| 378 |
<label>Control</label> |
| 379 |
</text> |
| 380 |
|
| 381 |
<text> |
| 382 |
<row>0</row><col>4</col> |
| 383 |
<label>Input</label> |
| 384 |
</text> |
| 385 |
|
| 386 |
<text> |
| 387 |
<row>0</row><col>5</col> |
| 388 |
<label>Control</label> |
| 389 |
</text> |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
</group> |
| 394 |
</group> |
| 395 |
|
| 396 |
<hrule/> |
| 397 |
|
| 398 |
<group> |
| 399 |
<layout>table</layout> |
| 400 |
<default-padding>2</default-padding> |
| 401 |
|
| 402 |
<empty> |
| 403 |
<width>150</width> |
| 404 |
<col>0</col> |
| 405 |
<row>0</row> |
| 406 |
</empty> |
| 407 |
|
| 408 |
<text> |
| 409 |
<label>Aileron: </label> |
| 410 |
<halign>right</halign> |
| 411 |
<col>1</col> |
| 412 |
<row>0</row> |
| 413 |
</text> |
| 414 |
|
| 415 |
<text> |
| 416 |
<label>-0.00000</label> |
| 417 |
<halign>left</halign> |
| 418 |
<format>%.5f</format> |
| 419 |
<property>/controls/flight/aileron</property> |
| 420 |
<live>1</live> |
| 421 |
<col>2</col> |
| 422 |
<row>0</row> |
| 423 |
</text> |
| 424 |
|
| 425 |
<text> |
| 426 |
<label>Elevator: </label> |
| 427 |
<halign>right</halign> |
| 428 |
<col>1</col> |
| 429 |
<row>1</row> |
| 430 |
</text> |
| 431 |
|
| 432 |
<text> |
| 433 |
<label>-0.00000</label> |
| 434 |
<halign>left</halign> |
| 435 |
<format>%.5f</format> |
| 436 |
<property>/controls/flight/elevator</property> |
| 437 |
<live>1</live> |
| 438 |
<col>2</col> |
| 439 |
<row>1</row> |
| 440 |
</text> |
| 441 |
|
| 442 |
<text> |
| 443 |
<label>Rudder: </label> |
| 444 |
<halign>right</halign> |
| 445 |
<col>3</col> |
| 446 |
<row>0</row> |
| 447 |
</text> |
| 448 |
|
| 449 |
<text> |
| 450 |
<label>-0.00000</label> |
| 451 |
<halign>left</halign> |
| 452 |
<format>%.5f</format> |
| 453 |
<property>/controls/flight/rudder</property> |
| 454 |
<live>1</live> |
| 455 |
<col>4</col> |
| 456 |
<row>0</row> |
| 457 |
</text> |
| 458 |
|
| 459 |
<text> |
| 460 |
<label>Throttle: </label> |
| 461 |
<halign>right</halign> |
| 462 |
<col>3</col> |
| 463 |
<row>1</row> |
| 464 |
</text> |
| 465 |
|
| 466 |
<text> |
| 467 |
<label>-0.00000</label> |
| 468 |
<halign>left</halign> |
| 469 |
<format>%.5f</format> |
| 470 |
<property>/controls/engines/engine/throttle</property> |
| 471 |
<live>1</live> |
| 472 |
<col>4</col> |
| 473 |
<row>1</row> |
| 474 |
</text> |
| 475 |
|
| 476 |
<empty> |
| 477 |
<width>150</width> |
| 478 |
<col>5</col> |
| 479 |
<row>0</row> |
| 480 |
</empty> |
| 481 |
</group> |
| 482 |
|
| 483 |
<hrule/> |
| 484 |
|
| 485 |
|
| 486 |
<group> |
| 487 |
<layout>hbox</layout> |
| 488 |
|
| 489 |
<empty> |
| 490 |
<stretch>true</stretch> |
| 491 |
</empty> |
| 492 |
|
| 493 |
<button> |
| 494 |
<legend>Close</legend> |
| 495 |
<binding> |
| 496 |
<command>dialog-close</command> |
| 497 |
</binding> |
| 498 |
</button> |
| 499 |
|
| 500 |
<empty> |
| 501 |
<stretch>true</stretch> |
| 502 |
</empty> |
| 503 |
</group> |
| 504 |
|
| 505 |
</PropertyList> |