Random Directional Inputs (possibly Joystick)

Please check here for help solving common issues.
Hitokiri
Posts: 7
Joined: Tue 2 Jun 2020 20:10

Random Directional Inputs (possibly Joystick)

Post by Hitokiri »

Hello everyone,

First time poster, was hoping it wasn't going to be so soon after receiving my Retrostone2 in the mail, but here I am.

Everything looked good when I first unpacked it. I plugged in the RS2 to charge up for a couple of hours. In the meantime, I followed the tutorial for getting the SD card ready, according to http://www.8bcraft.com/retrostone2-tutorial.

After putting in the SD in and powering the RS2 on, everything was getting prepped over a few minutes and eventually Retrorangepi booted up. I was then prompted to map the controls for the RS2 with the control that was detected. This is where the issue began.

The RS2 was registering intermittent inputs from "Axis 1+" or "Axis 1-" at a rapid rate. Whenever I tried to map each button starting, the RS2 would try to map one of those inputs to each entry, often coming up with message "Already mapped" when it tried to map to each key.

All the other buttons seem to register properly, except for the joystick (which seems to be where the "Axis 1+/Axis 1-" are coming from).

At first, I thought this issue was unique to retroarngepi as a software issue, so I tried formatting, deleting partitions, and starting the installation from scratch. But the same issue happened again.

The issue seems to also persist when I go into other functions and applications on the RS2 (desktop mode, various configurations such as bluetooth and wifi, etc). The selection in each mode will move around erratically as if I'm using the joystick when I'm not inputting anything.

I looked through the troubleshooting and support forums, but I couldn't find any similar issues. Could I please get some help? Can I give any other information that would be helpful in troubleshooting this problem?

Thank you everyone in advance!
999Nocturne
Posts: 9
Joined: Wed 3 Jun 2020 19:27

Re: Random Directional Inputs (possibly Joystick)

Post by 999Nocturne »

Hi, I have your same problem, it is very frustrating, has anyone found the solution?
User avatar
Admin
Administrateur du site
Posts: 505
Joined: Sat 10 Dec 2016 13:12

Re: Random Directional Inputs (possibly Joystick)

Post by Admin »

Hi there!
This issue sounds familiar, I need to search a bit.
You have the joytsick version right? Just to make sure.

It sounds like the joystick driver is throwing calls even while you are not moving it.

I pasted below a python script which can be used to debug the joystick. If you want to try to run it see what it says when moving or not moving joystick.
(to run it you need to save the code in a file that you can call "j.py" for instance. Then "sudo python path-to-the-file/j.py")

Code: Select all

#!/usr/bin/env python

from time import sleep
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector


DZONE = 200 # dead zone applied to joystick (mV)
VREF = 1350 # joystick Vcc (mV)
JOYOFFVAL = 5000 # Value read when joystick is not connected.
CENTER = 1
OFFVAL = 0


#--------------- define botoes -----------------
	# ---- PLAYER 1 ---------#
bt_up_p1 = port.PH19
bt_down_p1 = port.PH7
bt_left_p1 = port.PH4
bt_right_p1 = port.PH16

bt_l_p1 = port.PH23
bt_x_p1 = port.PH12
bt_y_p1 = port.PH20
bt_r_p1 = port.PH22
bt_b_p1 = port.PH11
bt_a_p1 = port.PH0

bt_select_p1 = port.PH15
bt_start_p1 = port.PH14

bt_left_trigger_p1 = port.PH27
bt_right_trigger_p1 = port.PH26

#optional buttons
bt_c_p1 = port.PC18
bt_z_p1 = port.PC22

#--------------------------------Initialize module. Always called first
gpio.init()

gpio.setcfg(bt_up_p1, gpio.INPUT)
gpio.pullup(bt_up_p1, gpio.PULLUP)

gpio.setcfg(bt_down_p1, gpio.INPUT)
gpio.pullup(bt_down_p1, gpio.PULLUP)

gpio.setcfg(bt_left_p1, gpio.INPUT)
gpio.pullup(bt_left_p1, gpio.PULLUP)

gpio.setcfg(bt_right_p1, gpio.INPUT)
gpio.pullup(bt_right_p1, gpio.PULLUP)


gpio.setcfg(bt_l_p1, gpio.INPUT)
gpio.pullup(bt_l_p1, gpio.PULLUP)

