Which is the worst way it can be done
Why?
See the rest of what i wrote, that's why

hence why controls.dat exists. You load dotron and it will "light" your tball. You load some games it will light 4 buttons instead of 3 like it is suppose to. Driver developers took some shortcuts and made some hacks that get represented when you ask mame for control info.
Right, I noticed this in I,Robot (two buttons light but only one is used). Why exactly does this happen in MAME? If it's just a matter of fixing a game's drivers, that's the way to go IMO.
Various reason. In case of dotron the trackball is an up/down spinner hack. In case of game where mame says 4 buttons but it used 2 is because the driver dev used a generic macro to map the buttons for all games in the driver. There are various other reasons.
I had a quick look at controls.dat recently, and as far as I can see, it tells you exactly what controls a game originally used, but it doesn't tell you how a particular user's control panel layout actually works or what hardware inputs he decides to map to a particular game's ports.
right, because controls.dat doesn;t need to store that info, it's all readily available. Hence you need something like the Johhny 5 viewer which combines controls.dat and your ctrlr files to accuratly display the labels and control per your configuration
For example, what if you have two track balls (for argument's sake)? Which one is mapped determines which one should light up. Or what if you've mapped a trackball to a lightgun game? You want the trackball to light up, not the gun. Then there's the hairy issue of people sharing encoder inputs between sticks/buttons etc.
Again, need something like Johhny5, then you'd have your ctrlr file mapped correctly for that game, it get's presented correctly for that game.
With respect to lights, what if you have an RGB light under a track, or several lights you want to animate in some way? What if you have lights all around it that show the direction of travel?
Controls.dat doesn't provide any of this info. It also doesn't make sense to add the light layout to controls.dat, because different light drivers will offer different lighting related options that can't all be accomodated in a generic layout format.
why would animated lights be part of controls.dat?
You are right, it doesn't make sense to put it in controls.dat, hence why I wrote my ideal solution...
So, the more ideal solution is to have a FE, when a game is highlighted or selected, read controls.dat and send LSE the right signals. Of if the game isn't in controls.dat then grab info form mame since something is usually better than nothing for this.
I support dynamic control lighting in the LSE - controls can light up when you press/activate them for example, and I'm trying to provide signals for each player's controls to light up when they're up. This has to happen from inside MAME, and I have to work off the game's input data somehow.
Why does it have to happen in mame? why can't it happen in an FE that supports controls.dat (and compares controls.dat with one's ctrlr files to get the correct key mappings). Or if the supprt was in the Johhny5 viewer (and use an FE like Mamewah that cna use the viewer).