[SOLVED] Gamepad // button released / depress button

Hi!

I have following situation:

  • There is one player-object that can be moved (top-down-movement) via gamepad AND keyboard controlls.
  • Also I have certain UI-Elements like inventory or equipment windows. If one is activated I can toggle through the specific splots (with the same buttons as my player-walking buttons).

Now here is my problem:

If I move my player-object (keep pressing a movement button) and activate my inventory (for example) at the same time I am moving, the active slot will also be changed for one time.
For example - If I walk right and then activate the inventory the second slot is selected.

I’ve tried some things but nothing has worked yet.
Probably it could be fixed if there was a “button released”-event for the gamepad available?

So is there a workaround for this or is it possible to extend the gamepad-addon somehow?

Hope you understand my problem (:

Here someone had a similar issue: https://forum.gdevelop.io/t/depress-mouse-keyboard-key-action/12799

Thanks in advance!

Hello there!
That’s an interesting problem I had when doing dialogue.
Anyway, what I used was a “key timer” variable - for a certain key that needs to avoid conflicts like this, I assign it a variable like “KTimer.Action1” for my key binded to F.
This variable will start at 0.
When the button is pressed, it will be at 1. When it is not being pressed, it will subtract by 1 (if more than 0).
Then, in your case, when opening/moving inventory, add a condition to check this keyTimer variable if it is 0 (not pressed).

PS: It can be set to more than 1 too, such as 15 for 15 frames, to avoid button mashing during some important segment like dialogue choice selection.

1 Like

Hey!

Thanks for the fast reply!! (: (:

I’ve tried it out but I can’t get it to work. Now the event does not trigger at all… I’ve attached a screenshot with my code - probably the order I’ve set the events is not right?

Gamepad button is ready for next release of my gamepad extension, but i need clean the code and finish some improvement. I’ll take a look tomorrow for finish this.

if you have others comments about gamepad extension i hope get your feedbacks :slight_smile:

1 Like

Nice progress! I assume taste_recths is your key timer.
You just need to add the “If key is NOT pressed, decrease timer by 1” - currently it is always 1 after you press it.

1 Like

Hi,

thanks for all your help!

@Bouh this sounds nice! I look foward to your extension update, probably it could fix that issue!

@reina, unfortunately I don’t get it to work… Do I need an additional event? The “key is not pressed - decrease timer by 1” -event I have in the third row - or do I miss something?
I’ve put the “timer”-variable in my debug-text-object and there it seems to work (when button pressed the variable is 1, when button not pressed it is 0).

I also suggest that probably the movement event does have problems to execute in combination with the condition of “timer”-Variable = 0, because in this case I keep pressing the key…?

Hey,

wow I’ve got it to work! Unfortunately I can’t tell you exactly what the solution was. It had something to do with the order the scripts were executed.

  • I removed the “timer”-variable condition from the player movement event
    and
  • put the “timer”-variable event to the end of the script:

(: (:

1 Like