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.
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 )