Skip to content

Commit

Permalink
joystick: provide constant values for existing joystick configurations
Browse files Browse the repository at this point in the history
Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed Aug 25, 2018
1 parent c098cac commit 261400d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/joystick_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func main() {
joystickAdaptor := joystick.NewAdaptor()
stick := joystick.NewDriver(joystickAdaptor, "dualshock3")
stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock3)

work := func() {
// buttons
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_ps4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_xbox360.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_xbox360_rock_band_drums.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
Expand Down
17 changes: 17 additions & 0 deletions platforms/joystick/joystick_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 261400d

Please sign in to comment.