gpio.setcfg(bt_x_p1, gpio.INPUT)
gpio.pullup(bt_x_p1, gpio.PULLUP)

gpio.setcfg(bt_y_p1, gpio.INPUT)
gpio.pullup(bt_y_p1, gpio.PULLUP)

gpio.setcfg(bt_r_p1, gpio.INPUT)
gpio.pullup(bt_r_p1, gpio.PULLUP)

gpio.setcfg(bt_b_p1, gpio.INPUT)
gpio.pullup(bt_b_p1, gpio.PULLUP)

gpio.setcfg(bt_a_p1, gpio.INPUT)
gpio.pullup(bt_a_p1, gpio.PULLUP)

gpio.setcfg(bt_c_p1, gpio.INPUT)
gpio.pullup(bt_c_p1, gpio.PULLUP)

gpio.setcfg(bt_z_p1, gpio.INPUT)
gpio.pullup(bt_z_p1, gpio.PULLUP)

gpio.setcfg(bt_select_p1, gpio.INPUT)
gpio.pullup(bt_select_p1, gpio.PULLUP)

gpio.setcfg(bt_start_p1, gpio.INPUT)
gpio.pullup(bt_start_p1, gpio.PULLUP)

gpio.setcfg(bt_left_trigger_p1, gpio.INPUT)
gpio.pullup(bt_left_trigger_p1, gpio.PULLUP)

gpio.setcfg(bt_right_trigger_p1, gpio.INPUT)
gpio.pullup(bt_right_trigger_p1, gpio.PULLUP)

	
_bt_up_p1 = False
_bt_down_p1 = False
_bt_left_p1 = False
_bt_right_p1 = False
_bt_a_p1 = False
_bt_b_p1 = False
_bt_x_p1 = False
_bt_y_p1 = False
_bt_c_p1 = False
_bt_z_p1 = False
_bt_d_p1 = False
_bt_e_p1 = False
_bt_l_p1 = False
_bt_r_p1 = False
_bt_select_p1 = False
_bt_start_p1 = False
_bt_left_trigger_p1 = False
_bt_right_trigger_p1 = False


exit = True


while exit:
	#------ player 1 -----------#		
#bt a =====================
	if (not _bt_a_p1) and (gpio.input(bt_a_p1) == 0):
		_bt_a_p1 = True
		print("A")	
	if (_bt_a_p1) and (gpio.input(bt_a_p1) == 1):
		_bt_a_p1 = False
		print("A unclicked")
			
#bt b =====================

	if (not _bt_b_p1) and (gpio.input(bt_b_p1) == 0):
		_bt_b_p1 = True
		print("B")	
	if (_bt_b_p1) and (gpio.input(bt_b_p1) == 1):
		_bt_b_p1 = False
		print("B unclicked")
			

#bt X =====================

	if (not _bt_x_p1) and (gpio.input(bt_x_p1) == 0):
		_bt_x_p1 = True
		print("X")	
	if (_bt_x_p1) and (gpio.input(bt_x_p1) == 1):
		_bt_x_p1 = False
		print("X unclicked")	
#bt Y =====================

	if (not _bt_y_p1) and (gpio.input(bt_y_p1) == 0):
		_bt_y_p1 = True
		print("Y")	
	if (_bt_y_p1) and (gpio.input(bt_y_p1) == 1):
		_bt_y_p1 = False
		print("Y unclicked")	

#bt C =====================

	if (not _bt_c_p1) and (gpio.input(bt_c_p1) == 0):
		_bt_c_p1 = True
		print("PC18-BrightnessUp")	
	if (_bt_c_p1) and (gpio.input(bt_c_p1) == 1):
		_bt_c_p1 = False
		print("PC18-BrightnessUp unclicked")
		
#bt C =====================

	if (not _bt_z_p1) and (gpio.input(bt_z_p1) == 0):
		_bt_z_p1 = True
		print("PC22-BrightnessDown")	
	if (_bt_z_p1) and (gpio.input(bt_z_p1) == 1):
		_bt_z_p1 = False
		print("PC22-BrightnessDown unclicked")
		
#bt L =====================
	if (not _bt_l_p1) and (gpio.input(bt_l_p1) == 0):
		_bt_l_p1 = True
		print("L")
	if (_bt_l_p1) and (gpio.input(bt_l_p1) == 1):
		_bt_l_p1 = False
		print("L unclicked")
