Triacular
Posts: 5
Joined: Fri Aug 23, 2019 2:51 am

Can I get a joystick to work on my pi without Retropi?

Fri Sep 27, 2019 3:35 am

I'm thinking of getting an arcade stick kit from ebay and running a game I made using the stick & buttons set. I've been looking for ways to use the encoder for my game by setting it to keyboard inputs. I have not found a solution, so now I'm asking if there's a way to somehow use the control stick without changing my Pi's image.
I want to run it on a Python3 program. The encoder is really common with 2 player arcade control kits on ebay: https://www.ebay.ca/itm/2-Player-Americ ... 0005.m1851

User avatar
B.Goode
Posts: 8820
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Can I get a joystick to work on my pi without Retropi?

Fri Sep 27, 2019 7:56 am

{ Inappropriate reply removed. Fell into the trap of not reading all the linked information and missed the vital fact that these are usb, not analogue, devices. }
Last edited by B.Goode on Fri Sep 27, 2019 10:53 am, edited 1 time in total.

User avatar
procount
Posts: 1772
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Can I get a joystick to work on my pi without Retropi?

Fri Sep 27, 2019 8:35 am

Joysticks can have analog or digital inputs.
From the photos this arcade stick looks like it is purely digital using micro-switches.

There is a standard kernel joystick interface that covers these things.
See https://www.kernel.org/doc/html/latest/ ... _uapi.html especially sections 4,6 & 7.

As it has a USB interface you will probably find Linux will load appropriate drivers automatically.
If not you may have to add joydev and xpad drivers (using sudo modprobe etc.)
But then, using the above API references, you should be able to detect joystick events and even map them to keyboard keys if you so wish.
Or you may find some standard solutions in some of the popular python libraries: gpiozero, pygame etc.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
topguy
Posts: 5882
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Can I get a joystick to work on my pi without Retropi?

Fri Sep 27, 2019 10:50 am

Plug the device in after the Pi has booted, and then run the "dmesg" command and look at the last lines outputted.
It should indicate if the device has been detected as a keyboard or as a joystick.
You can also use the "evtest" program to test what events you get from the device.

Triacular
Posts: 5
Joined: Fri Aug 23, 2019 2:51 am

Re: Can I get a joystick to work on my pi without Retropi?

Sun Oct 06, 2019 6:01 pm

topguy wrote:
Fri Sep 27, 2019 10:50 am
Plug the device in after the Pi has booted, and then run the "dmesg" command and look at the last lines outputted.
It should indicate if the device has been detected as a keyboard or as a joystick.
You can also use the "evtest" program to test what events you get from the device.
How do I get evtest? I'm on a Pi Zero, so I have no direct internet access.

Andyroo

Re: Can I get a joystick to work on my pi without Retropi?

Sun Oct 06, 2019 6:56 pm

Triacular wrote:
Sun Oct 06, 2019 6:01 pm
topguy wrote:
Fri Sep 27, 2019 10:50 am
Plug the device in after the Pi has booted, and then run the "dmesg" command and look at the last lines outputted.
It should indicate if the device has been detected as a keyboard or as a joystick.
You can also use the "evtest" program to test what events you get from the device.
How do I get evtest? I'm on a Pi Zero, so I have no direct internet access.
Set the Zero up to use the USB port as an Ethernet connection - very handy for development and simple to back out for live.

Connections via Mac / Windows is documented here and works with Buster fine
Internet sharing for Mac is here - no idea for Windows

sneazzy95
Posts: 3
Joined: Mon Oct 07, 2019 8:33 pm

Re: Can I get a joystick to work on my pi without Retropi?

Mon Oct 07, 2019 8:38 pm

Can someone explain to me what is evtest program and where I could find it ? Thanks.

UC Browser SHAREit MX Player
Last edited by sneazzy95 on Tue Oct 15, 2019 7:54 pm, edited 1 time in total.

scotty101
Posts: 3732
Joined: Fri Jun 08, 2012 6:03 pm

Re: Can I get a joystick to work on my pi without Retropi?

Tue Oct 08, 2019 8:32 am

sneazzy95 wrote:
Mon Oct 07, 2019 8:38 pm
Can someone explain to me what is evtest program and where I could find it ? Thanks
The man page for evtest explains what it is
http://manpages.ubuntu.com/manpages/tru ... est.1.html

You should be able to install it using

Code: Select all

sudo apt-get install evtest
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Gaming”