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 20.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.
    • 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
                              • TheStrayMongrelT
                                TheStrayMongrel @rbaker
                                last edited by

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

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

                                Hmm okay, will have to look further into it. Might have ballsed it up by using the Adafruit keyboard utility from the start.

                                Raspberry Pi 2 B+

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

                                  Hey @rbaker, could you see any reason this wouldnt work?

                                  Raspberry Pi 2 B+

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

                                    @TheStrayMongrel Pretty similar to mine, so it should work:

                                    # Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely, 
                                    # rather than relying on a default.
                                    input_player1_a = "alt"
                                    input_player1_b = "ctrl"
                                    input_player1_y = "space"
                                    input_player1_x = "x"
                                    input_player1_start = "num1"
                                    input_player1_select = "num5"
                                    input_player1_l = null
                                    input_player1_r = null
                                    input_player1_left = "left"
                                    input_player1_right = "right"
                                    input_player1_up = "up"
                                    input_player1_down = "down"
                                    
                                    input_player2_a = "s"
                                    input_player2_b = "a"
                                    input_player2_y = "q"
                                    input_player2_x = "k"
                                    input_player2_start = "num2"
                                    input_player2_select = "num6"
                                    input_player2_l = null
                                    input_player2_r = null
                                    input_player2_left = "d"
                                    input_player2_right = "g"
                                    input_player2_up = "r"
                                    input_player2_down = "f"
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • meleuM
                                      meleu @rbaker
                                      last edited by

                                      @rbaker
                                      I tested with this file:
                                      https://raw.githubusercontent.com/RetroPie/pifba/76ef8cc7c093db4c1150e4e1eeee24f860f53935/fba2x.cfg.template

                                      Do you have 2 controllers? If so, try to start pifba with the keyboard AND two or more controllers plugged. Ignore the controllers and test two players on keyboard.

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

                                        @meleu Thanks!

                                        ok, so I tried this:

                                        Start PiFBA with keyboard in AND IPac connected. P1 disabled on Keyboard - only IPac works!

                                        then

                                        Remove IPac and use only Keyboard for everything. Only P1 works and pressing zero brings up FPS! Pressing 5 to start P2 does nothing. I configured the keyboard using Autodetect and have not configured anything else. I used the template but no player 2. I updated from Source. Next I'm going to try a fresh install.

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

                                          This post is deleted!
                                          1 Reply Last reply Reply Quote 0
                                          • rbakerR
                                            rbaker @meleu
                                            last edited by rbaker

                                            @meleu Thanks! I got it going! At last! I updated from Source a second time and it worked great. No idea why the first time didn't work though. Thank you for your assistance, it's another problem ticked off for me. Does pressing Zero insert a coin AND display FPS for you too?

                                            meleuM 1 Reply Last reply Reply Quote 1
                                            • 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.