So far I was having hard time figuring out certain things. I.e. why lightgun_device should be set to keyboard instead of the mouse, etc. Guess I shouldn't try to fix it if it works.
If you enable devices with eg 'lightgun 1', 'mouse 1' etc., then you do not need to set the 'lightgun_device' etc options.
In short, these options are the 'old' way of doing it:
mouse 0
joystick 0
lightgun 0
Setting 'mouse 1' would enable mouse, all the time, for all games.
This is the preferred 'new' method:
paddle_device joystick
adstick_device joystick
pedal_device joystick
dial_device mouse
trackball_device mouse
lightgun_device mouse
positional_device mouse
mouse_device mouse
The 'new' method, automatically enables said device for games which require it. eg (using my example above), Mame would enable joysticks for any game with a pedal.
Although the new system is preferred, there are a few flaws. Sometimes it is just easier to use the old method. One example is that if you want to use a joystick device for a digital input, you can't without using 'joystick 1'.