GPIO based Joystick controller

Post Reply
User avatar
tobetter
Posts: 6619
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 328 times
Been thanked: 921 times
Contact:

GPIO based Joystick controller

Post by tobetter »

I originally wrote a driver to support the parallel port on the GPIO headers, but...eventually I encountered a problem that I cannot have a hardware that has the parallel port for testing. Even the used dot-printer is expensive. :( So..I turned out to use the driver to support gpio-based joystick controllers and have three patches for this. These patches are based on the Hardkernel's 4.9 kernel and tested with RetroArena. Please note that these patches are not applied to any official emulator yet.
[1] https://github.com/tobetter/linux/commi ... 8dd276ece9
[2] https://github.com/tobetter/linux/commi ... 3aaeddcf62
[3] https://github.com/tobetter/linux/commi ... 3d4d885f1c
[4] https://github.com/tobetter/linux/commi ... e7dc7545d9
[5] https://github.com/tobetter/linux/commi ... 4e2d285753

After applying these patches, Linux kernel image must be updated as well as kernel modules. Also the device tree must be updated but this part would be very depends on the OS. Hardkernel's Linux kernel switched to support device tree overlay, so the patch [2] will work with it. Otherwise the patch [2] must be integrated to the original device tree file.

With the Hardkernel's Linux kernel tree to use the device tree overlay, config.ini should be modified like this in order to enable GPIOs to connect with the the switches.

Code: Select all

; Device Tree Overlay
overlay_resize=16384
overlay_profile=joysticks
overlays="spi0 i2c0 i2c1 uart0"

[overlay_custom]
overlays="i2c0 i2c1"

[overlay_hktft32]
overlays="hktft32"

[overlay_hktft35]
overlays="hktft35"

[overlay_joysticks]
overlays="gpio-joystick0 gpio-joystick1"
Also boot.init must be updated, so...add this to the end of the line of bootargs. This change will enable to the driver gamecon and map the GPIO pins to emulate the joystick controller.

Code: Select all

gamecon.map=0,10 gamecon.map2=1,10
Once everything is applied properly, two joystick will appear after rebooting. /dev/input/js0 and /dev/input/js1 are the devices for GPIO based joystick controllers.

Code: Select all

# ls -l /dev/input/
total 0
drwxr-xr-x  2 root root      80 Jan 28  2018 by-id
drwxr-xr-x  2 root root      80 Jan 28  2018 by-path
crw-rw----  1 root input 13, 64 Jan 28  2018 event0
crw-rw----  1 root input 13, 65 Jan 28  2018 event1
crw-rw----  1 root input 13, 66 Jan 28  2018 event2
crw-rw----+ 1 root input 13, 67 Nov  1 08:29 event3
crw-rw----+ 1 root input 13, 68 Nov  1 08:29 event4
crw-rw----+ 1 root input 13,  0 Nov  1 08:29 js0
crw-rw----+ 1 root input 13,  1 Nov  1 08:29 js1
crw-rw----  1 root input 13, 63 Jan 28  2018 mice
For GPIO pins wiring, we have very limited number pins to use for two joystick controllers. The controller is assumed to have 12 inputs, LEFT/RIGHT/UP/DOWN/A/B/X/Y/TL/TR. Here is the map how the switches can be wired to GPIO pin header and how it's different with the RPi. Disadantage of having two joysticks is that only one GPIO pinpad remans. :(
GPIO-based-joystick-pinmap.png
GPIO-based-joystick-pinmap.png (136.34 KiB) Viewed 356 times
These users thanked the author tobetter for the post (total 4):
odroid (Mon Nov 02, 2020 9:34 am) • superpowter77 (Mon Nov 02, 2020 10:57 am) • shanti (Wed Nov 04, 2020 6:33 pm) • ponz (Tue Nov 17, 2020 4:10 am)

User avatar
tobetter
Posts: 6619
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 328 times
Been thanked: 921 times
Contact:

Re: GPIO based Joystick controller

Post by tobetter »

Good new!!

EmuELEC 4.0 (test release) has been released about 7 hours ago and gratefully the patch to enable GPIO based joystick controller are merged. Thanks to @shanti for accepting the patch and release it with 4.0. Intresting thing is that EmuELEC has released the new version for ODROID-HC4 as well.
https://github.com/EmuELEC/EmuELEC-test ... /v4.0-test

I also upload the video how to set up the EmuELEC to enable GPIO based joystick which is boring... :D Please skip the video to here if you are familiar to set up EmuELEC and only to know what to change on EmuELEC image.


Thank you again, @shanti!!
These users thanked the author tobetter for the post (total 3):
ponz (Tue Nov 17, 2020 4:10 am) • lsc1117 (Tue Nov 17, 2020 12:23 pm) • odroid (Tue Nov 17, 2020 2:35 pm)

Post Reply

Return to “Games and Emulators”

Who is online

Users browsing this forum: No registered users and 2 guests