Here's what I did. Note: this assumes you're using an I-PAC or J-PAC using the default mame assignment settings.
1) In the mame/ctrlr folder, make a new folder called Cabinet
2) copy std.ini from mame/ctrlr to mame/ctrlr/Cabinet
3) rename the new copy of std.ini to default.ini
4) modify the P2 button 5 & 6 lines in default.ini to look like this...
P2_BUTTON5 "KEYCODE_I | JOYCODE_2_BUTTON5"
P2_BUTTON6 "KEYCODE_K | JOYCODE_2_BUTTON6"
5) if you don't already have a mame.ini file in your mame folder, run...
"mame -createconfig" without the quotes to make one
6) in mame.ini, modify the "ctrlr" line under the "Input device options" section so it references your custom controller settings folder like this. Don't change any other lines!...
### Input device options ###
ctrlr Cabinet
7) create custom ini files for any games where you want the assignment different from the default.ini file. for example, this is my custom ini file for mortal kombat 3 (it works for UMK3 as well). Just cut out everything between the begin and end sections and past into a file named mk3.ini and save it in the mame/ctrlr/Cabinet folder...
-----------BEGIN mk3.ini--------------------------
# mk3.ini
#
# default button layout is:
# HP BK HK
# LP LK RN
#
# this file modifies it to:
# HP RN HK
# LP BK LK
P1_BUTTON2 "KEYCODE_Z | JOYCODE_1_BUTTON2 | MOUSECODE_1_BUTTON3"
P1_BUTTON5 "KEYCODE_X | JOYCODE_1_BUTTON5"
P1_BUTTON6 "KEYCODE_LALT | JOYCODE_1_BUTTON6"
P2_BUTTON2 "KEYCODE_I | JOYCODE_2_BUTTON2"
P2_BUTTON5 "KEYCODE_K | JOYCODE_2_BUTTON5"
P2_BUTTON6 "KEYCODE_S | JOYCODE_2_BUTTON6"
-----------END mk3.ini--------------------------
I hope this helps. I'm still figuring this out myself so I thought I would pass along what I know.
You can use this same file for MK1 and MK2, just save copies of it in the Cabinet folder named mk.ini and mk2.ini.
Note that this takes whatever button 6 does and assigns it to button 2. On MK1, the default button 6 seems to block but it won't work for a Sub-Zero slide. On MK2, it seems to block for split second and then release, even if you hold the button. I don't know what purpose that serves.
I think that eventually, I'll end up making the same assignment for buttons 2 and 5 in MK1 and MK2 so it just triggers the normal block button.
...
Krick