package main import ( "conjure-os/lib/inputs" "conjure-os/lib/models" "conjure-os/lib/provider" "context" "fmt" "os" "os/exec" "time" "github.com/wailsapp/wails/v2/pkg/runtime" ) var ( games []models.Metadata lastEmitTimestamp = time.Now().Add(-10 * time.Second) emitInterval = 150 * time.Millisecond gameIsOpen = false ) // App struct type App struct { ctx context.Context } // NewApp creates a new App application struct func NewApp() *App { return &App{} } // Startup is called when the app starts. The context is saved // so we can call the runtime methods func (a *App) Startup(ctx context.Context) { a.ctx = ctx inputs.Start(a.onControllerChange) provider.Update() } func (a *App) onControllerChange(state inputs.ControllerState) { now := time.Now() if now.Sub(lastEmitTimestamp) >= emitInterval && !gameIsOpen { if state.Buttons != 0 { for _, button := range inputs.ConjureControllerButtons { if state.Buttons&(1<