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.1k 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

      @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
                • BiZzAr721B
                  BiZzAr721
                  last edited by BiZzAr721

                  I just tried out the "fresh" image and am still getting joy2key still running in background. I used a fresh retropie image downloaded from Retropie, then added folders back using Samba. I added the roms folder, bios folder and then config folder. I omitted es_settings.cfg, runcommand-launch-dialog.cfg and
                  runcommand.cfg

                  I did not touch anything that required SSH, nor did I even install anything from retropie setup. Can anyone check to see if they have joy2key running using retroarch?

                  Edit
                  I was digging into runcommand files again and compared /opt/retropie/supplementary/runcommandjoy2key.pyc from the new image with runcommandjoy2key.pyc from my backup and they were not identical.
                  0_1534052389661_joy2key.PNG

                  I replaced the file on the image I backed up (still had it on an SD card). I still got the error to reappear, but I really had to try to get it to happen so far. (only once) . Running Turbo grafx 16 opens joy2key, and once it's open, the only way to close it is to pkill it.

                  I also wanted to add in that when I renamed runcommandjoy2key.pyc to [OLD]runcommandjoy2key.pyc, but did not replace the file, joy2key was still working in runcommand, still staying open as well.

                  I

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

                    @bizzar721 Thejoy2key.py file should be just a small text file and it wasn't updated the last 5 months. You can see it here on Github

                    Annother question? What is runcommandjoy2key.pyc? And why it looks so strange encoded in your screenshot? Did you compiled it?

                    I also wanted to add in that when I renamed runcommandjoy2key.pyc to [OLD]runcommandjoy2key.pyc, but did not replace the file, joy2key was still working in runcommand, still staying open as well.

                    That's feasible because you seem to edit the wrong file. The script filename is joy2key.py it's located in same directory as runcommand.sh

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

                      @cyperghost

                      That's weird. This file was there on a clean build from the official RetroPie image. I assumed it was needed to run joy2key.py. It is located in the same folder as joy2key.py & runcommand.sh. That's why I thought it was so odd for it running without that file.

                      Joy2key.py matches the official joy2key.py. The last post is the only time I really looked into or mentioned joy2key.pyc. I was using WinMerge to compare the 2 files. Here is joy2key.pyc from the fresh install.

                      Inside of retropie-4.4-rpi2_rpi3.img
                      0_1534118823028_diskinternals.JPG

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

                        @bizzar721 Okay, I see
                        I think it's better to tag @BuZz maybe he can solve the question

                        Why is in the Image a compiled joy2key python script? Is this needed since RetroPie 4.4?
                        If I compare the github then the runcommand and the joy2key python-script were not updated since month.
                        It seems that @BiZzAr721 gots issues with a not terminated joy2key instance during emulator call.
                        This ends in a terminated OpenBOR session, because left DPAD seems to work as ESCAPE key which is so far an issue only with this emulator but it ocours also with others.
                        If you have any idea, than thanks for your feedback.

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

                          I spent a little time this evening trying to get this sorted out. I loaded up the "debug" image where I copied over only the contents of the folders available in samba (config, roms, bios). I went to enter a command in terminal and realized my keyboard wasn't set up for English US when I went to enter ~ command. I entered config and changed the keyboard type to Generic 101 key PC and AltGr as `default for this keyboard layout' .

                          I have not been able to replicate the joy2key bug yet.

                          Over on my complete image, I already had keyboard set, but I went ahead and reset the keyboard to the exact same options as mentioned above. This did not fix the problem.

                          Is there a way/is it safe to update retropie from source? I'm wondering if getting keyboard settings back to square one will help any. Maybe there are files I can try manually replacing?

                          I will try to recreate the bug in the "debug" image again....and again...and again...... and hopefully I will not see it reappear. Then I can slowly reintroduce system files. Any recommendations for which files should be introduced first?

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

                            Another update....
                            I've been using RetroPie for a couple of weeks now without the issue reappearing. I got it happening again. Installing Pixel Desktop to ports and some metadata edits through ES menu are the only things I can think that I have done besides playing games . Like usual, hard reboots didn't clear it. I created a new backup the bugged image. I then restored that very image and so far it hasn't happened yet. I can't imagine it is gone but I haven't had it return yet.
                            Technically I would assume the very first boot would have the same issue since that is the state I backed it up in.

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

                              I restored a backup that wasn't noticeably having the joy2key issue, and upon first boot, first try I was had the issue. I reinstalled ES from source but no change. Is there a possibility this specific SD card is causing the issue? I don't see how, but literally all I did was backup and restore to this SD.

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

                                @bizzar721 I believe it has something to do with your controller config. I suggest to manually check if instance of joy2key is running, or to use my delay kill script.

                                I sadly can not reproduce any of your issues maybe other users can

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

                                  @cyperghost My controller config only consists of the 1 SNES clone (This build I never added any additional controllers EXCEPT the logitech wireless dongle for my keyboard/touchpad combo)

                                  I turned of joypad support for runcommand and I have no issues since joy2key never starts. I still have joy2key support with your OpenBOR game selector AND it kills joy2key properly.

                                  The Joy2Key on_start scripts you wrote up never worked (which must have something to do why runcommand will not kill it) Somehow joy2key has infinite lives!

                                  EDIT
                                  Pressing buttons on loading screen I received a message on bottom left of screen
                                  readonly mode, sorry [start with --edit?]

                                  Edit 2

                                  Resetting ownership/permissions of /home/pi/RetroPie/roms
                                  That seems to be tied to that specific error

                                  Edit 3
                                  Restoring permissions did not help. I have been checking manually. I have done ps -a countless times. It's normal practice for me to run ps -a when ANY game is loaded lol

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

                                    @bizzar721 I know that these SNES controllers behave a bit unusual. I used your controller config for openbor and it worked also with mine so I assume that mine got the same chip set.

                                    So what is unusual of these? The DPAD is mapped as analog input - that is really the last thing I can think your issues are affected from this. Does this happen with a keyboard connected only?
                                    Why do you think your file permission is wrong?

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

                                      @cyperghost It happens no matter what is plugged in. This last time I reset controllers, then when I got the controller screen I setup a keyboard as controller and still have the issue. Even without keyboard plugged have the issue. I can tell when the issue is back because SNES will have a delay before the loading screen.

                                      The reason I reset permissions was that searching for the error shown on loading screen let to a post where resetting permissions cleared the error.

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

                                        While I was messing with the latest & greatest OpenBOR, while hitting keys on the controller I could get the console under the game to show (flash) so I recorded it, so I could replay it and pause when it flashed on screen. I don't know if this is anything substantial. Below is what is shown.

                                        0_1537718414282_VideoCapture_20180923-112812.jpg

                                        Traceback (most recent call last):
                                             File "/opt/retropie/supplementary/runcommand/joy2key.py", line 227, in <module>
                                                  chars = get_hex_chars(arg)
                                             File "/opt/retropie/supplementary/runcommand/joy2key.py", line 139, in get_hex_chars
                                                  return key_str[2:].decode('hex')
                                             File "/usr/lib/python2.7/encodings/_init_.py", line 100, in search_function
                                                  level=0)
                                             File "/usr/lib/python2.7/encodings/hex_codec.py", line 52, in <module>
                                                  class IncrementalEncoder(codecs.IncrementalEncoder):
                                             File "/opt/retropie/supplementary/runcommand/joy2key.py", line 134, in signal_handler
                                                   close_fds(js_fds)
                                        MameError: global name 'js_fds' is not defined
                                        

                                        fds may be Famicon Disk System which I have installed. MameError - I am certain I did not open/play any mame games between boot and this error. This error may be totally unrelated but it is too much of a coincidence to not post.

                                        I am curious how many people have this joy2key issue but are unaware since most games play just fine with it present. It seems OpenBOR is the only program to show ill effect from it.

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

                                          @BiZzAr721 there is a progress in resolving this issue. It would be nice to give report if the patch is ready and merged (PR#2654)
                                          @psyke83 is working on your issues related to joy2key (=kryptonite agony)

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

                                            @psyke83 This is great news! I have been restoring backups, and switching sd cards to get rid of it. At this moment I haven't noticed having the issue, but I will look to see if I have my abandoned sd card with the issue. When I recreate the issue, how do I use your remedy?

                                            @cyperghost Thanks for thinking of me. I'd sure like some piece of mind on this issue haha

                                            BuZzB 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.