@mitu OK I figured it out. Fist i got into Stargate on RetroPie and re-assigned the game controls to different keys using Tab. "Input, this game". F is fire, T is thrust, H is hyperspace, 1 is player1 start, 2 is player2 start, S is smart bomb, I is inviso, R is reverse, arrow up is UP, arrow down is DOWN. This makes my head easier to remember. Then I went back into EmStation, disconnected the USB gamepad and reconfigured the keyboard as main controller. I set key 1 as Start and key 2 as Select. I also set key T as B and key F as A. Down at the bottom of the configure menu I left hotkey blank and when asked, I selected Yes. I also went into RetroArch/Settings/Input/Hotkey Binds and made sure Press Quit Twice is set to OFF. So to exit the game now I press 1 and 2 together and it brings me back to EmStation. And when the Pi is in the cabinet (hooked up to iPac2), I can work through the EmStation using the Stargate control buttons and never need a keyboard or gamepad again.
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first