package main import ( "fmt" "log" "os" "os/signal" "syscall" "github.com/hypebeast/go-osc/osc" ) func main() { // Setup and spawn the OSC server addr := "0.0.0.0:9137" d := osc.NewStandardDispatcher() // Screen bar handlers bar := NewScreenBar("DECRUNCH... Screen") d.AddMsgHandler("/party/bar/title/set", bar.setTitle) d.AddMsgHandler("/party/bar/t/reset", bar.reset) // Media player handlers player := NewMPV() d.AddMsgHandler("/party/media/play", player.play) d.AddMsgHandler("/party/media/stop", player.stop) d.AddMsgHandler("/party/media/volume", player.volume) // ATARI 800 XL emulator player handlers xl_emu := NewXLEmulator() d.AddMsgHandler("/party/emu/xl/play", xl_emu.play) d.AddMsgHandler("/party/emu/xl/stop", xl_emu.stop) d.AddMsgHandler("/party/emu/xl/volume", xl_emu.volume) // C64 handler c64 := C64{u1541_host: "http://192.168.7.64"} d.AddMsgHandler("/party/c64/reset", c64.reset) d.AddMsgHandler("/party/c64/reboot", c64.reboot) d.AddMsgHandler("/party/c64/run/sid", c64.sidplay) d.AddMsgHandler("/party/c64/run/prg", c64.runPRG) d.AddMsgHandler("/party/c64/drive/a/insert", c64.insertDisk) d.AddMsgHandler("/party/c64/send/keys", c64.sendKeys) // AMIGA 600 handler a600 := Amiga{host: "b600.local"} d.AddMsgHandler("/party/amiga/reset", a600.reset) d.AddMsgHandler("/party/amiga/drive/0/insert", a600.insertDisk) // AMIGA 1200/030 handler a1230 := Amiga{host: "b1200.local"} d.AddMsgHandler("/party/amiga/reset", a1230.reset) d.AddMsgHandler("/party/amiga/drive/0/insert", a1230.insertDisk) // Disable cursor, move it home and clear the terminal fmt.Print("[?25l") // Set up and start OSC server go func() { server := &osc.Server{Addr: addr, Dispatcher: d} if err := server.ListenAndServe(); err != nil { log.Fatal("error: ", err.Error()) } }() // Run until signals ch := make(chan os.Signal, 1) signal.Notify( ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, ) d.AddMsgHandler("/party/halt", func(msg *osc.Message) { ch <- syscall.SIGINT }) <-ch // Defered enable cursor (futile) fmt.Println("[?25h") }