// Start emulation func (deck *ControlDeck) Start() { if deck.ShowGui { leggo.LeggoMain(func() { deck.PPU.Run() }, // Handle keystrokes from GUI func (ch chan leggo.Event) { for { e := <-ch pressed := e.Type == leggo.EVENT_KEY_DOWN switch e.Type { case leggo.EVENT_KEY_DOWN, leggo.EVENT_KEY_UP: switch e.Keycode { case leggo.KEY_ESCAPE, leggo.KEY_Q: os.Exit(0) case leggo.KEY_F: fmt.Printf("display FPS = %f\n", leggo.FPS()) fmt.Printf("PPU FPS = %f\n", deck.PPU.FPS) // TODO: custom controller keyboard key mapping; refactor all this case leggo.KEY_ALT, leggo.KEY_ALTGR: deck.IO.SetButtonState(0, io2a03.BUTTON_A, pressed) case leggo.KEY_LSHIFT, leggo.KEY_RSHIFT: deck.IO.SetButtonState(0, io2a03.BUTTON_B, pressed) case leggo.KEY_TAB: deck.IO.SetButtonState(0, io2a03.BUTTON_SELECT, pressed) case leggo.KEY_ENTER: deck.IO.SetButtonState(0, io2a03.BUTTON_START, pressed) case leggo.KEY_LEFT: deck.IO.SetButtonState(0, io2a03.BUTTON_LEFT, pressed) case leggo.KEY_RIGHT: deck.IO.SetButtonState(0, io2a03.BUTTON_RIGHT, pressed) case leggo.KEY_UP: deck.IO.SetButtonState(0, io2a03.BUTTON_UP, pressed) case leggo.KEY_DOWN: deck.IO.SetButtonState(0, io2a03.BUTTON_DOWN, pressed) } } } }) } else { deck.PPU.Run() } }
func main() { // never returns leggo.LeggoMain(render, process) fmt.Printf("returned?!\n") }