How do I Get String From Gamepad Button Index?

Get help using Construct 2

Post » Thu Aug 25, 2016 5:58 am

This is a short one and I might just have missed this feature.
I'm currently working an a custom controls menu and I would like to display a gamepad button as a string. (e.g. 0 = A | 1 = B ...)

I know that the keyboard plugin has an expression called "StringFromKeyCode", I would like to do something like that with a gamepad button index.
If it doesn't exist, I would like to suggest adding an expression called "StringFromButtonIndex" to the gamepad plugin.
ImageImageImage
B
63
S
23
G
78
Posts: 664
Reputation: 44,941

Post » Thu Aug 25, 2016 8:43 am

Do it manually. On button pressed, set a variable to the character you prefer.

The keyboard has that expression because it already has a string mapped to every key...
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Thu Aug 25, 2016 1:47 pm

Use Gamepad.LastButton to check what was the last button pressed.
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Thu Aug 25, 2016 3:37 pm

oosyrag wrote:Do it manually. On button pressed, set a variable to the character you prefer.

What does that mean, could you please provide me a screenshot or something?


andreyin wrote:Use Gamepad.LastButton to check what was the last button pressed.

"Gamepad.LastButton" returns a number and not the string of a button.
ImageImageImage
B
63
S
23
G
78
Posts: 664
Reputation: 44,941

Post » Thu Aug 25, 2016 4:25 pm

https://www.dropbox.com/s/nwyvxrfb0mg4q ... p.PNG?dl=0

You set the string returned from each button manually yourself, it is not defined anywhere.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Thu Aug 25, 2016 5:16 pm

oosyrag wrote:https://www.dropbox.com/s/nwyvxrfb0mg4q8u/gamepadmap.PNG?dl=0
You set the string returned from each button manually yourself, it is not defined anywhere.

I guess that is a valid workaround.
Well, I think I will optimize it a little further and add it to my project.

Thanks oosyrag
ImageImageImage
B
63
S
23
G
78
Posts: 664
Reputation: 44,941


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests