The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hello, I have some troubles with some joypad methods in the Input class.
Here is a snippet of my code :

if Input.get_connected_joypads().size() == 0:
   print("mouse/keyboard")
else:
   print("Input.get_joy_name(0)")

Whether the gamepad is plugged in or not, Input.get_connected_joypads() always return a array with, at least, one element: vJoy Device
Does anyone know what is this device and/or how to disable it ?

Thank you in advance
PS : I ran my code on a laptop maybe it's the trackpad ?

Godot version 3.3.4
in Engine by (81 points)

1 Answer

+1 vote

It's probably a virtual joystick device provided by the OS or some driver/software on you device. Could be the trackpad. There can be any number of other real or virtual joystick/joypad devices connected on peoples computers, so you shouldn't rely on the first of them being the one the player wants to use.

If you're making a single player game, the easiest way is to let any connected gamepad device be used. In case of multiple players, you should allow players to select their gamepad devices..

by (71 points)

Okay thank you for your advise.
Yes, it's a single player game. I think I will do something like that :

if Input.get_connected_joypads().size() == 0:
   print("mouse/keyboard")
elif Input.get_connected_joypads().size() == 1:
   var joy_name = Input.get_joy_name(0)
   if joy_name == "vJoy Device":
       print("mouse/keyboard")
   else:
       print(joy_name)
else:
   print(Input.get_joy_name(1))

Thank you again for your help!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.