Picade Hat Utility button reassignment

Ive been at it for a week now, but I just dont have enough experience with this stuff. My goal is a handheld Retropie with same buttons as playstation controller minus L3 and R3 and analogs. Utility buttons I need ENT as Start, ESC as Select/Coin, 1/4 as L2, and 1UP as R2. Id keep 26 and 13 as volume which I like.
Is this possible? Emulationstation lets me config this way, but Mame, the Coin (ive been using ESC) just freezes the game and I have to selectstart to exit game. When I try to config in Retroarch, it wont allow the ESC to be reconfigured. Is there a simple way around this? Im definitely missin something haha!

You could try rebinding all the keycodes in the input driver /usr/bin/picadehatd, or just swapping out ESC for something you can reconfigure:

Is that in a file on the sd card? I dont know how to get to that. Could you please walk me through it?

Might be worth taking a copy first, to be on the safe side:

in Terminal;

cp /usr/bin/picadehathd ~/picadehatd-backup

Then

sudo nano /usr/bin/picadehatd

Tweak as necessary - the available KEY_SOMETHING are listed here: https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

Then Ctrl+X, Y and Enter to save.

Thanks a bunch! Very helpful!