WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
313 stars 46 forks source link

FloatVariable does not allow negative values #365

Closed edwardwbarber closed 3 years ago

edwardwbarber commented 3 years ago

The Joystick Gremlin GUI does not seem to allow negative values to be entered for FloatVariable. Nor are they allowed for as default values:

testfloat = FloatVariable(
    "Test float",
    "Test float",
    -0.1,
    -1.0,
    1.0
)

Output of above defaults to 0.0. Expected -0.1. Attempts to enter -0.1 manually into GUI widget are reset to 0.0.

Looks like QtWidgets.QDoubleSpinBox.Maximum and QtWidgets.QDoubleSpinBox.Minimum aren't assigned to the limits given in FloatVariable. Seems like this could be fixed by inserting the following after line 345 in gremlin/user_plugin.py (haven't been able to create a 32-bit python 3.4 env to build JoystickGremlin or I would test it myself...):

value_widget.setMaximum(float(self.max_value))
value_widget.setMinimum(float(self.min_value))

This might also avoid some of the confusion raised in #359. As it is the GUI lets a user enter up to 99.99 as a float, only to be ignored under the hood :)

Cheers, -Edward

WhiteMagic commented 3 years ago

Fixed with 37ba776.