package gamepad var Driver ControllerDriver = nil func Install(out chan<-Event) { Driver = InstallDriver(out) } func Uninstall() { if (Driver != nil) { Driver.Exit() Driver = nil } } func IsInstalled() bool { return Driver != nil } func Recofigure() bool { if Driver == nil { return false } return Driver.Reconfigure() } func Source() Driver { return Driver } func emitEvent(event Event) { Driver.Emit(event) } func NumberOfControllers() int { if Driver == nil { return 0 } return Driver.NumberOfControllers() } type Controller interface { Release() error Active() bool Name() string NumberOfAxes() int NumberOfButtons() int Flags() int } func ControllerById(id int) Controller { if Driver == nil { return nil } if id < 0 || id >= NumberOfControllers() { return nil } return Driver.ControllerById() }