Axis with value on Virtual Joystick and Fixing SDL Joystick issues #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Virtual Joystick
First, I have modified the Virtual Joystick operation. Now its axes have "continuous" values (between -32767 and 32767) and three states:
INCREASE
,STILL
andDECREASE
.How does that work?
Take for instance the axes
AXIS_AD
. When the user press the A key, the state of the axis will change toDECREASE
. Then, when the user release the key, the state will return toSTILL
. The same way, when the user press the D key, the state of this axis will change toINCREASE
.Then I connected a Timer to update all the axes each 10ms. So depending on the status of the axis, its value will still, increase or decrease. If the axis is on
INCREASE
orDECREASE
state, its values will be summed or subtracted by the variablem_axisStep
. That way, it is possible to control the sensitivity of the axes. I create a function to do that on a scale from 0 to 1, so you will just need to callQJoysticks::getInstance()->setVirtualJoystickAxisSensibility(0.5);
to change the sensitivity to 0.5.I made the key 0 a special key that reset all axes.
SDL Joystick
I was getting
ASSERT failure in QList<T>::operator[]: "index out of range",
error when I pressed any button on the Joystick (the same as in here. Looking into, I figured out that it was because those lines (here and here) added on some recently commit. Removing then should fix the problem and it did, but then I was not able to see the changes when running JoystickList and the program crashed on the destructor. So I reverted that commit and tried to fix the memory leak issue and others that I have found on the issues area.Now everything seems to be working fine and the issues #6 and #9 are probably solved.