joystick: provide constant values for existing joystick configurations

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans 2018-08-25 18:02:01 +02:00
parent c098cacad0
commit 261400d325
5 changed files with 21 additions and 4 deletions

View File

@ -13,7 +13,7 @@ import (
func main() { func main() {
joystickAdaptor := joystick.NewAdaptor() joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "dualshock3") stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock3)
work := func() { work := func() {
// buttons // buttons

View File

@ -13,7 +13,7 @@ import (
func main() { func main() {
joystickAdaptor := joystick.NewAdaptor() joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "dualshock4") stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock4)
work := func() { work := func() {
stick.On(joystick.SquarePress, func(data interface{}) { stick.On(joystick.SquarePress, func(data interface{}) {

View File

@ -13,7 +13,7 @@ import (
func main() { func main() {
joystickAdaptor := joystick.NewAdaptor() joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "xbox360") stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360)
work := func() { work := func() {
stick.On(joystick.APress, func(data interface{}) { stick.On(joystick.APress, func(data interface{}) {

View File

@ -13,7 +13,7 @@ import (
func main() { func main() {
joystickAdaptor := joystick.NewAdaptor() joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "xbox360RockBandDrums") stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360RockBandDrums)
work := func() { work := func() {
stick.On(joystick.RedPress, func(data interface{}) { stick.On(joystick.RedPress, func(data interface{}) {

View File

@ -10,6 +10,23 @@ import (
"gobot.io/x/gobot" "gobot.io/x/gobot"
) )
const (
// Dualshock3 joystick configuration.
Dualshock3 = "dualshock3"
// Dualshock4 joystick configuration.
Dualshock4 = "dualshock4"
// TFlightHotasX flight stick configuration.
TFlightHotasX = "tflightHotasX"
// Xbox360 joystick configuration.
Xbox360 = "xbox360"
// Xbox360RockBandDrums controller configuration.
Xbox360RockBandDrums = "xbox360RockBandDrums"
)
// Driver represents a joystick // Driver represents a joystick
type Driver struct { type Driver struct {
name string name string