123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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()
- }
|