@polygaryd
so to run this from emulationstation @mitu said to add XINIT: /opt/retropie/ports/dunelegacy/dunelegacy in the emulators.cfg file in /opt/retropie/configs/ports/dunelegacy folder and retropie's run command will handle xinit. So I removed xserver-xorg-legacy package and tested what he told me to do. It does in fact work, no need for sudo before the xinit command with his suggestion.

As a side note he actually told me to do this for glhexen2 which needs xinit but couldnt find the game data files if you run "sudo xinit". I used what he told me and applied it to dunelegacy.

There are two more issues, one I have overcome the other I need help with. The issue I overcame was that when you run dunelegacy it says it cant find the pak files to run the game and wants them either in the "data" folder or /home/pi/.configs/dunelegacy/data". So in the start script located in /home/pi/Retropie/roms/ports/dunelegacy.sh I added "cd /opt/retropie/ports/dunelegacy" before the runcommand line. This first puts you in the dunelegacy directory with the executable and the data folder it wants, then runs the runcommand to execute the dunelegacy executable. I wish I could have the data under /home/pi/RetroPie/roms/ports like every other game ran in emulationstation but I havent figured out how to do that yet if its even possible.

The issue I need help with is I have no keyboard in dune legacy, but the mouse works. The game works fine otherwise. I cannot figure out how to get the keyboard working.

Keyboard does work in glhexen2 using XINIT: string so it must be something wrong with dunelegacy??

Any help on this would be great.