Skip to content

Commit

Permalink
examples: modify consumers of joystick.NewAdaptor() to pass joystick …
Browse files Browse the repository at this point in the history
…ID as is now required

Signed-off-by: deadprogram <ron@hybridgroup.com>
  • Loading branch information
deadprogram committed Sep 9, 2023
1 parent 603fe26 commit 8e434f2
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/ardrone_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var leftX, leftY, rightX, rightY atomic.Value
const offset = 32767.0

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

ardroneAdaptor := ardrone.NewAdaptor()
Expand Down
2 changes: 1 addition & 1 deletion examples/bebop_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var leftX, leftY, rightX, rightY atomic.Value
const offset = 32767.0

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

bebopAdaptor := bebop.NewAdaptor()
Expand Down
2 changes: 1 addition & 1 deletion examples/bebop_ps3_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func ffmpeg() (stdin io.WriteCloser, stderr io.ReadCloser, err error) {
}

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

bebopAdaptor := bebop.NewAdaptor()
Expand Down
26 changes: 25 additions & 1 deletion examples/joystick_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

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

work := func() {
Expand Down Expand Up @@ -64,15 +64,27 @@ func main() {
stick.On(joystick.RightPress, func(data interface{}) {
fmt.Println("right_press")
})
stick.On(joystick.RightRelease, func(data interface{}) {
fmt.Println("right_release")
})
stick.On(joystick.LeftPress, func(data interface{}) {
fmt.Println("left_press")
})
stick.On(joystick.LeftRelease, func(data interface{}) {
fmt.Println("left_release")
})
stick.On(joystick.UpPress, func(data interface{}) {
fmt.Println("up_press")
})
stick.On(joystick.UpRelease, func(data interface{}) {
fmt.Println("up_release")
})
stick.On(joystick.DownPress, func(data interface{}) {
fmt.Println("down_press")
})
stick.On(joystick.DownRelease, func(data interface{}) {
fmt.Println("down_release")
})

// joysticks
stick.On(joystick.LeftX, func(data interface{}) {
Expand All @@ -92,15 +104,27 @@ func main() {
stick.On(joystick.R1Press, func(data interface{}) {
fmt.Println("R1Press", data)
})
stick.On(joystick.R1Release, func(data interface{}) {
fmt.Println("R1Release", data)
})
stick.On(joystick.R2Press, func(data interface{}) {
fmt.Println("R2Press", data)
})
stick.On(joystick.R2Release, func(data interface{}) {
fmt.Println("R2Release", data)
})
stick.On(joystick.L1Press, func(data interface{}) {
fmt.Println("L1Press", data)
})
stick.On(joystick.L1Release, func(data interface{}) {
fmt.Println("L1Release", data)
})
stick.On(joystick.L2Press, func(data interface{}) {
fmt.Println("L2Press", data)
})
stick.On(joystick.L2Release, func(data interface{}) {
fmt.Println("L2Release", data)
})
}

robot := gobot.NewRobot("joystickBot",
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_ps4.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock4)

work := func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_ps5.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
stick := joystick.NewDriver(joystickAdaptor, joystick.Dualsense)

work := func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_xbox360.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360)

work := func() {
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 @@ -14,7 +14,7 @@ import (
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360RockBandDrums)

work := func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick_xboxone.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
joystick := joystick.NewDriver(joystickAdaptor, joystick.XboxOne)

work := func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/minidrone_mambo_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var leftX, leftY, rightX, rightY atomic.Value
const offset = 32767.0

func main() {
joystickAdaptor := joystick.NewAdaptor()
joystickAdaptor := joystick.NewAdaptor(0)
stick := joystick.NewDriver(joystickAdaptor,
"./platforms/joystick/configs/dualshock3.json",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/minidrone_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var leftX, leftY, rightX, rightY atomic.Value
const offset = 32767.0

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

droneAdaptor := ble.NewClientAdaptor(os.Args[1])
Expand Down
2 changes: 1 addition & 1 deletion examples/tello_facetracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var (
flightData *tello.FlightData

// joystick
joyAdaptor = joystick.NewAdaptor()
joyAdaptor = joystick.NewAdaptor(0)
stick = joystick.NewDriver(joyAdaptor, "dualshock4")
leftX, leftY, rightX, rightY atomic.Value
)
Expand Down
2 changes: 1 addition & 1 deletion examples/tello_ps3.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var leftX, leftY, rightX, rightY atomic.Value
const offset = 32767.0

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

drone := tello.NewDriver("8888")
Expand Down

0 comments on commit 8e434f2

Please sign in to comment.