playMaker

Author Topic: Joystick connected messages.  (Read 752 times)

Prestonh

  • Playmaker Newbie
  • *
  • Posts: 36
    • View Profile
Joystick connected messages.
« on: August 09, 2019, 09:28:18 PM »
Is there any solid way to get if ajoystick connects or disconnects?  The getnextjoystickname action, really doesnt do much.  And i have no idea how to querry unity engine.   But unity obviously has something, it debug logs every connect/disconnect

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15443
  • Official Playmaker Support
    • View Profile
Re: Joystick connected messages.
« Reply #1 on: August 12, 2019, 05:15:39 AM »
Hi,

 they all use indeed the list of joysticks to check out what's new and what's gone:

https://answers.unity.com/questions/1100642/joystick-runtime-plugunplug-detection.html


 so , maintain a list of joystick list and every nth seconds or less, just go over the list again and see if the name is in the list or not and fire a connection event if it's not, then do the opposite and see if there is a joystick that was cached but not in the new list, then fire a disconnect event.

let me know how it goes. It's a good exercice to work on for PlayMaker.

 Bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 269
    • View Profile
Re: Joystick connected messages.
« Reply #2 on: August 22, 2019, 05:54:30 PM »
Hi, take a look at my screenshot of a working fsm that will detect if the joystick is connected or not, and take action with the aid of a string compare.

With this, I was able to activate either mouse or joystick controls.

However, I required a different approach and implemented my own way.

It's untested with an xbox controller as I do not own one.

If you have one please try it out.

follow this post update: https://hutonggames.com/playmakerforum/index.php?topic=20919.0



« Last Edit: August 23, 2019, 07:15:19 PM by colpolstudios »

colpolstudios

  • Sr. Member
  • ****
  • Posts: 269
    • View Profile
Re: Joystick connected messages.
« Reply #3 on: September 02, 2019, 07:05:28 PM »
id really appreciate if someone could help show an example of how to use the getnextjoystickname action correctly.

Thanks, Jean for this info: https://answers.unity.com/questions/1100642/joystick-runtime-plugunplug-detection.html

However, I wish to only use playmaker to achieve a similar result.

At the game start.

Test if a joystick is connected.

I will need to be able to check for three types Logitech, Xbox and PlayStation.

Each specific controller sends different axis info to temp variables.

If no joystick connected then activate mouse controls, here I send mouse-specific axis info.

This info is only required at the game start, once the state is run it will deactivate its'self.

I think this way would be a much better way; than having the player select from the different icons on screen.


 



 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15443
  • Official Playmaker Support
    • View Profile
Re: Joystick connected messages.
« Reply #4 on: September 11, 2019, 06:47:16 AM »
Hi,

 actually... it's all on the ecosystem :)



Bye,

 Jean