Retrieve gamepad number

Get help using Construct 2

Post » Sat Sep 07, 2013 7:30 pm

Is there a expression to retrieve a specific gamepad's gamepad number?

When the player presses start on the controller, I want to assign the gamepad number to a variable.
B
51
S
13
G
8
Posts: 194
Reputation: 7,316

Post » Sat Sep 07, 2013 7:32 pm

At first it's a gamepad, but then it's a console controller 0_o
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,377

Post » Sat Sep 07, 2013 7:37 pm

Yeah, I use the terms interchangeably. I've always called them controllers, but I've had to switch with C2's "gamepad"
B
51
S
13
G
8
Posts: 194
Reputation: 7,316

Post » Sat Sep 07, 2013 8:06 pm

NOt that I know of. As it is gamepad have to be explicitly polled for information rather than triggered.

Personally I feel the gamepad should be

On gpad Left
-- if gpad = 0 then do player 1 stuff


as it is now
On gpad 0 Left
-- do player 1 stuff


this is really annoying as it requires duplicating all the controller events. This can be easily done by putting all controller events into a single group say "Player 1".

Then copy/paste Player 1 to new versions. then go through each event and reference controller index 0 to 1, and repeat for every controller :(


alternativly you can do what I did.
Repeat 4 Times
-- Is gpad loopindex Left then Function.Call("Pad.Left", loopindex)
-- Is gpad loopoinex A Then Function.Call("Pad.A", loopindex)

I do a little more than that to handle Press, Release and analog state. but that's the jist of handling X number of controllers with the same code base.

The disadvantage is that the controller is constantly polled every tick rather triggering on an input event :(
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Sat Sep 07, 2013 8:17 pm

Thanks jayderyu. I'm surprised there isn't a gamepad number expression. It would really simplify things and prevent redundant code

:On Gamepad Start pressed:
> create object Spite
> Set Sprite variable "gamePadNum" to gamepad.number

which would allow you do do some many things easily

:ForEach Sprite
::Gamepad(Sprite.gamePadNum) Button "A" is down
>>Sprite Spawn Another Object "Bullet"


B
51
S
13
G
8
Posts: 194
Reputation: 7,316

Post » Sat Sep 07, 2013 8:23 pm

It's a little late to change my code now, but I wonder if it might be done with functions to do away with redundancy.

Still, if you have 3 gamepads connected with numbers 00,01,02 and gamepad 01 is unplugged, a lot of "Repeat GamePad.GamepadCount times" conditions will break. I'm not sure if gamepad numbers are reassigned when a gamepad's USB is yanked out.

Anywho, I'll let you know if I find anything. Maybe someone else has an idea and will chime in as well!
B
51
S
13
G
8
Posts: 194
Reputation: 7,316

Post » Tue Nov 05, 2013 1:45 am

I have a problem with dual gamepad configuration.
I've used the single gamepad and works fine, but when I add more event for dual gamepad, The Game won't detect any user input.
I'm using this kind of gamepad.
http://image.en.09635.com/2012-8/11/USB-Dual-Shock-Twin-Gamepad-STK-8032-426.jpg

can anybody help me fix this?.

more detail :
http://www.scirra.com/forum/topic79041_post468244.html
B
11
S
2
G
2
Posts: 62
Reputation: 2,153

Post » Tue Nov 12, 2013 3:22 pm

Hi Dazky
You're problem is unique to ours; if you want any help, I'd recommend starting your own thread instead of changing the topic of this one.
B
51
S
13
G
8
Posts: 194
Reputation: 7,316


Return to How do I....?

Who is online

Users browsing this forum: farsen and 26 guests