I think I have it sorted, although I can’t test it here. I have pushed up a new branch
free5ty1e/rpi2/testing that should take care of this issue for your situation, where the controller ends up with trailing whitespace in the Name field.
Could you try building this branch (replace the branch name in the script I posted above) and seeing if your controller mapping woes are still present?
If this fixes the thing, I’ll add it to my multiplayer pull request / branch for all to use.
(You should only need the entry for your controller without spaces at the end, now… there was some trimming going on during the config section name parsing code, so it threw itself for a loop just as you described. I enforced trimming whitespace from all Names so that they should always match up in the logic.)
Hope this helps!! :D