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

    Has anyone got a keyboard working for Player 2 in PiFBA?

    Scheduled Pinned Locked Moved Help and Support
    48 Posts 9 Posters 19.5k 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.
    • rbakerR
      rbaker
      last edited by

      Hello, I have a RPi2 running the latest version of Retropie but nothing I do allows me to use player two controls in PiFBA. The issue is well documented. The latest version claims to have support for configuring two players with keyboard keys but I cannot do it. Having spent a day, I give up. Anyone done it? there are suggestions about patching "gp2xsdk.cpp" but I have no idea how to do it or where it is. In the fba2xcfg, it says player 2 keyboard controls disabled by default, can they just be enabled? Thanks.

      meleuM 1 Reply Last reply Reply Quote 0
      • BuZzB
        BuZz administrators
        last edited by

        I've not tested it myself with pifba - but it will work with lr-fba-next with two keyboard inputs set up for plasyer1/player2 in /opt/retropie/configs/all/retroarch.cfg - on a rpi2 the lr-fba-next is the better emulator and supports many more games.

        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

        rbakerR TheStrayMongrelT 2 Replies Last reply Reply Quote 0
        • caver01C
          caver01
          last edited by

          I have. I use an ipac4 and I used to run pifba using the piplay distribution. I had to define my keys for player 2 in the config file for that emulator using the SDL codes, but once I did, Player 2 worked fine.

          I remember a much earlier version of pifba lacked p2 functionality, but that was fixed a while ago.

          My 4-player cocktail style cabinet built as a custom "roadcase"

          rbakerR 1 Reply Last reply Reply Quote 0
          • rbakerR
            rbaker @caver01
            last edited by

            @caver01 thanks, have you got it working in Retropie? I saw on the PiPlay forums that it was fixed a while ago but on Retropie when I alter the config, it has no effect and it still says Player 2 disabled by default. The Git Hub page says that it was fixed ages ago so I am confused as to what else to do.

            caver01C 1 Reply Last reply Reply Quote 0
            • rbakerR
              rbaker @BuZz
              last edited by

              @BuZz Thanks, I am running that emulator instead now on a Pi2 without any issues. However, I cant help but feel that the performance of some games is snappier and smoother on PiFBA so would really like to try and getting working more for me being able to really. I have seen a page about patching files but couldn't get it to work. Do you know if the current build in the Retropie image is the latest fixed one?

              1 Reply Last reply Reply Quote 0
              • caver01C
                caver01 @rbaker
                last edited by

                @rbaker hmm. Nope. I just looked for a backup copy of my old config file and didn't find it. Have you tried lr-fba-next? That's what I use now.

                My 4-player cocktail style cabinet built as a custom "roadcase"

                caver01C 1 Reply Last reply Reply Quote 0
                • caver01C
                  caver01 @caver01
                  last edited by

                  @caver01 you could try reinstalling just pifba from source.

                  My 4-player cocktail style cabinet built as a custom "roadcase"

                  rbakerR 1 Reply Last reply Reply Quote 0
                  • rbakerR
                    rbaker @caver01
                    last edited by

                    @caver01 Yes, I'm using that emulator instead with no issues. I tried the source thing from the Retropie menu for single emualtors and it made no difference to the ability to configure player 2. I could be doing something wrong but to be honest, I'm just doing it for the sake of learning. lr-fba-next is clearly the way forward as I am going to go with a Pi3 soon.

                    1 Reply Last reply Reply Quote 0
                    • meleuM
                      meleu
                      last edited by meleu

                      @rbaker I think this thread is more related with this specific issue (and we talked about it in another thread). So let me say something about it here for future references.

                      going straight to the conclusion

                      I did a research about this issue and I found out where the problem is. I made my own tests with a tweaked code, and assured myself that it works.

                      I made a Pull Request and @BuZz merged it (2016-07-15). Now, if you reinstall PiFBA from source you will have a keyboard working for 2 players (if you have a properly configured fba2x.cfg file, obviously!).

                      I think the binary will be updated soon.

                      tech info for the NERD folks

                      I was impressed with how this inconvenience was solved changing only one character in the source code! :-)

                      In the file gp2xsdk.cpp (specifically between lines 259-286) PiFBA determines how many valid joysticks are plugged to the system and store this number in the joyCount variable:

                          //We handle up to four joysticks
                          if(SDL_NumJoysticks())
                          {
                              int i;
                              SDL_JoystickEventState(SDL_ENABLE);
                              
                              for(i=0;i<SDL_NumJoysticks();i++) {
                                  joy[i]=SDL_JoystickOpen(i);
                                  
                                  //Check for valid joystick, some keyboards
                                  //aren't SDL compatible
                                  if(joy[i])
                                  {
                                      if (SDL_JoystickNumAxes(joy[i]) > 28)
                                      {
                                          SDL_JoystickClose(joy[i]);
                                          joy[i]=0;
                                          logoutput("Error detected invalid joystick/keyboard\n");
                                      }
                                      else
                                          joyCount++;
                                  }
                              }
                              if(joy[0])
                                  logoutput("Found %d joysticks\n",joyCount);
                          }
                          else
                              joyCount=1;
                      

                      As we can see in the last else, if no joysticks found, joyCount receives 1.

                      In other words: "If no joysticks found, let's pretend that we have one for player1 (and let's see if fba2x.cfg has some configs to control player1 with a keyboard)."

                      The problem is that in this scenario (no joysticks), there is no way to control player2, even if the user has a properly configured fba2x.cfg to control player2 with the same keyboard as the player1.

                      If we replace the line 286 with joyCount=2;, pifba will understand that there is a minimum of 2 players.

                      In other words: "If no joysticks found, let's pretend that we have two, for player1 and player2 (and let's see if fba2x.cfg has some configs to control player1 and player2 with a keyboard)."

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      1 Reply Last reply Reply Quote 1
                      • TheStrayMongrelT
                        TheStrayMongrel @BuZz
                        last edited by

                        @BuZz said in Has anyone got a keyboard working for Player 2 in PiFBA?:

                        I've not tested it myself with pifba - but it will work with lr-fba-next with two keyboard inputs set up for plasyer1/player2 in /opt/retropie/configs/all/retroarch.cfg - on a rpi2 the lr-fba-next is the better emulator and supports many more games.

                        Wait, waa...? Just had a sift through .../retroarch.cfg again and looks to have keyboard 2 set up and active (works okay in mame4all) but doesnt work for me in lr-fba-next. Or does this need to be edited to something bespoke @BuZz? Any help would be fantastic been trying to get this working for a good while.

                        Thanks in advance.

                        Raspberry Pi 2 B+

                        1 Reply Last reply Reply Quote 0
                        • meleuM
                          meleu
                          last edited by meleu

                          @rbaker I would like to know if now you have your keyboard working for player2 in PiFBA. I did it for you, dude! :-)

                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          rbakerR 2 Replies Last reply Reply Quote 0
                          • rbakerR
                            rbaker @meleu
                            last edited by

                            @meleu Hi, still waiting to try it because my machine is currently in school as a final week treat for the kids I teach. When the machine comes home it'll be the first thing I do! I'll let you know for sure when I do the update. Thanks.

                            1 Reply Last reply Reply Quote 1
                            • TheStrayMongrelT
                              TheStrayMongrel
                              last edited by

                              Anyone made any progress on this issue? Thanks

                              Raspberry Pi 2 B+

                              meleuM 1 Reply Last reply Reply Quote 0
                              • meleuM
                                meleu @TheStrayMongrel
                                last edited by meleu

                                @TheStrayMongrel said in Has anyone got a keyboard working for Player 2 in PiFBA?:

                                Anyone made any progress on this issue? Thanks

                                I did. I can control 2 players with only one keyboard.

                                Look here what happened:
                                https://retropie.org.uk/forum/topic/1914/has-anyone-got-a-keyboard-working-for-player-2-in-pifba/9

                                If you update your pifba from source you'll get it! ;-)

                                • Useful topics
                                • joystick-selection tool
                                • rpie-art tool
                                • achievements I made
                                TheStrayMongrelT 1 Reply Last reply Reply Quote 0
                                • TheStrayMongrelT
                                  TheStrayMongrel @meleu
                                  last edited by

                                  @meleu Ah fantastic. Sorry to ask when I'm sure is elementary to most but how do I "update pifba from source", run a shell command I assume? Thanks heaps for all the help.

                                  Raspberry Pi 2 B+

                                  meleuM 1 Reply Last reply Reply Quote 0
                                  • meleuM
                                    meleu @TheStrayMongrel
                                    last edited by

                                    @TheStrayMongrel https://github.com/retropie/retropie-setup/wiki/Updating-RetroPie

                                    • Useful topics
                                    • joystick-selection tool
                                    • rpie-art tool
                                    • achievements I made
                                    TheStrayMongrelT 2 Replies Last reply Reply Quote 0
                                    • TheStrayMongrelT
                                      TheStrayMongrel @meleu
                                      last edited by

                                      Excellent, thanks @meleu will give that a go.

                                      Raspberry Pi 2 B+

                                      1 Reply Last reply Reply Quote 0
                                      • TheStrayMongrelT
                                        TheStrayMongrel @meleu
                                        last edited by

                                        I assume this is not going to get lr-fba-next working with two players on one keyboard though @meleu ? Thats what I'm really after as SF3 and SFA wont work in piFBA.

                                        Raspberry Pi 2 B+

                                        rbakerR 1 Reply Last reply Reply Quote 0
                                        • rbakerR
                                          rbaker @TheStrayMongrel
                                          last edited by

                                          @TheStrayMongrel lr-fba-next already works on one keyboard because it's a "lr" core and therefore uses your universal retroarch config so there shouldn't be any issues.

                                          TheStrayMongrelT 2 Replies Last reply Reply Quote 0
                                          • rbakerR
                                            rbaker @meleu
                                            last edited by

                                            @meleu I just updated from Source but no luck for me. Any chance you could post your fba2x.cfg? Here is mine:

                                            [Keyboard]
                                            # Get codes from /usr/include/SDL/SDL_keysym.h
                                            A_1=306
                                            B_1=32
                                            X_1=308
                                            Y_1=120
                                            L_1=122
                                            R_1=304
                                            START_1=49
                                            SELECT_1=53
                                            LEFT_1=276
                                            RIGHT_1=275
                                            UP_1=273
                                            DOWN_1=274
                                            QUIT=27
                                            #player 2 keyboard controls, disabled by default
                                            A_2=97
                                            B_2=115
                                            X_2=113
                                            Y_2=107
                                            L_2=105
                                            R_2=119
                                            START_2=114
                                            SELECT_2=102
                                            LEFT_2=100
                                            RIGHT_2=103
                                            UP_2=114
                                            DOWN_2=102
                                            

                                            Player 1 works perfectly. Am I missing something when deciding on codes from SDL_keysym.h?

                                            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.