This might be close...might be perfect...if there's a problem let me know. There's a few things that could be tweaked yet.
include "target.tmh"
int MouseU, MouseD, MouseL, MouseR, MouseUO, MouseDO, MouseLO, MouseRO, flag1;
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
flag1=1;
MouseU = REXEC(0,10,"TrimDXAxis(MOUSE_Y_AXIS, -2);");
MouseD = REXEC(0,10,"TrimDXAxis(MOUSE_Y_AXIS, 2);");
MouseL = REXEC(1,10,"TrimDXAxis(MOUSE_X_AXIS, -2);");
MouseR = REXEC(1,10,"TrimDXAxis(MOUSE_X_AXIS, 2);");
MouseUO = CHAIN(EXEC("ActKey(MouseU);"),EXEC("TrimDXAxis(MOUSE_Y_AXIS,SET(0));"));
MouseDO = CHAIN(EXEC("ActKey(MouseD);"),EXEC("TrimDXAxis(MOUSE_Y_AXIS,SET(0));"));
MouseLO = CHAIN(EXEC("ActKey(MouseL);"),EXEC("TrimDXAxis(MOUSE_X_AXIS,SET(0));"));
MouseRO = CHAIN(EXEC("ActKey(MouseR);"),EXEC("TrimDXAxis(MOUSE_X_AXIS,SET(0));"));
MapKey(&Joystick, H1U, EXEC("if(flag1) ActKey(KEYON+MouseU); else ActKey(KEYON+DXHATUP);")); // starts it moving
MapKeyR(&Joystick,H1U, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseUO); else ActKey(DXHATUP);")); // stops moving
MapKey(&Joystick, H1D, EXEC("if(flag1) ActKey(KEYON+MouseD); else ActKey(KEYON+DXHATDOWN);")); // starts it moving
MapKeyR(&Joystick,H1D, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseDO); else ActKey(DXHATDOWN);")); // stops moving
MapKey(&Joystick, H1L, EXEC("if(flag1) ActKey(KEYON+MouseL); else ActKey(KEYON+DXHATLEFT);")); // starts it moving
MapKeyR(&Joystick,H1L, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseLO);else ActKey(DXHATLEFT);")); // stops moving
MapKey(&Joystick, H1R, EXEC("if(flag1) ActKey(KEYON+MouseR); else ActKey(KEYON+DXHATRIGHT);")); // starts it moving
MapKeyR(&Joystick,H1R, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseRO); else ActKey(DXHATRIGHT);")); // stops moving
MapKey(&Joystick, S3, EXEC("flag1=!flag1;"));
}
//event handler
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
//add event handling code here
}