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

    Mapping java games in Retropie with joy2key

    Scheduled Pinned Locked Moved Help and Support
    control configsjava gamesjoy2key
    10 Posts 2 Posters 1.4k 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.
    • EliasE
      Elias
      last edited by

      Hi,

      I play to java games in Retropie.

      I would like mapping a GamePad to a KeyBoard, I have tried use joy2key but don't work.

      I have this:

      • emulators.cfg:
      java = "/opt/retropie/configs/java/joy2key_init.sh; sudo xinit -e 'java -Xms384M -Xmx384M -jar %ROM%' -- :0"
      default = "java"
      
      • joy2key_init.sh
      echo "Init joy2key_init.sh" >> /dev/shm/runcommand.log
      
      sudo pkill -f joy2key
      echo "Kill possible running joy2key processes" >> /dev/shm/runcommand.log
      sleep 5
      
      readonly JOY2KEY_SCRIPTLOC="/home/pi/RetroPie-Setup/scriptmodules/helpers.sh"
      
      # Config:
      # DPAD = Cursors	(kcub1 kcuf1 kcuu1 kcud1)
      # A = Space			(ASCII 32 -> HEXADECIMAL 0x20)
      # B = Enter			(ASCII 10 -> HEXADECIMAL 0x0a)
      # X = Escape		(ASCII 27 -> HEXADECIMAL 0x1b)
      # Y = F1			(kf1)
      readonly CONFIG=(kcub1 kcuf1 kcuu1 kcud1 0x20 0x0a 0x1b kf1)
      
      if [[ -f $JOY2KEY_SCRIPTLOC ]]; then
      	echo "Script $JOY2KEY_SCRIPTLOC found" >> /dev/shm/runcommand.log
      	
      	source "$JOY2KEY_SCRIPTLOC"
      	scriptdir="/home/pi/RetroPie-Setup"
      	joy2keyStart ${CONFIG[@]}
      	echo "joy2key throw" >> /dev/shm/runcommand.log
      else
      	echo "Script $JOY2KEY_SCRIPTLOC NOT found" >> /dev/shm/runcommand.log
      fi
      
      echo "Exit joy2key_init.sh" >> /dev/shm/runcommand.log
      

      I know that the script runs correctly, because I have threw Midnight Commander after of joy2key_init.sh and works with GamePad, but java games no.

      Any idea??

      Thanks

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

        joy2key is working with the console terminal, not with X11 applications.
        Also, don't use sudo to run any emulators or xinit, it's not necessary and it will cause permissions issues.

        EliasE 1 Reply Last reply Reply Quote 0
        • EliasE
          Elias @mitu
          last edited by

          @mitu thanks a lot.

          Oks, I will remove sudo.

          Do you know any application to mapping keys that works with X11??

          EliasE 1 Reply Last reply Reply Quote 0
          • EliasE
            Elias @Elias
            last edited by

            Hi,

            I have read this in the Joy2key official documentation:

            "joy2key monitors the joystick (normally /dev/input/js0) and sends keyboard events to an X window, terminal, or raw console. In the case of X, xwininfo(1) is used to retrive the window ID, which should not be a problem as this is a standard utility in most X11 distributions."

            Then, does Joy2key must works with xinit??

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

              @elias Which documentation are you referring to ?

              EliasE 1 Reply Last reply Reply Quote 0
              • EliasE
                Elias @mitu
                last edited by

                Hi @mitu ,

                I have tried with joy2key python script (joy2key.py) and with joy2key application (apt-get install joy2key).

                The documentation where I have seen X window is the application documentation:
                http://manpages.ubuntu.com/manpages/xenial/man1/joy2key.1.html

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

                  @elias said in Mapping java games in Retropie with joy2key:

                  http://manpages.ubuntu.com/manpages/xenial/man1/joy2key.1.html

                  This is a different application, same name though, than the one shipped with RetroPie.

                  EliasE 1 Reply Last reply Reply Quote 0
                  • EliasE
                    Elias @mitu
                    last edited by

                    Hi @mitu ,

                    Yes, I know.

                    First, I tried with joy2key python script (joy2key.py) shipped with RetroPie, doesn't works.

                    Second, I tried with joy2key application (apt-get install joy2key), neither works.

                    What do you advise me?

                    EliasE 1 Reply Last reply Reply Quote 0
                    • EliasE
                      Elias @Elias
                      last edited by

                      Hi,

                      This is my configuration to joy2key application:

                      • emulators.cfg (like in python script ):
                      java = "/opt/retropie/configs/java/joy2key_init.sh; sudo xinit -e 'java -Xms384M -Xmx384M -jar %ROM%' -- :0"
                      default = "java"
                      
                      • joy2key_init.sh
                      echo "Init joy2key_init.sh" >> /dev/shm/runcommand.log
                      
                      sudo pkill -f joy2key
                      echo "Kill possible running joy2key processes" >> /dev/shm/runcommand.log
                      sleep 5
                      
                      joy2key -rcfile /opt/retropie/configs/java/joy2keyrc -config java
                      
                      echo "Exit joy2key_init.sh" >> /dev/shm/runcommand.log
                      
                      • joy2keyrc:
                      COMMON
                      -thresh -32767 32767 -32767 32767
                      
                      START java
                      -X
                      -dev /dev/input/js0
                      -buttons Space Escape Return
                      -axis Left Right Up Down
                      

                      Like in python script , if I throw Midnight Commander after of joy2key_init.sh then works with GamePad, but if I throw java games no.

                      EliasE 1 Reply Last reply Reply Quote 0
                      • EliasE
                        Elias @Elias
                        last edited by

                        I'm going to try with rejoystick (http://rejoystick.sourceforge.net/)

                        Do we know it?

                        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.