[Request] - Gamepad ID expression

Discussion and feedback on Construct 2

Post » Thu Nov 06, 2014 10:39 pm

It would be awesome if there was an expression that would give you the ID number of the gamepad after pushing a button, so that we could easily tell which gamepad initiated that button press.

Thanks!
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Thu Nov 06, 2014 11:05 pm

I 100% percent agree with you. The way it is very annoying and counter intuitive.

Either
A. Create an Input for each controller
or
B. Iterate through each controller and check for state.

both are not the best way to handle input.

It would be a lot nicer to do
OnControllerButton A
--FunctionCall("FireAction", GamePad.ID)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Fri Nov 07, 2014 6:58 pm

@Ashley - would this be something easy to add plz?

thx
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Sat Nov 08, 2014 8:18 pm

Seconded. While I'm unsure the reason for which there are no unique gamepad IDs, it would be so nice to have the ability to have something built in.

It's not difficult to work around, though, like Jay noted above, but yeah, having to cycle through each gamepad is strange.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Fri Nov 14, 2014 3:33 pm

Firstly I think you are asking for a "LastGamepadIndex" expression? The gamepad ID is a string describing it, which doesn't sound especially useful to this case.

Secondly I don't see how it helps by itself: currently you have to always specify a gamepad index when using a trigger like 'On button pressed', so the expression would be redundant, it would always be the same as the number you already provided in the trigger. So are you in addition to that asking for new triggers which don't specify a gamepad index and provide it by an expression instead? That did not appear to be specifically outlined.

Thirdly the way conditions work, that could not really be extended to the non-trigger 'Is button down'. If you have 'Is button A down' that is true for any gamepad, then if two gamepads press A simultaneously, then the condition still runs its actions once with a LastGamepadIndex for just one of the gamepads, since that's just how the event system works. So we could extend new gamepad-neutral triggers, but not non-trigger conditions, which then makes a sort of weird inconsistency between what you can do without a gamepad index and what you can do with one.

This is why you should always describe feature requests in as much detail as possible, a bit like the approach with bug reports. The suggestion just raises more questions and has implications you probably didn't foresee.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684

Post » Fri Nov 14, 2014 3:46 pm

@Ashley - Thanks for the reply, I will try and explain in more detail.

When working with a local "couch co-op" type game with 4 players, it seems like the easiest solution right now to support setting up a reusable input system for all 4 players is to create a master group that listens for whatever button is being pressed, for all 4 inputs then passing it to another function that picks the related player and initiates that players attack etc.

For example:

On gamepad 0 button A pressed -> call function "Jump" ("0")

Function "Jump"
Pick by evaluate player = function.param(0) -> Jump

But this now means that you need create 4x the number of input checks * the number of buttons on the controller

So i was thinking perhaps if there was some way of being able to read which gamepad initiated the button press you could replace all of that with...

On Any gamepad button A pressed - Call function "Jump" ("Gamepad Number that initiated that input")

Function "Jump"
Pick player function.param(0) -> Jump

Thus only having the 16 events at the beginning setting up what every button on your controller does.

But there's also probably another awesome way of doing it that I've never though of.

How would you approach handling all inputs for a 4 player "couch co-op" type input system?

Thanks for all of your help!
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Fri Nov 14, 2014 4:27 pm

OK, so that sounds like what I assumed, but you realise that doesn't work with 'Is button down' for the reasons I described, right? So you'd still need to do those conditions over. But then I guess you can also check that in a loop, which you can't do with triggers.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684

Post » Fri Nov 14, 2014 8:28 pm

@Ashley
Yes. That would be fantastic middle solution

Trigger Button is down
--loop through all to find who is down THEN function.call with controller info



because right now it's
Loop through all controllers
-- check fro button A down
-- check for button b down
-- check for button c down
-- check for analog x
-- check for analog y
....


With the top version I'm not constantly having too loop through all possible controller input every tick. Now it only checks the whom on the input when an input occurs. I like this way much better.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Thu Nov 27, 2014 10:44 pm

@Ashley Any chance this will be in the next beta? The current way calls for A LOT of copy paste code with slight variations for each gamepad..
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Fri Nov 28, 2014 3:24 pm

@Jayderyu You mention being able to loop through the gamepads to retrieve the gamepad index when a button is pressed. Can you elaborate? I tried a for loop every tick with loopindex as the gamepad index but it didn't work. Maybe I missed something. Anyhow, I 'd definitely prefer to do this than have a set of input events for each gamepad...that will be a major pain in the ass with complex player mechanics.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests