From 261400d3259160d34b0036058c05738c8e108f6f Mon Sep 17 00:00:00 2001 From: Ron Evans <ron@hybridgroup.com> Date: Sat, 25 Aug 2018 18:02:01 +0200 Subject: [PATCH] joystick: provide constant values for existing joystick configurations Signed-off-by: Ron Evans <ron@hybridgroup.com> --- examples/joystick_ps3.go | 2 +- examples/joystick_ps4.go | 2 +- examples/joystick_xbox360.go | 2 +- examples/joystick_xbox360_rock_band_drums.go | 2 +- platforms/joystick/joystick_driver.go | 17 +++++++++++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/examples/joystick_ps3.go b/examples/joystick_ps3.go index 56946e9fe..1d61119a4 100644 --- a/examples/joystick_ps3.go +++ b/examples/joystick_ps3.go @@ -13,7 +13,7 @@ import ( func main() { joystickAdaptor := joystick.NewAdaptor() - stick := joystick.NewDriver(joystickAdaptor, "dualshock3") + stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock3) work := func() { // buttons diff --git a/examples/joystick_ps4.go b/examples/joystick_ps4.go index 34dfebc1d..aaaad2e98 100644 --- a/examples/joystick_ps4.go +++ b/examples/joystick_ps4.go @@ -13,7 +13,7 @@ import ( func main() { joystickAdaptor := joystick.NewAdaptor() - stick := joystick.NewDriver(joystickAdaptor, "dualshock4") + stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock4) work := func() { stick.On(joystick.SquarePress, func(data interface{}) { diff --git a/examples/joystick_xbox360.go b/examples/joystick_xbox360.go index bf94a90b5..9f61049f9 100644 --- a/examples/joystick_xbox360.go +++ b/examples/joystick_xbox360.go @@ -13,7 +13,7 @@ import ( func main() { joystickAdaptor := joystick.NewAdaptor() - stick := joystick.NewDriver(joystickAdaptor, "xbox360") + stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360) work := func() { stick.On(joystick.APress, func(data interface{}) { diff --git a/examples/joystick_xbox360_rock_band_drums.go b/examples/joystick_xbox360_rock_band_drums.go index 9f75e92e3..1e52bfa6a 100644 --- a/examples/joystick_xbox360_rock_band_drums.go +++ b/examples/joystick_xbox360_rock_band_drums.go @@ -13,7 +13,7 @@ import ( func main() { joystickAdaptor := joystick.NewAdaptor() - stick := joystick.NewDriver(joystickAdaptor, "xbox360RockBandDrums") + stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360RockBandDrums) work := func() { stick.On(joystick.RedPress, func(data interface{}) { diff --git a/platforms/joystick/joystick_driver.go b/platforms/joystick/joystick_driver.go index 0a8481ce7..8d08f743c 100644 --- a/platforms/joystick/joystick_driver.go +++ b/platforms/joystick/joystick_driver.go @@ -10,6 +10,23 @@ import ( "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 type Driver struct { name string