Action while holding Button
Forums:
Hy,
for the TB Joystick (tbJoystick.py) steering i have the problem when i press a button for e.g. slower, fasten or spinning, the movement continues after i release the button until i press a new button or move the joystick. But this is not what i want. I tried a lot but got no solution, i am also not high experienced with programming so i am very happy of help of you.
The program is almost in the initial state, i just added the lines with definition shown in picture
piborg
Sat, 11/09/2019 - 20:46
Permalink
Stop when button is released
I think it is fairly simple to fix :)
Towards the top of the loop there is a section which checks if the pygame event needs to be processed:
This section decides the event is of interest if it is caused by a joystick moving or a button being pressed.
What you need to do is also process events where a button is released as well. This means adding
JOYBUTTONUP
to this section like so:Once changed the script should recalculate the motor output when you let go of the button, causing it to stop as expected.
Canaoz
Sat, 11/23/2019 - 10:40
Permalink
Hy,
Hy,
a late response.
Yes, it was that easy.
Thank you guys.