From 3c4c15b6d998a5784242ef7b510692b9f89d8256 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Wed, 18 Apr 2018 12:12:07 +0200 Subject: [PATCH] joystick: correct events used by gamepad-style up/down/left/right buttons Signed-off-by: Ron Evans --- examples/joystick_ps3.go | 12 ++++++++++++ platforms/joystick/events.go | 24 ++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/examples/joystick_ps3.go b/examples/joystick_ps3.go index 3e506622e..49454d620 100644 --- a/examples/joystick_ps3.go +++ b/examples/joystick_ps3.go @@ -53,6 +53,18 @@ func main() { stick.On(joystick.SelectRelease, func(data interface{}) { fmt.Println("select_release") }) + stick.On(joystick.RightPress, func(data interface{}) { + fmt.Println("right_press") + }) + stick.On(joystick.LeftPress, func(data interface{}) { + fmt.Println("left_press") + }) + stick.On(joystick.UpPress, func(data interface{}) { + fmt.Println("up_press") + }) + stick.On(joystick.DownPress, func(data interface{}) { + fmt.Println("down_press") + }) // joysticks stick.On(joystick.LeftX, func(data interface{}) { diff --git a/platforms/joystick/events.go b/platforms/joystick/events.go index 066d28ad8..0170309ec 100644 --- a/platforms/joystick/events.go +++ b/platforms/joystick/events.go @@ -33,14 +33,22 @@ const ( R2Press = "r2_press" // R1 button release event R2Release = "r2_release" - // up gamepad event - Up = "up" - // down gamepad event - Down = "down" - // left gamepad event - Left = "left" - // right gamepad event - Right = "right" + // up gamepad press event + UpPress = "up_press" + // up gamepad release event + UpRelease = "up_release" + // down gamepad press event + DownPress = "down_press" + // down gamepad release event + DownRelease = "down_release" + // left gamepad press event + LeftPress = "left_press" + // left gamepad release event + LeftRelease = "left_release" + // right gamepad press event + RightPress = "right_press" + // right gamepad release event + RightRelease = "right_release" // square button press event SquarePress = "square_press" // square button release event