Creating macros for mame?

Are there any programs that will allow me to record an input I do with my xbox ctrl or hori EX2 if i plug it in to my pc and then assign that to a button and replay that motion or whatever I just did?

I know a program out there called pinnacle game profiler can do this but it’s a very limited capacity and you can’t actually put the input in yourself.

Just want to mess around with it for some games thanks