playMaker

Author Topic: getting controller names  (Read 1807 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
getting controller names
« on: October 10, 2019, 03:22:54 PM »
Hi, I am attempting to use the get joystick name.

I only have a Logitech Dual Action

so gettings its correct spelling was easy

"Logitech Dual Action"

But how are the other joysticks named?

is an Xbox controller named "Xbox"

is a PlayStation controller named "Playstation Dual Shock"

If you would kindly help with the correct naming profiles many thanks

 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: getting controller names
« Reply #1 on: October 11, 2019, 02:12:14 AM »
Hi,

in control has that:

https://github.com/pbhogan/InControl/tree/master/Assets/InControl/Source/Unity/DeviceProfiles

check the content of the scripts they feature the names of the devices.

Bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: getting controller names
« Reply #2 on: October 11, 2019, 04:12:43 AM »
Thanks Jean.

I am trying to use your custom get custom name.

Its the one with the joystick int index.

Does index 0 = keyboard ?

I have three possible controllers so if I do an int compare I will get each value, then based on the value do I need to do a string compare.

How do I know what order the possible controllers will be?

Currently, there is only one possible string to place the value into.

"store the joystick name found at that index"

Thanks for that in control someone should try fixing that :)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: getting controller names
« Reply #3 on: October 11, 2019, 08:43:12 AM »
please see attachment as I am not sure if this setup will work.

I have three get next joystick name actions each one under each other with each one storing the found joystick into a separate variable.

with each one having the same finishing event "keyboard control"

Each having a different LOOP event.

The loop event moves to a string compare Logitech controller to an empty string value.

equal event = keyboard control

not equal event = activate logitech controls.

Use this setup to test for PlayStation and Xbox controllers.

As I do not have another controller I'm unable to test will the next joystick name actions actually fire.







colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: getting controller names
« Reply #4 on: October 11, 2019, 01:15:43 PM »
updated FSM.

This should work now.

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: getting controller names
« Reply #5 on: October 11, 2019, 07:22:32 PM »
No matter what I do when building to HTML I always start with keyboard controls.

Everything works in unity however, what's going on?

I am trying and failing to implement a simple check controller in use if none use keyboard controls.

This is working inside of unity but not in HTML why?

 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: getting controller names
« Reply #6 on: October 14, 2019, 02:11:59 AM »
Hi,

https://docs.unity3d.com/Manual/webgl-input.html

 it says:

Quote
Note that browsers may only allow access to available input devices once the user has interacted with the device while the content has focus. This is a security measure to prevent using the connected devices for browser fingerprinting purposes. For this reason, you should make sure to instruct the user to click a button on their devices before checking Input.GetJoystickNames()) for connected devices.

can you double check on this?

Bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: getting controller names
« Reply #7 on: October 23, 2019, 03:58:51 AM »
Note that browsers may only allow access to available input devices once the user has interacted with the device while the content has focus.

I seem to have found a glitch, play test this:

https://simmer.io/@colpolstudios/controller-tester

If you move the right or left stick the Axis are shown.

However, now thinking I have interacted with the controller and I am not getting the controller names.

But a very interesting note is that the Axis for the right stick in a HTML file is the same despite which controller is in use:

Logitech dual action controller, PlayStation dual action and Xbox are all showing the same Axis for the right stick.

HTML:

up + down = Axis 5

Left + right = Axis 4


I also noted some issues when using a controller in HTML and inside the unity editor

Logitech dual action controller:

Unity editor:

up + down = Axis 4

Left + right = Axis 3

D-pad:

up + down = Axis 6

Left + right = Axis 5

HTML:

up + down = Axis 5

Left + right = Axis 4

D-pad:

up + down = Axis 7

Left + right = Axis 6

Special note:

When pressed right on the D-pad button 15 shows as active.

When pressed left on the D-pad button 14 shows as active.

When pressed up on the D-pad button 12 shows as active.

When pressed down on the D-pad button 13 shows as active.

This is only the case in the HTML and does not show inside unity.

It would be helpful if the community could help, by downloading the controller tester and noting the changes of other controllers.