Пример #1
0
func handleButtons(l *controller.Launchpad, nextBoards chan Board, quit chan bool) {
	for {
		select {
		case cc := <-l.OutPort().ControlChanges():
			if cc.Value == 0 {
				continue
			}
			switch cc.ID {
			case 108:
				quit <- true
				time.Sleep(250 * time.Millisecond) // Hack.
				if len(quit) > 0 {
					<-quit
				}
				nextBoards <- glider()
				go loop(l, nextBoards, quit)
			case 111:
				quit <- true // Stop the playback loop.
				programMode = true
			}
		case note := <-l.OutPort().NoteOns():
			switch note.Key {
			case 8:
				nextBoards <- glider()
			case 24:
				nextBoards <- spaceship()
			case 40:
				nextBoards <- queen()
			case 56:
				nextBoards <- phoenix()
			case 72:
				nextBoards <- queen()
			case 88:
				nextBoards <- infinity()
			}
		case note := <-l.OutPort().NoteOffs():
			l.ToggleLightColor(note.Key, ON_COLOR, OFF_COLOR)
		}
	}
}