There's a utility called JoyToKey, that emulates key-input from a joystick. You can download ver 3.7.9 from brothersoft, which I think is the latest version.
Works fine for me in Trainz with Windows XP using a simple game-pad, either in cab-mode or DCC. It has to run in the background and takes 1,2MB of memory according to taskmanager.
Use it on your own risk...