Issue with joypad methods

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Roshi

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:

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 ?

:bust_in_silhouette: Reply From: fractile

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…

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:
elif Input.get_connected_joypads().size() == 1:
   var joy_name = Input.get_joy_name(0)
   if joy_name == "vJoy Device":

Thank you again for your help!

Roshi | 2021-11-04 10:55