The best solution for Ubuntu 22.04 is to follow these steps:
- Install xboxdrv:
 
$ sudo apt-add-repository ppa:rael-gc/ubuntu-xboxdrv
$ sudo apt-get update
$ sudo apt-get install ubuntu-xboxdrv
- Add xpad in the blacklist:
 
$ echo "blacklist xpad" | sudo tee -a /etc/modprobe.d/blacklist.conf
$ sudo rmmod xpad         (Unload the module if it's already loaded)
- Remove 
jstest-gtk to set xboxdrv as default: 
$ sudo apt-get purge jstest-gtk
$ sudo apt-get install xboxdrv
$ sudo apt-get install jstest-gtk (Reinstalling it without affecting xboxdrv)
- In the directory 
/etc/default/, make a new file called "xboxdrv" with the following text in it: 
[xboxdrv]
silent = true
controller 1
trigger-as-button = true
dpad-as-button = true
deadzone = 4000
controller 2
next-controller = true
trigger-as-button = true
dpad-as-button = true
deadzone = 4000
controller 3
next-controller = true
trigger-as-button = true
dpad-as-button = true
deadzone = 4000
controller 4
next-controller = true
trigger-as-button = true
dpad-as-button = true
deadzone = 4000
[xboxdrv-daemon]
dbus = disabled
- To start 
xboxdrv every time when Ubuntu boots, follow the steps of systemctl in this website. It's not necessary to type in Terminal sudo xboxdrv --silent if it's running by systemctl. 
- Note: Print a list of supported devices:
 
$ xboxdrv --list-supported-devices
- If a controller have any problem in wine, follow this website.
 
More info:
https://youtu.be/JfcSMRooHLU
https://github.com/gotbletu/shownotes/blob/master/xboxdrv.md