Author Topic: Get User Input (Joystick Button) multiple options  (Read 308 times)

Krittol

  • Newbie
  • *
  • Posts: 16
Get User Input (Joystick Button) multiple options
« on: July 04, 2024, 08:11:49 PM »
Hi, I am trying to write a command that pauses and waits for the user to press a button on the joystick. The user will have to press 1 of 2 buttons, with button 1 doing command X and button 2 doing command Y. I have read the documentation, but I am not sure that the "individual buttons" option is my right course of action here. Thanks for any help.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: Get User Input (Joystick Button) multiple options
« Reply #1 on: July 04, 2024, 08:41:08 PM »
Hi, Krittol

You will want to look at the 'Wait for Joystick Button Press' action (Other > Advanced > Get User Input > Wait for Joystick Button Press) and select the 'Continue on any button press' option.  From there, you will need to have a condition ('If' statement) that checks the value of the '~intButtonResult' variable.

I've uploaded a sample profile with one command that you can look at if none of that makes sense.  Just import the single command into your profile - note that it has a timeout of 15 seconds.

Hope that helps!

Krittol

  • Newbie
  • *
  • Posts: 16
Re: Get User Input (Joystick Button) multiple options
« Reply #2 on: July 04, 2024, 10:11:27 PM »
Hi, Gary. Thanks for this, but wouldnt the "wait for any button" command mean that pressing any button on a joystick end the command? I may be still using other buttons on a joystick while this command waits to be executed. I only want it to respond to the 2 buttons I program.

I tried something I thought was similar while I waited for your initial response:

***
Wait for joystick button press [variable button press ([J3B37][J3B15])]
Begin Device State Check: Joystick 3 Button 37 Is Pressed
     Press Tab key and hold for 0.1 seconds and release
     Press NumPad 9 key and hold for 0.1 seconds and release
Else If Device State Check: Joystick 3 Button 15 Is Pressed
     Press K key and hold for 0.1 seconds and release
End Condition
***

When I initiate the command I get the message:
"Wait for joystick button press by variable [[J3B37][J3B15]] not set. Unable to wait for joystick button press. Exiting command"

I hope this helps in determining what I am trying to achieve.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Get User Input (Joystick Button) multiple options
« Reply #3 on: July 05, 2024, 12:49:29 AM »
As the name and error message imply, and the tooltip and other documentation specify, the "Use variable joystick button press (Advanced)" requires a variable.

Use the "Set a Text Value" action to set a variable, then input the name of that variable into the "Use variable joystick button press (Advanced)" option's field (the default is "~textVariableButtons").