#bt R =====================
	if (not _bt_r_p1) and (gpio.input(bt_r_p1) == 0):
		_bt_r_p1 = True
		print("R")
	if (_bt_r_p1) and (gpio.input(bt_r_p1) == 1):
		_bt_r_p1 = False
		print("R unclicked")
#bt select =====================
	if (not _bt_select_p1) and (gpio.input(bt_select_p1) == 0):
		_bt_select_p1 = True
		print("select")
	if (_bt_select_p1) and (gpio.input(bt_select_p1) == 1):
		_bt_select_p1 = False
		print("select unclicked")
#bt start =====================
	if (not _bt_start_p1) and (gpio.input(bt_start_p1) == 0):
		_bt_start_p1 = True
		print("start")
	if (_bt_start_p1) and (gpio.input(bt_start_p1) == 1):
		_bt_start_p1 = False
		print("start unclicked")
#bt L2 =====================
	if (not _bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 0):
		_bt_left_trigger_p1 = True
		print("L2")
	if (_bt_left_trigger_p1) and (gpio.input(bt_left_trigger_p1) == 1):
		_bt_left_trigger_p1 = False
		print("L2 unclicked")
#bt R2 =====================
	if (not _bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 0):
		_bt_right_trigger_p1 = True
		print("R2")
	if (_bt_right_trigger_p1) and (gpio.input(bt_right_trigger_p1) == 1):
		_bt_right_trigger_p1 = False
		print("R2 unclicked")
####DIRECTIONS P1 ###########################

#bt up =====================
	if (not _bt_up_p1) and (gpio.input(bt_up_p1) == 0):
		_bt_up_p1 = True
		print("up")
	if (_bt_up_p1) and (gpio.input(bt_up_p1) == 1):
		_bt_up_p1 = False
		print("up unclicked")
#bt down =====================
	if (not _bt_down_p1) and (gpio.input(bt_down_p1) == 0):
		_bt_down_p1 = True
		print("down")
	if (_bt_down_p1) and (gpio.input(bt_down_p1) == 1):
		_bt_down_p1 = False
		print("down unclicked")
#bt left =====================
	if (not _bt_left_p1) and (gpio.input(bt_left_p1) == 0):
		_bt_left_p1 = True
		print("left")
	if (_bt_left_p1) and (gpio.input(bt_left_p1) == 1):
		_bt_left_p1 = False
		print("left unclicked")
#bt right =====================
	if (not _bt_right_p1) and (gpio.input(bt_right_p1) == 0):
		_bt_right_p1 = True
		print("right")
	if (_bt_right_p1) and (gpio.input(bt_right_p1) == 1):
		_bt_right_p1 = False
		print("right unclicked")
		
	if (_bt_right_trigger_p1) and (_bt_up_p1):
		exit = False
		
		
#joystick =====================
	f3scale=open("/sys/bus/iio/devices/iio:device0/in_voltage3_scale", "r")
	f4scale=open("/sys/bus/iio/devices/iio:device0/in_voltage4_scale", "r")
	f3raw=open("/sys/bus/iio/devices/iio:device0/in_voltage3_raw", "r")
	f4raw=open("/sys/bus/iio/devices/iio:device0/in_voltage4_raw", "r")
	
	joystick_LR = int(int(f3raw.read())*float(f3scale.read()))
	joystick_UD = int(int(f4raw.read())*float(f4scale.read()))

	
	if (joystick_LR > (VREF/2 + DZONE)) or (joystick_LR < (VREF/2 - DZONE)):
		#gamepad.emit(uinput.ABS_X, VREF - joystick_LR ) 
		print("left right : ",joystick_LR)
		
	if (joystick_UD > (VREF/2 + DZONE)) or (joystick_UD < (VREF/2 - DZONE)):
		#gamepad.emit(uinput.ABS_Y, joystick_UD )
		print("up/down : ", joystick_UD)
	
	
	
	f3raw.close()
	f4raw.close()
	f3scale.close()
	f4scale.close()
	
	sleep(.2)
999Nocturne
Posts: 9
Joined: Wed 3 Jun 2020 19:27

Re: Random Directional Inputs (possibly Joystick)

Post by 999Nocturne »

