Improved handling of binding buttons and axes (cherry picked from commit 71f3bf90edce26083056215124e65881f6c6ad26)