Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis with value on Virtual Joystick and Fixing SDL Joystick issues #11

Merged
merged 13 commits into from
Sep 7, 2020

Conversation

Bollos00
Copy link
Contributor

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 and DECREASE.

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 to DECREASE. Then, when the user release the key, the state will return to STILL. The same way, when the user press the D key, the state of this axis will change to INCREASE.

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 or DECREASE state, its values will be summed or subtracted by the variable m_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 call
QJoysticks::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.

@alex-spataru
Copy link
Owner

Thanks, merging

@alex-spataru alex-spataru merged commit b2e83a2 into alex-spataru:master Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants