@SinisterSpatula That's great indeed and I'm glad I could help. I can't wait to see the next iteration you produce.

The advanced mapping method with case statement really works well if you have a lot of code. My arcade machine's runcommand-onstart.sh has about 4,300 lines of code for 4 arcade joysticks, a PS4 wireless controller and an 8BitDo Zero covering about 60 systems. I also use it for all of the libretro cores too now. It doesn't miss a beat, so I reckon you're going down the right path.

Going back to my GPi vice code, with a bit more testing I'm finding that it's definitely not working for every game, so I reckon your newly produced code will be more successful than mine in "universalising" the controls for the c64. Please feel free to experiment with my code of course and make any changes you think are best.