Hmmm okay I understand. There might well be a dedicated program for this, but I'm also sure it's technically possible, just maybe far from trivial.
A bit of searching turned up this, I haven't tried it myself but it claims to offer the functionality you want: https://sourceforge.net/projects/linuxjoymap/