====== Raspberry Pi NAS: Gamepad as Kodi remote ======
I have two SNES-Like gamepads, both are recognized by the Linux kernel Dragonrise module **hid_dr**. The older one is shipped with bot an **USB dongle** and a **Nintendo adapter**, the second one **has only the USB dongle**. In the picture the USB only model is the one with **colored keys**:
{{.:raspberrypi:gamepad-dragonrise-0079-0011.jpg?280|}}
{{.:raspberrypi:gamepad-dragonrise-0079-0126.jpg?280|}}
They are different models: the old model is identified by **lsusb** with this output line:
Bus 001 Device 010: ID 0079:0011 DragonRise Inc. Gamepad
The new model has a different ID:
Bus 002 Device 004: ID 0079:0126 DragonRise Inc.
To **pair** the gamepad with the USB receiver, first proceed by disconnecting the host USB dongle. Press the **Start**, **Select** and **Up** buttons simultaneously on the gamepad; the red LED starts flashing rapidly. During the next 10 seconds you have to insert the USB receiver into the host port, the pairing takes place automatically.
===== Configuring the gamepad in Kodi =====
You have to install the package
* **kodi-peripheral-joystick**
Other packages may be useful to debug and solve problems:
* **input-utils** - Contains the **lsinput** and **input-events** tools, used to view input events produced by the gamepad.
* **evtest** - Contains the **evtest** tool, used to monitor input events.
Install the **kodi-peripheral-joystick** package and restart **Kodi**, then go to **Settings** => **System settings** => **Input** => **Configure attached controller**. In this section you can choose the controller type: Kodi 17.6 has only the **generic** one, Kodi 18.7 has a **generic Kodi** and a specific **Super Nintento**.
Il is possible to configure each key, but default settings should be OK.
Custom configuration is saved into the directory **$HOME/.kodi/userdata/peripheral_data/**, in our case the file was named **addon_YSTEK_MICREAL_USB_Gamepad.xml**.
The gamepad goes to stand-by after some time of non-use. To wake it up it is necessary to press the **start** button; the red LED turns on and the gamepad is working.
===== Problem: non working left and right arrows =====
Everything is working correctly with a **Raspberry Pi 3**, using RaspiOS based on **Debian 9.11 Stretch** and **Kodi 17.6**. There is instead a problem with a **Raspberry Pi 4**, using RaspiOS based on **Debian 10.8** and **Kodi 18.7**: the **Left** and **Right** arrow keys do not work.
Someone had the same problem using Retropie: **[[https://retropie.org.uk/forum/topic/25657/controler-issue-no-left-and-right-not-working-at-all/| Controler Issue (no left and right not working at all)]]**.
==== Working kernel versions ====
^ System ^ Kernel ^ ABS_X Working ^
| Raspberry Pi 3 | 4.19.66-v7+ | Yes |
| Raspberry Pi 4 | 5.10.11-v7l+ | No |
| PC amd64 Debian 10.8 | 4.9.189-3+deb9u2 | Yes |
| PC amd64 Debian 10.8 | 4.19.67-2+deb10u2 | Yes |
| PC amd64 Debian 10.8 | 4.19.98-1+deb10u1 | No |
| PC amd64 Debian 10.8 | 4.19.160-2 | No |
===== Web References =====
* **[[https://www.retropie-italia.it/viewtopic.php?f=19&t=702|[GUIDA] DragonRise Inc. Generic USB Joystick]]**
* **[[https://retropie.org.uk/forum/topic/25657/controler-issue-no-left-and-right-not-working-at-all/|Controler Issue (no left and right not working at all)]]**