thanks for the support, I use a retroStone 2 with the joystick, I uploaded a private video on the tube so that you can see what is going on, it seems to me that the joystick is moving exactly as if someone was physically moving it.

https://www.youtube.com/watch?v=OaXm7C6 ... e=youtu.be
Hitokiri
Posts: 7
Joined: Tue 2 Jun 2020 20:10

Re: Random Directional Inputs (possibly Joystick)

Post by Hitokiri »

Hello again,

Thank you very much for the very prompt response and continued support. I'm a little rusty with everything here, but I was able to get through with your instructions, thank you!

I'd like to confirm that this is the RetroStone2 Pro (clear blue) with the joystick mod (as per the 2 kickstarter campaigns).

So I ran the python code you provided and was greeted with the following results:
- A constant stream of inputs of the following line:
('up/down : ', 0)

- Buttons (not joystick) are registering both presses and depressions (Clicked and unclicked).

- When the joystick is moved horizontally, I will get lines such as:
(left right : ', 1340)

- When the joystick is moved vertically, the numerical value typically doesn't not change from 0
('up/down : ', 0)

- Sometimes when the joystick is stimlutaed, the up/down value would register a value and rapidly reduce until it hit 0:
('up/down : ', 723)
('up/down : ', 611)
('up/down : ', 400)
('up/down : ', 15)
('up/down : ', 0)
('up/down : ', 0)
('up/down : ', 0)
('up/down : ', 0)

I've also uploaded a video: https://youtu.be/ScM5XqDU1FU


Thank you so much again for the assistance.
999Nocturne
Posts: 9
Joined: Wed 3 Jun 2020 19:27

Re: Random Directional Inputs (possibly Joystick)

Post by 999Nocturne »

So today I disassembled the version of Retrostone 2 with Joystick, I noticed that the contacts on the joystick 2 were not welded, however I did not touch anything, I thought it was possible to open the joypad to clean it in order to test if this was the problem, unfortunately the joystick is closed, at this point I closed everything and tried the RetroStone, magically the random joystick problem disappeared, at this point I think of a hardware and not software problem, I ask those who have opened their RetroStone 2 if they have all joystick contacts welded?
What do I do, I can weld?
User avatar
Admin
Administrateur du site
Posts: 505
Joined: Sat 10 Dec 2016 13:12

Re: Random Directional Inputs (possibly Joystick)

Post by Admin »

999Nocturne wrote: Fri 5 Jun 2020 11:58 thanks for the support, I use a retroStone 2 with the joystick, I uploaded a private video on the tube so that you can see what is going on, it seems to me that the joystick is moving exactly as if someone was physically moving it.
It's strange in your video the joystick seems to behave correctly. It is not triggering all by itself and moves.
Can you please post picture of the joystick solder pads so I can look at them? I'll confirm you what to do.
Though it's strange if they are not soldered because it seems to be working correctly in your video.
Hitokiri wrote: Mon 8 Jun 2020 07:37 - A constant stream of inputs of the following line:
('up/down : ', 0)
Your video is private, can you please send set it as public but not listed? Meaning you can see it only with the URL.
Hitokiri
Posts: 7
Joined: Tue 2 Jun 2020 20:10

Re: Random Directional Inputs (possibly Joystick)

Post by Hitokiri »

Hello Admin,

I've adjusted the setting on my video from being private to being unlisted. You should be able to view the video now from my link. Sorry for that.

Thanks!
999Nocturne
Posts: 9
Joined: Wed 3 Jun 2020 19:27

Re: Random Directional Inputs (possibly Joystick)

Post by 999Nocturne »

Well, today I reopened the RetroStone 2 to take photos, here are the two points where the welds are missing ... I think my problem was caused by this, I wait for confirmation before soldering them.

Image
Image
Image
Image
Image
Image
maximilianvoss
Posts: 6
Joined: Tue 7 Apr 2020 12:53

Left Button is pressed permanently

Post by maximilianvoss »

Hi,
after an intensive period of gaming it happened to me a couple times that the character was running permanently to the left (or it seemed that the left button was pressed permanently) on RS2 without mounted Joystick. [1]
It is a static charge on the solder points. The easiest workaround is to remove the Joystick code from the driver. I updated the driver's code and put it onto github [2].

Best,
Max

[1]: https://retropie.org.uk/forum/topic/266 ... uring-game
[2]: https://github.com/maximilianvoss/retrostone2
Post Reply