From 8e434f2bc04331ad697892080e6520d6de6d6140 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 9 Sep 2023 11:09:05 +0200 Subject: [PATCH] examples: modify consumers of joystick.NewAdaptor() to pass joystick ID as is now required Signed-off-by: deadprogram --- examples/ardrone_ps3.go | 2 +- examples/bebop_ps3.go | 2 +- examples/bebop_ps3_video.go | 2 +- examples/joystick_ps3.go | 26 +++++++++++++++++++- examples/joystick_ps4.go | 2 +- examples/joystick_ps5.go | 2 +- examples/joystick_xbox360.go | 2 +- examples/joystick_xbox360_rock_band_drums.go | 2 +- examples/joystick_xboxone.go | 2 +- examples/minidrone_mambo_ps3.go | 2 +- examples/minidrone_ps3.go | 2 +- examples/tello_facetracker.go | 2 +- examples/tello_ps3.go | 2 +- 13 files changed, 37 insertions(+), 13 deletions(-) diff --git a/examples/ardrone_ps3.go b/examples/ardrone_ps3.go index d7aad83e0..c21b84352 100644 --- a/examples/ardrone_ps3.go +++ b/examples/ardrone_ps3.go @@ -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() diff --git a/examples/bebop_ps3.go b/examples/bebop_ps3.go index 93b514348..7b33ffa91 100644 --- a/examples/bebop_ps3.go +++ b/examples/bebop_ps3.go @@ -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() diff --git a/examples/bebop_ps3_video.go b/examples/bebop_ps3_video.go index 74b38b672..7e57e7169 100644 --- a/examples/bebop_ps3_video.go +++ b/examples/bebop_ps3_video.go @@ -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() diff --git a/examples/joystick_ps3.go b/examples/joystick_ps3.go index 2cdb55bc4..762f79b2b 100644 --- a/examples/joystick_ps3.go +++ b/examples/joystick_ps3.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock3) work := func() { @@ -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{}) { @@ -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", diff --git a/examples/joystick_ps4.go b/examples/joystick_ps4.go index 046c7bd0a..91b1c3a99 100644 --- a/examples/joystick_ps4.go +++ b/examples/joystick_ps4.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) stick := joystick.NewDriver(joystickAdaptor, joystick.Dualshock4) work := func() { diff --git a/examples/joystick_ps5.go b/examples/joystick_ps5.go index fe8d1063b..0de5af6ee 100644 --- a/examples/joystick_ps5.go +++ b/examples/joystick_ps5.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) stick := joystick.NewDriver(joystickAdaptor, joystick.Dualsense) work := func() { diff --git a/examples/joystick_xbox360.go b/examples/joystick_xbox360.go index 655cb3889..dd8dee5b9 100644 --- a/examples/joystick_xbox360.go +++ b/examples/joystick_xbox360.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360) work := func() { diff --git a/examples/joystick_xbox360_rock_band_drums.go b/examples/joystick_xbox360_rock_band_drums.go index a83c6993b..b892eb0ae 100644 --- a/examples/joystick_xbox360_rock_band_drums.go +++ b/examples/joystick_xbox360_rock_band_drums.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) stick := joystick.NewDriver(joystickAdaptor, joystick.Xbox360RockBandDrums) work := func() { diff --git a/examples/joystick_xboxone.go b/examples/joystick_xboxone.go index d29737c90..df079993b 100644 --- a/examples/joystick_xboxone.go +++ b/examples/joystick_xboxone.go @@ -14,7 +14,7 @@ import ( ) func main() { - joystickAdaptor := joystick.NewAdaptor() + joystickAdaptor := joystick.NewAdaptor(0) joystick := joystick.NewDriver(joystickAdaptor, joystick.XboxOne) work := func() { diff --git a/examples/minidrone_mambo_ps3.go b/examples/minidrone_mambo_ps3.go index d38e4af6a..2dd581c32 100644 --- a/examples/minidrone_mambo_ps3.go +++ b/examples/minidrone_mambo_ps3.go @@ -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", ) diff --git a/examples/minidrone_ps3.go b/examples/minidrone_ps3.go index a09959ec9..8717b723c 100644 --- a/examples/minidrone_ps3.go +++ b/examples/minidrone_ps3.go @@ -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]) diff --git a/examples/tello_facetracker.go b/examples/tello_facetracker.go index 1a65dfd65..676e9445f 100644 --- a/examples/tello_facetracker.go +++ b/examples/tello_facetracker.go @@ -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 ) diff --git a/examples/tello_ps3.go b/examples/tello_ps3.go index 5d4f998d0..e1d9a71cc 100644 --- a/examples/tello_ps3.go +++ b/examples/tello_ps3.go @@ -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")