1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/examples/joystick_xbox360_rock_band_drums.go
Ron Evans 261400d325 joystick: provide constant values for existing joystick configurations
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-08-25 18:02:01 +02:00

71 lines
1.7 KiB
Go

// +build example
//
// Do not build by default.
package main
import (
"fmt"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/joystick"
)
func main() {
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360RockBandDrums)
work := func() {
stick.On(joystick.RedPress, func(data interface{}) {
fmt.Println("red_press")
})
stick.On(joystick.RedRelease, func(data interface{}) {
fmt.Println("red_release")
})
stick.On(joystick.YellowPress, func(data interface{}) {
fmt.Println("yellow_press")
})
stick.On(joystick.YellowRelease, func(data interface{}) {
fmt.Println("yellow_release")
})
stick.On(joystick.BluePress, func(data interface{}) {
fmt.Println("blue_press")
})
stick.On(joystick.BlueRelease, func(data interface{}) {
fmt.Println("blue_release")
})
stick.On(joystick.GreenPress, func(data interface{}) {
fmt.Println("green_press")
})
stick.On(joystick.GreenRelease, func(data interface{}) {
fmt.Println("blue_release")
})
stick.On(joystick.PedalPress, func(data interface{}) {
fmt.Println("pedal_press")
})
stick.On(joystick.PedalRelease, func(data interface{}) {
fmt.Println("pedal_release")
})
stick.On(joystick.UpPress, func(data interface{}) {
fmt.Println("up", data)
})
stick.On(joystick.DownPress, func(data interface{}) {
fmt.Println("down", data)
})
stick.On(joystick.LeftPress, func(data interface{}) {
fmt.Println("left", data)
})
stick.On(joystick.RightPress, func(data interface{}) {
fmt.Println("right", data)
})
}
robot := gobot.NewRobot("joystickBot",
[]gobot.Connection{joystickAdaptor},
[]gobot.Device{stick},
work,
)
robot.Start()
}