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.py?

    Scheduled Pinned Locked Moved Help and Support
    tinypi
    14 Posts 4 Posters 3.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.
    • mooseprM
      moosepr
      last edited by

      Howdy Folks

      I have been playing with the code for my upcoming TinyPi Project, and someone pointed out an oddity.

      After much playing with uinput, i managed to get the gpio connected buttons of the TinyPi board seen to the system as a controller. I thought that this would be the best option, thinking that a controller would be the best direction for the gaming system.

      controller success

      A little bit more testing later, and when you crank up a game, up pops joy2Key.py

      top shot

      so im assuming that this is actually processing the joystick commands, and then converting them into keyboard commands?

      Would I actually be better off just creating keyboard events rather than joystick events, or would this code still end up running?

      I obviously want to keep things as streamlined as possible, so another program being there pretty much duplicating what I am doing seems weird to me!!

      Thanks

      Pete :)

      want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

      mediamogulM 1 Reply Last reply Reply Quote 0
      • mediamogulM
        mediamogul Global Moderator @moosepr
        last edited by mediamogul

        @moosepr

        so im assuming that this is actually processing the joystick commands, and then converting them into keyboard commands?

        Correct.

        Would I actually be better off just creating keyboard events rather than joystick events, or would this code still end up running?

        It would indeed. However, joy2key.py is only active during the time that the Runcommand window is active. Once the Runcommand menu exits, joy2key.py exits as well. For my xboxdrv mappings, I have it scripted to wait for joy2key.py to launch, loop until it exits and launch xboxdrv afterwards. This has worked out pretty well for me and allows use of the Runcommand window without another key-mapping program (xboxdrv) interfering.

        RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

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

          @mediamogul @moosepr
          Just to make some deeper questions....
          Why is joy2key active since an emulator core (retroarch) is running?
          This shouldn't be the case.
          Do you have some dialogs in background open?

          1 Reply Last reply Reply Quote 0
          • mooseprM
            moosepr
            last edited by

            Thanks for the replies guys.

            I was actually seeing it ruining all the time I was playing a game (GBA to be precise). I'm assuming that runcommand is still active because it triggers the emulator, so won't close until the emulator does 🤔

            The constant read/write nature of the program does suggest that it has to be running all the time the game is ruining, otherwise the mapping would no longer work

            Pete

            want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

            mediamogulM 1 Reply Last reply Reply Quote 0
            • mediamogulM
              mediamogul Global Moderator @moosepr
              last edited by mediamogul

              @moosepr said in Joy2Key.py?:

              I'm assuming that runcommand is still active because it triggers the emulator, so won't close until the emulator does

              The runcommand script should remain active throughout your gaming session. However, joy2key.py is supposed to exit alongside the Runcommand menu. Just to be completely clear, is this not the case for you?

              RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

              mooseprM 1 Reply Last reply Reply Quote 0
              • mooseprM
                moosepr @mediamogul
                last edited by

                @mediamogul that is what happens. i always assumed runcommand was just a quick run job before the emulator starts, but it makes more sense that its actually triggering the emulator too.

                are all the emulators normalised then, to use the same keys as input, or does the Joy2Key run differently for each emulator?

                want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

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

                  @moosepr said in Joy2Key.py?:

                  are all the emulators normalised then, to use the same keys as input, or does the Joy2Key run differently for each emulator?

                  No, as @mediamogul said, joy2key is not used by any emulators, just by Runcommand (and the RetroPie-Setup menu, when started from ES).

                  cyperghostC mooseprM 2 Replies Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @mitu
                    last edited by

                    @mitu The joy2key seems so confusing to many users. A hint in the wiki may be usefull. For what it is and what it does

                    @moosepr You can see the work of the joy2key in the Midnight Joy [SCRIPTLET]. This script will run MidnightCommander (a file manager for shell) and assign some keyboard keys to joy2key so you can do file actions with your controller.
                    Otherwise you need a SSH or keyboard connection to control this tool.

                    1 Reply Last reply Reply Quote 0
                    • mooseprM
                      moosepr @mitu
                      last edited by

                      @mitu ah i missunderstood.

                      So Joy2Key is not needed for the emulator, just for the runcommand menu? If this is the case, then it is sat in the background using cpu when it doesnt need to be

                      want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

                      mediamogulM 1 Reply Last reply Reply Quote 0
                      • mediamogulM
                        mediamogul Global Moderator @moosepr
                        last edited by mediamogul

                        @moosepr said in Joy2Key.py?:

                        If this is the case, then it is sat in the background using cpu when it doesnt need to be

                        It's only active for the duration of the Runcommand window. After the Runcommand window exits, so does joy2key.py. That being the case, it's never really wasting any CPU time.

                        RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                        mooseprM 1 Reply Last reply Reply Quote 0
                        • mooseprM
                          moosepr @mediamogul
                          last edited by

                          @mediamogul but if runcommand triggers the emulator, then it is running for the duration of the emulation session. or at least that is what i saw in my experimentation

                          want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

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

                            @moosepr Please add more info about your system - https://retropie.org.uk/forum/topic/3/read-this-first. If you stop your uinput script, does joy2key still remain resident ?

                            mooseprM 1 Reply Last reply Reply Quote 0
                            • mooseprM
                              moosepr @mitu
                              last edited by

                              @mitu I will test when i get home

                              The setup is a Raspberry Pi zero, running the latest Retropie. There is a tft driver (https://github.com/juj/fbcp-ili9341) my own bespoke uinput code emulating a controller and monitoring battery voltage, and running dtoverlay=hifiberry-dac and dtoverlay=i2s-mmap

                              want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

                              1 Reply Last reply Reply Quote 0
                              • mooseprM
                                moosepr
                                last edited by moosepr

                                ok so further testing. If i use adafruit retrogame, i see Joy2key appear in Top at about 20% cpu, then after a few seconds it disappears.

                                Using my own code, Joy2key does the same 20% ish cpu for a few seconds, then it will sit at about 4% cup for as long as im playing a game. it actually remains even when i close the emulator (start + select)

                                pi@retropie:~ $ udevadm info /dev/input/event0
                                P: /devices/virtual/input/input0/event0
                                N: input/event0
                                E: DEVNAME=/dev/input/event0
                                E: DEVPATH=/devices/virtual/input/input0/event0
                                E: ID_INPUT=1
                                E: ID_INPUT_JOYSTICK=1
                                E: ID_INPUT_KEY=1
                                E: ID_SERIAL=noserial
                                E: MAJOR=13
                                E: MINOR=64
                                E: SUBSYSTEM=input
                                E: TAGS=:seat:uaccess:
                                E: USEC_INITIALIZED=16949167
                                
                                pi@retropie:~ $ dmesg | grep -i input
                                [   16.015469] input: TinyPi-Pro as /devices/virtual/input/input0
                                

                                want to get a tft into your project, look no further than here https://retropie.org.uk/forum/topic/7464/ili9341-tft-screen-guide

                                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.