How to intelligently poll the XBOX 360 Gamepad clicks in the browser?
A question about controlling the movements of objects on a page in the browser along the x-y axes using the sticks and buttons of the XBOX 360 controller.
I tried polling for keystrokes using the setTimeout timer, with different frequencies (from 50 to 200 ms),
and if we managed to achieve optimal control for the sticks, then with the same polling rate, the arrow buttons buttons [12-15] generate events with a higher frequency - I just can't control the controls normally - they always fly past the point at which I released the press.
In short, I don't understand how it turns out that with the same polling rate in the browser, a response comes from different buttons from the gamepad with different frequency. In the case of buttons [12-15], it seems that there heralion fires events once a second.
If you set the timer frequency in the browser to a lower one, it turns out that control of the stop is better, but the start of the movement is worse - you just don't always get into the polling frequency, and the press is not read.
Do you need to select the polling rate for each button separately, or is it somehow fixed in a different way?
To place the code, please use CodePen or similar tool. Thanks you!