Fix nuking of property-scale's default factor by joystick-config dialog
As can be seen in do_property_scale()'s definition in flightgear/src/Main/fg_commands.cxx, property-scale rightfully uses a default factor of 1.0. However, if a joystick axis' property-scale binding has no 'factor' node defined, and one opens the joystick configuration dialog, then PropertyScaleAxis.parse() creates an empty 'factor' node that implicitely gets a value of 0. This method is called by joystick.readConfig() when the joystick-config dialog is opened. This has the effect of rendering the corresponding joystick axis inoperant. How to reproduce the bug: - take a joystick such as the SAITEK CYBORG 3D USB, with its default binding file from fgdata/Input/Joysticks/Saitek/Cyborg-Gold-3d-USB.xml (this file uses property-scale for the aileron, with no explicitely defined factor); - start FlightGear; move the joystick left or right while looking at the plane wings -> the ailerons move, it works fine; - now, open the joystick-config dialog and do the same test -> the ailerons don't move anymore and the 'Aileron' value at the bottom of the dialog stays at 0 (0.0 or -0.0...). Just opening the dialog to test the joystick has "corrupted" its setup! This is very confusing for users. This fix corrects the problem by avoiding the apparently unneeded creation of an empty 'factor' node when there is none inside the <binding>. An alternative would be to create a 'factor' node with value 1.0. In any case, if someone later expands the joystick-config dialog to allow modification of property-scale's factor, he should make sure to use a default value of 1.0!
This commit is contained in:
parent
d84168d36d
commit
5bcf58c7d6
1 changed files with 6 additions and 3 deletions
|
@ -130,9 +130,12 @@ var PropertyScaleAxis = {
|
|||
|
||||
parse: func(p) {
|
||||
me.deadband = p.getNode("binding", 1).getNode("dead-band", 1).getValue();
|
||||
if (p.getNode("binding", 1).getNode("factor", 1).getValue() != nil) {
|
||||
me.inverted = (p.getNode("binding", 1).getNode("factor", 1).getValue() < 0);
|
||||
}
|
||||
# Don't create a null 'factor' node if it doesn't exist!
|
||||
# (value 0 wouldn't be appropriate for a default factor)
|
||||
factorNode = p.getNode("binding", 1).getNode("factor", 0);
|
||||
if (factorNode != nil)
|
||||
me.inverted = (factorNode.getValue() < 0);
|
||||
|
||||
me.offset = p.getNode("binding", 1).getNode("offset", 1).getValue();
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue