How do I create a rebindable controller system?

Get help using Construct 2

Post » Sat Jan 31, 2015 1:32 pm

Image
This code sets individual bits in an array, at positions corresponding to gamepad button index, to 1/0 when the button is pressed/released respectively. But the problem is that when multiple buttons are pressed at the same time or in quick succession, certain bits will become stuck at 1. I'm guessing that this is because gamepad.LastButton is changed when the next button is pressed, so if one button is pressed while another is released, then one of the bits won't update.
Image
As you can see, my attempts to resolve the problem have only become more convoluted and more broken as time goes on.

Can anybody think of a solution to this problem?

( Here's the .capx, if you'd rather look at it that way: https://www.dropbox.com/s/lonh0dkzd9ugq ... .capx?dl=1 )
B
7
S
3
G
2
Posts: 10
Reputation: 1,820

Post » Sat Jan 31, 2015 5:41 pm

@Virtualistik
I'm not sure why you had the set bit code in your input array. As soon as I took it off it seemed to work. Here check out my reworked example. The only thing I could see you having a problem with is trying to rebind the analog sticks. I'm not sure how that would be done. I'ld have to think about it. But I don't know if that's something you wanted.
In the example click one of the Control buttons in the ui that you want to bind than click a button on your gamepad to bind it.

What you would do is preload the array with the default bindings.
You do not have the required permissions to view the files attached to this post.
B
33
S
8
G
2
Posts: 100
Reputation: 2,635

Post » Sun Feb 01, 2015 11:24 am

Thanks man. I dunno why I was so obsessed with the idea of setting each controller button to be represented by a single bit in a number. Your way works a lot better.
B
7
S
3
G
2
Posts: 10
Reputation: 1,820


Return to How do I....?

Who is online

Users browsing this forum: matriax and 10 guests