RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Joy2key causing controller issues

    Scheduled Pinned Locked Moved Help and Support
    joy2keyopenborportscontrollerexits emulator
    36 Posts 4 Posters 6.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BiZzAr721B
      BiZzAr721
      last edited by BiZzAr721

      I am having an issue with Joy2key causing an issue with OpenBOR. When I load the port, when I hit LEFT on any controller I try (ps3, snes clone, xbox360) it immediately exits back to ES.

      I have been working on setting up OpenBOR
      Tutorial: OpenBOR - the complete guide

      I created a "test image", which was a backup of the SD card I was using, so I can experiment with openBOR. That image still works perfect. I haven't done anything except copy over all the finished OpenBOR content.
      I tried many trouble steps. Runcommand.sh as well joy2key.py are identical on both images.
      As per @cyperghost 's recommendation, I did ps - a while open bor was running. It showed joy2key running, where as on the working test image it is not. When killing joy2key, the controller works as it should.

      I checked other ports as well, and they all show joy2key running, except they have no noticeable effects on the controller. Again, my OpenBOR test image doesn't show joy2key running during any port.

      Is my understanding that joy2key is needed to navigate runcommand menu, but should turn off when a emulator/port is executed.

      I don't have the slightest idea of where to go from here.
      I appreciate any help. Thank you!

      Power Supply used: (RPI3 3B Plus Power Supply Raspberry Pi Power Supply Switch 5V 3A UL Certified Compatible w/2.5A 2A 1.5A 1A Fast Rapid Charge AC Adapter w/1.5m Extra Long On Off Power Switch Micro USB Cable)
      RetroPie Version Used (4.4):
      Built From: (Pre made SD Image on RetroPie website 
      retropie-4.4-rpi2_rpi3.img.gz)
      USB Devices connected:Logitech wireless keyboard/mouse combo
      Controller used:snes tata clone (wired)
      Error messages received: nome - exits back to es```
      
      **Edit**
      Formatting
      cyperghostC 1 Reply Last reply Reply Quote 0
      • cyperghostC
        cyperghost @BiZzAr721
        last edited by

        @bizzar721 Please post content of your runcommand-onstart.sh

        1 Reply Last reply Reply Quote 0
        • BiZzAr721B
          BiZzAr721
          last edited by

          I do not have a runcommand-onstart.sh or runcommand-onend.sh file in /opt/retropie/configs/all/
          Should I? I haven't checked the image I was doing our experimenting of OpenBOR with to compare.
          Here is the contents of runcommand.cfg if that is helpful:

          use_art = "0"
          disable_joystick = "0"
          governor = ""
          disable_menu = "0"
          image_delay = "2"
          
          cyperghostC 1 Reply Last reply Reply Quote 0
          • cyperghostC
            cyperghost @BiZzAr721
            last edited by

            @bizzar721 Some call with the es_systems.cfg in ports section? Does this accour on a fresh install, too?

            BiZzAr721B 1 Reply Last reply Reply Quote 0
            • BiZzAr721B
              BiZzAr721 @cyperghost
              last edited by

              @cyperghost I don't see anything different in es_systems.cfg between the working and messed up images. I've been trying to find out more about joy2key in retropie but info seems to be very vague. I was hoping to see how, where, and when joy2key is used.

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @BiZzAr721
                last edited by

                @bizzar721 You can look directly at the source for runcommand.sh to see how it's used - https://github.com/RetroPie/RetroPie-Setup/blob/master/scriptmodules/supplementary/runcommand.sh.

                BiZzAr721B 1 Reply Last reply Reply Quote 0
                • BiZzAr721B
                  BiZzAr721 @mitu
                  last edited by

                  @mitu Thanks, this helped give some more insight. Still a little blurry, but much easier to read than runcommand.sh file on my pi

                  I changed permissions, renamed joy2key.pyc & joy2key.py and restarted system. Of course problem went away, but then I'd lose controls on runcommand menus. I renamed then back to normal, then ran OpenBor. It worked fine. I did this a couple of times and still worked. Then back at ES, I switched controller USB port. The problem came back. After exiting OpenBor using the Left on D-pad, I entered runcommand. Up & down, Left & Right functioned properly, but select button (B) moved selection down as well, and another button (Y) moved up. Left Trigger was now select.
                  (Actual keyboard Enter worked normal)

                  cyperghostC 1 Reply Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @BiZzAr721
                    last edited by cyperghost

                    @bizzar721 I've a solution but it's really a dirty hack and a workaround!

                    You edit runcommand-onstart.sh
                    Be aware the last & is mandotary!

                    [[ "$1" == "openbor" ]] && /path/to/script/delaykill_joy2key.sh OpenBOR &
                    

                    No you create script delaykill_joy2key.sh and make it executable with chmod +x delaykill_joy2key.sh

                    #!/bin/bash
                    
                    while true; do
                        if [[ -n $(pgrep -f $1) ]]; then
                           pkill -f joy2key.py
                           break
                        else
                           sleep 1
                        fi
                    done
                    
                    1 Reply Last reply Reply Quote 1
                    • BiZzAr721B
                      BiZzAr721
                      last edited by BiZzAr721

                      Thank you for writing up those commands for me. I will give them a go so I can get some BOR play in while family is out - In the meantime, I am going to backup my OpenBor testing image (in case I need to grab some working files for more troubleshooting), then restore an earlier backup over it - and I hope I can remember all the minor tweaks I've done such as renaming roms, and switching out video snaps then re-introduce OpenBOR. Ultimately, I can get back to a working image(hopefully the issue doesn't re-appear, but now I'll be tracking my steps), but I still will be trying to figure out what's going on with this issue. (To help others who may have a similar problem, possibly squash a bug)

                      Thinking about it now, when I was setting everything up and remapping controllers, there was a point I had the wireless xbox 360 receiver plugged in along with the SNES clone (and I always have the wireless bluetooth receiver plugged in)
                      USB PORTS:
                      [======EMPTY======] [==xbox360=]
                      [=Wireless Keyboard=] [==SNES===]

                      Controllers were always switched while in ES menu

                      Is there a way to "reset usb"? I can't imagine controller config would cause this , but maybe I'll install Eazy Hax to run his Factory Reset Controller to see if it does anything.

                      1 Reply Last reply Reply Quote 0
                      • BiZzAr721B
                        BiZzAr721
                        last edited by

                        I just had the joy2key issue reappear. I had the backup image I restored to a sandisk 128gb (119gb after format) working fine. I wanted to get it back onto the original PNY 128gb (117gb) SD card, so I created a backup using win32img, then ran pishrink. I restored the image that was working when I created the image to the PNY SD, and upon boot, immediately went to ports and tried OpenBOR.

                        A couple of nights ago I installed PS3 BT driver, but that was done AFTER I already had an image made, so those changes were not on the image backed up. However, I did still have a SNES clone plugged into a different USB port upon boot.

                        I don't know if this is the cause, but I will try to burn the image again, this time booting with the controller in the regular usb port I've been using.

                        Maybe some people can try running ps - a to see f they have joy2key running without even knowing it. It seems the only system/port effected by the exit left bug seems to be openbor. Others there is no noticeable difference with joy2key running at the same time.

                        cyperghostC 1 Reply Last reply Reply Quote 0
                        • cyperghostC
                          cyperghost @BiZzAr721
                          last edited by

                          @bizzar721

                          Others there is no noticeable difference with joy2key running at the same time.

                          Well yes there can be an issue. If you start ports again it may happen a second instance of joy2key is running. So you have suddenly leaps if you want to select something in dialog.

                          1 Reply Last reply Reply Quote 0
                          • BiZzAr721B
                            BiZzAr721
                            last edited by

                            So, I have just restored my backup again (the exact same backup I just used that had issues on start). This time I plugged the controller into the usual port. Started up no problem! So I'm certain that had something to do with it. After some messing around , copying back the SNES default controller configs, I went to access run command but pushed the button a tad bit late and BAM! Joy2key issue was back!

                            I was able to recover this time. The ONLY way I was able to was to be in ES menu - open terminal and type ps -a
                            Find the entry for joy2key and then kill 1234 (1234 being process ID #)

                            I randomly does it if I happen to tap A or B at the wrong time, but does NOT do it no matter how much I tap the L & R shoulder buttons. I assume they are not mapped with joy2key.

                            cyperghostC 1 Reply Last reply Reply Quote 0
                            • cyperghostC
                              cyperghost @BiZzAr721
                              last edited by cyperghost

                              @bizzar721 I just used SNES clone controller, but joy2key is terminated after runcommand call (as it should).... strange strange...

                              Did you try the little hacky script? This seems the only "quick" solution I discovered so far :(

                              Btw: pgrep joy2key.py will directly show PID
                              pkill joy2key.py will directly terminate process ;)

                              ps -ais good for diagnosis ;)

                              BiZzAr721B 1 Reply Last reply Reply Quote 1
                              • BiZzAr721B
                                BiZzAr721 @cyperghost
                                last edited by BiZzAr721

                                @cyperghost Thanks for the explanation of pkill. I have not gotten to try the joy2key disable script yet. Even though it may be a bit hackey, at least it's not taking up any resources.

                                From what I read, this particular Joy2key is only used for runcommand and even if I wished to use Joy2key inside an emulator (which I don't), I would want a different Joy2key.

                                I still have not been able to find in runcommand how exactly Joy2key is called to shut down. I can't image what is stopping it from terminating (or possibly starting back up)

                                EDIT
                                I went through various systems and used ps - a and Joy2key was running in the background of many, such as SNES, & Gameboy running retroarch. With Joy2key not running in ES, booting a gameboy game without hitting any buttons, Joy2key will be running in the background.

                                For ports (any), hitting A or B anytine during loading screen, not going into runcommand, will cause Joy2key to run in the background.

                                1 Reply Last reply Reply Quote 0
                                • BiZzAr721B
                                  BiZzAr721
                                  last edited by BiZzAr721

                                  @cyperghost The script did not work. Here is from runcommand log:

                                  /opt/retropie/configs/all/runcommand-onstart.sh: /opt/retropie/configs/all/delaykill_joy2key.sh: /bin/bash^M: bad interpreter: No such file or directory
                                  Parameters: 
                                  Executing: pushd /opt/retropie/ports/openbor; /opt/retropie/ports/openbor/OpenBOR "/home/pi/RetroPie/roms/ports/openbor/Aliens Vs Predator Aftermath (Demo).bor"; popd
                                  /opt/retropie/ports/openbor ~
                                  

                                  I looked up the error and it had to do with the file being created on windows, so I then ran a dos2unix utility.
                                  After that, the error was gone, as well as any mention of it in the runcommand log. Unfortunately it does not close joy2key.

                                  EDIT
                                  Going into runcommand settings and changing launch menu to disable removes joy2key from ever being started. All the keypresses during loading screen on any emulators would not invoke joy2key. Of course I lose an important feature of Emulation Station/RetroPie. I'm hoping this will help in pinpointing the issue.
                                  At this point, I would be interested in using a global KillJoy2Key script! This is making my head spin!

                                  cyperghostC 1 Reply Last reply Reply Quote 0
                                  • cyperghostC
                                    cyperghost @BiZzAr721
                                    last edited by cyperghost

                                    @bizzar721 said in Joy2key causing controller issues:

                                    The script did not work. Here is from runcommand log:

                                    It works for sure. You are using wrong formated text file format, Winows is using CR LF as newline, Unix system just using LF. You can avoid this if you are calling the bash script with command bash from runcommand-onstart.sh. It will look like this

                                    [[ "$1" == "openbor" ]] && bash /path/to/script/delaykill_joy2key.sh OpenBOR &
                                    

                                    A global joy2key kill script is also considerable. But I don't understand why the python script is still running in background in your case.

                                    I still have not been able to find in runcommand how exactly Joy2key is called to shut down

                                    It's a function call inside runcommand.sh very similar to the one I've used in the BoR-start menu script. But the call used by runcommand is done more professional and I did not have the time to dig deeper what exactly there happens. Simply the script detects joypads and set /dev/input/js# to joy2key. The PID of joy2key is savesdinto a variable. And if runcommand is going to finish the PID will be SIGTERMED, the PID of the python subshell is detected by bash with ?!

                                    1 Reply Last reply Reply Quote 0
                                    • BiZzAr721B
                                      BiZzAr721
                                      last edited by

                                      @cyperghost
                                      I really appreciate your time helping me with this. Thank you.

                                      After using dos2unix utility I didn't get any mention if it did or did not run in the log - but I also did not get the ^M error so I assumed it ran. I just realized I didn't change permissions to 0755 (but I did command to make it executable) so maybe that's why it didn't terminate Joy2key.

                                      I'm really debating if I just wipe the SD card, and start from scratch - restoring games & configs from the backup.
                                      It's just a lot of work getting everything just right, and I don't know what will reintroduce this bug if I start copying all the settings back over.

                                      cyperghostC 1 Reply Last reply Reply Quote 1
                                      • cyperghostC
                                        cyperghost @BiZzAr721
                                        last edited by cyperghost

                                        @bizzar721 I changed the script a bit pkill -f joy2key.py- is working better, because so it will also find python joy2key.pycalls ;) You can try to make a blank install. For first setups it will not take to much time to see if the issue will pop up again.

                                        1 Reply Last reply Reply Quote 0
                                        • BiZzAr721B
                                          BiZzAr721
                                          last edited by BiZzAr721

                                          Unfortunately, it did not work. First couple of tries it did not work, so I pkilled joy2key. After that it didn't come for about 25 times. (pressing all kinds of buttons on the controller). Even loading runcommand menu, joy2key was properly closing. Then, pressing A & B repeatedly, joy2key was back.

                                          Running the Unix delaykill_joy2key.sh from terminal sudo ./delaykill_joy2key.sh, I recieved and endless loop of:

                                          pgrep: no matching criteria specified
                                          Try `pgrep --help' for more information.
                                          

                                          Running the .sh not converted to unix using sudo bash ./delaykill_joy2key.sh

                                          ./delaykill_joy2key.sh: line 2: $'\r': command not found
                                          ./delaykill_joy2key.sh: line 10: syntax error near unexpected token `done'
                                          ./delaykill_joy2key.sh: line 10: `done'
                                          

                                          EDIT
                                          I get it, it won't run from terminal because variables are defined in runcommand-onstart.sh

                                          I thought that maybe your script was closing joy2key after run command, just like it should, and maybe something else was causing it to run again just after. I apologize if those commands were not input correctly in terminal.

                                          Dumping the files from my backup as we speak, hopefully I can get the new SD card up and running sometime tomorrow.

                                          This is going to make me jump out of a plane! (seriously, I'll be going skydiving tomorrow)

                                          cyperghostC 1 Reply Last reply Reply Quote 1
                                          • cyperghostC
                                            cyperghost @BiZzAr721
                                            last edited by cyperghost

                                            @bizzar721 said in Joy2key causing controller issues:

                                            seriously, I'll be going skydiving tomorrow

                                            Make your head clean and use the force!

                                            I get it, it won't run from terminal because variables are defined in runcommand-onstart.sh

                                            Yes runcommand-onstart sets parameter to obtain PID of a binary or script.
                                            I think a general script is easily possible to do.

                                            1. You set a delay timer of maybe 5 seconds before the while-loop
                                            2. You search for pgrep -f dialog
                                            3. IF NOT any dialog PID is found, then try to terminate joy2key

                                            But for now try it just for openBOR, because that makes trouble and the script defintly works in this case. It's not simple to write general solutions without test area.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.