controller.go 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package controller
  2. /*
  3. var Driver ControllerDriver = nil
  4. func Install(out chan<-Event) {
  5. Driver = InstallDriver(out)
  6. }
  7. func Uninstall() {
  8. if (Driver != nil) {
  9. Driver.Exit()
  10. Driver = nil
  11. }
  12. }
  13. func IsInstalled() bool {
  14. return Driver != nil
  15. }
  16. func Recofigure() bool {
  17. if Driver == nil {
  18. return false
  19. }
  20. return Driver.Reconfigure()
  21. }
  22. func Source() Driver {
  23. return Driver
  24. }
  25. func emitEvent(event Event) {
  26. Driver.Emit(event)
  27. }
  28. func NumberOfControllers() int {
  29. if Driver == nil {
  30. return 0
  31. }
  32. return Driver.NumberOfControllers()
  33. }
  34. type Controller interface {
  35. Release() error
  36. Active() bool
  37. Name() string
  38. NumberOfAxes() int
  39. NumberOfButtons() int
  40. Flags() int
  41. }
  42. func ControllerById(id int) Controller {
  43. if Driver == nil {
  44. return nil
  45. }
  46. if id < 0 || id >= NumberOfControllers() {
  47. return nil
  48. }
  49. return Driver.ControllerById()
  50. }
  51. */