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

    How to use Joystick as a mouse? Ports Edition.

    Scheduled Pinned Locked Moved Help and Support
    portsfallout 2gamepadmousejoystick
    25 Posts 6 Posters 1.8k 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.
    • S
      sleve_mcdichael @PiBoyyy
      last edited by

      @PiBoyyy it works on everything, as far as I know. I'm using it with a Logitech.

      1 Reply Last reply Reply Quote 0
      • F
        Fenderus @sleve_mcdichael
        last edited by Fenderus

        @sleve_mcdichael So from a generic controller, to a Virtual XBox 360 controller, to a mouse? Is that possible? And also, can you give an example of the runcommand-onstart.sh for mouse mapping?

        AshpoolA ExarKunIvE S 3 Replies Last reply Reply Quote 0
        • AshpoolA
          Ashpool @Fenderus
          last edited by Ashpool

          @Fenderus Ok, it is late & maybe I should have avoided to post right now...

          Edit: And I should have... ok, 3 minutes past & I cannot delete it... so please ignore this post!

          1 Reply Last reply Reply Quote 0
          • ExarKunIvE
            ExarKunIv @Fenderus
            last edited by

            @Fenderus yes if it puts out a key press. It should be able to be mapped.

            I'm 99% sure it will work. But I'm not going to say 100% since all the controllers I have used xboxdrv with have been a 8bitdo.

            But but when I was first learning how to use Xbox drv there were people asking questions about using dragon controls for arcade style sticks and they were able to get it to work so I would think your controller also will work

            RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
            RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
            Maintainer of RetroPie-Extra .

            1 Reply Last reply Reply Quote 0
            • S
              sleve_mcdichael @Fenderus
              last edited by

              @Fenderus said in How to use Joystick as a mouse? Ports Edition.:

              also, can you give an example of the runcommand-onstart.sh for mouse mapping?

              For example, here is the mapping I use for Jedi Outcast:

              sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                  --evdev /dev/input/by-id/usb-Logitech_Wireless_Gamepad_F710_C1A591C5-event-joystick \
                  --silent \
                  --detach-kernel-driver \
                  --force-feedback \
                  --deadzone-trigger 15% \
                  --deadzone 1000 \
                  --device-name "OpenJK-JO Virtual Mouseboard" \
                  --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                  --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start \
                  --axismap -Y1=Y1,-Y2=Y2 \
                  --ui-axismap x1=KEY_A:KEY_D,y1=KEY_W:KEY_S,x2=REL_X:16,y2=REL_Y:16 \
                  --ui-buttonmap a=KEY_SPACE,b=KEY_C,x=KEY_E,y=KEY_F,lt=BTN_RIGHT,rt=BTN_LEFT,lb=REL_WHEEL:1:150,rb=REL_WHEEL:-1:150,tl=KEY_ENTER,tr=KEY_L,dl=KEY_Z,dr=KEY_X,du=KEY_LEFTBRACE,dd=KEY_RIGHTBRACE,guide=KEY_M,back=KEY_TAB,start=KEY_ESC \
                  &
              
              S F 2 Replies Last reply Reply Quote 0
              • S
                sleve_mcdichael @sleve_mcdichael
                last edited by

                @Fenderus the mouse-to-gamepad mappings are here at:

                    --ui-axismap (...),x2=REL_X:16,y2=REL_Y:16 \
                    --ui-buttonmap (...),lt=BTN_RIGHT,rt=BTN_LEFT,lb=REL_WHEEL:1:150,rb=REL_WHEEL:-1:150,(...) \
                

                (This puts the mouse movement, buttons, and wheel onto gamepad right stick, triggers, and bumpers.)

                1 Reply Last reply Reply Quote 0
                • F
                  Fenderus @sleve_mcdichael
                  last edited by

                  @sleve_mcdichael Is there like a way to run it on a specific Port, like when I run Fallout 2, it says on the Booting screen that:

                  Launching fallout2
                  

                  Which maybe I can use for this maybe in the file?:

                  if [ "$1" = "scummvm" ]
                  then
                  sudo killall >> /dev/shm/runcommand.log 2>&1 xboxdrv
                  

                  I found this on the Official Retropie Guide.

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    sleve_mcdichael @Fenderus
                    last edited by sleve_mcdichael

                    @Fenderus said in How to use Joystick as a mouse? Ports Edition.:

                    @sleve_mcdichael Is there like a way to run it on a specific Port,

                    Yeah so here is my runcommand_onstart.sh (excerpt):

                    # $1 = system, $2 = emulator, $3 = rompath, $4 = command
                    [[ -f "/opt/retropie/configs/all/xboxdrv/$1.xbd" ]] && bash "/opt/retropie/configs/all/xboxdrv/$1.xbd" #xbd
                    

                    ...so then, the mapping I posted earlier goes into a file called for example jedioutcast.xbd and so whenever the system (port) jedioutcast is ran (you would call yours fallout2.xbd with this scheme), the mapping is loaded at start.

                    runcommand-onend.sh then kills the process and restores the default gamepad mapping with:

                    pgrep xboxdrv >/dev/null && sudo killall xboxdrv >> /dev/shm/runcommand.log 2>&1 #xbd
                    

                    (In the guide, they kill the custom xboxdrv mapping and then restart a "default" one -- I don't use a default one, it's just for the special cases, so I just kill any that are found at end and don't start any new one.)

                    ExarKunIvE F 2 Replies Last reply Reply Quote 0
                    • ExarKunIvE
                      ExarKunIv @sleve_mcdichael
                      last edited by

                      @sleve_mcdichael said in How to use Joystick as a mouse? Ports Edition.:

                      [[ -f "/opt/retropie/configs/all/xboxdrv/$1.xbd" ]] && bash "/opt/retropie/configs/all/xboxdrv/$1.xbd" #xbd

                      how does that work?

                      i use a more direct way, but as i have comes to expect from you, your way it way cleaner

                      RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
                      RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
                      Maintainer of RetroPie-Extra .

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        sleve_mcdichael @ExarKunIv
                        last edited by

                        @ExarKunIv said in How to use Joystick as a mouse? Ports Edition.:

                        how does that work?

                        [[ -f "/opt/retropie/configs/all/xboxdrv/$1.xbd" ]] && bash "/opt/retropie/configs/all/xboxdrv/$1.xbd" #xbd

                        "[[ If there's a file in the specified location called '[system].xbd` (where `[system]` matches the system being launched) ]], && then execute the contents of that file using bash interpreter. #identifying mark indicates the purpose of this line."

                        ExarKunIvE 1 Reply Last reply Reply Quote 0
                        • ExarKunIvE
                          ExarKunIv @sleve_mcdichael
                          last edited by

                          @sleve_mcdichael i thought that's now it might work, thanks for verifying that

                          RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
                          RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
                          Maintainer of RetroPie-Extra .

                          1 Reply Last reply Reply Quote 0
                          • F
                            Fenderus @sleve_mcdichael
                            last edited by Fenderus

                            @sleve_mcdichael Should I replace $1

                            # $1 = system, $2 = emulator, $3 = rompath, $4 = command
                            [[ -f "/opt/retropie/configs/all/xboxdrv/$1.xbd" ]] && bash "/opt/retropie/configs/all/xboxdrv/$1.xbd" #xbd
                            
                            

                            with fallout2?

                            And write this:

                            pgrep xboxdrv >/dev/null && sudo killall xboxdrv >> /dev/shm/runcommand.log 2>&1 #xbd
                            

                            onto the runcommand-onend.sh file?

                            S 1 Reply Last reply Reply Quote 0
                            • S
                              sleve_mcdichael @Fenderus
                              last edited by

                              @Fenderus said in How to use Joystick as a mouse? Ports Edition.:

                              Should I replace $1
                              with fallout2?

                              No, keep it as the variable $1; then, the fallout mapping file will be loaded when you play fallout, the (for example) doom file will be loaded when you play doom, and etc.

                              F 2 Replies Last reply Reply Quote 0
                              • F
                                Fenderus @sleve_mcdichael
                                last edited by Fenderus

                                @sleve_mcdichael problem is, does the lxde desktop get involved, since it is a port? And how about the void things like:

                                --ui-buttonmap guide=void,x=void,y=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void \
                                --ui-axismap x2=void \
                                

                                Is it important?

                                S 1 Reply Last reply Reply Quote 0
                                • F
                                  Fenderus @sleve_mcdichael
                                  last edited by

                                  @sleve_mcdichael Also, the game isn't launching, maybe because there is no fi on the runcommad files

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    sleve_mcdichael @Fenderus
                                    last edited by

                                    @Fenderus said in How to use Joystick as a mouse? Ports Edition.:

                                    @sleve_mcdichael problem is, does the lxde desktop get involved, since it is a port?

                                    No.

                                    And how about the void things like:

                                    --ui-buttonmap guide=void,x=void,y=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void \
                                    --ui-axismap x2=void \
                                    

                                    Is it important?

                                    You can "void" an input if you don't want it to do anything not even its original function.

                                    Also, the game isn't launching, maybe because there is no fi on the runcommad files

                                    Maybe cause what? I don't understand what you mean but you can check for any errors reported in the runcommand.log file.

                                    If you're talking about the runcommand onstsrt/onend scripts, please post the entire contents in a

                                    ```
                                    code block
                                    with three back-ticks
                                    before and after
                                    ```
                                    

                                    (Or upload to pastebin.com if it is very large and share the link here.)

                                    F 1 Reply Last reply Reply Quote 0
                                    • F
                                      Fenderus @sleve_mcdichael
                                      last edited by

                                      @sleve_mcdichael Yeah, I meant the run command on-start and on-end files, also the #!/bin/sh in the two files came from the official guide (https://retropie.org.uk/docs/Universal-Controller-Calibration-%26-Mapping-Using-xboxdrv/)

                                      My run command on start (Copied from your Suggestions):

                                      #!/bin/sh
                                      [[ -f "/opt/retropie/configs/all/xboxdrv/$1.xbd" ]] && bash "/opt/retropie/configs/all/xboxdrv/$1.xbd" #xbd
                                      

                                      My run command on end (Copied from your Suggestions):

                                      #!/bin/sh
                                      pgrep xboxdrv >/dev/null && sudo killall xboxdrv >> /dev/shm/runcommand.log 2>&1 #xbd
                                      

                                      Anf my Fallout 2 xbd file:

                                      sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                          --evdev /dev/input/event0
                                          --silent \
                                          --detach-kernel-driver \
                                          --force-feedback \
                                          --deadzone-trigger 15% \
                                          --deadzone 1000 \
                                          --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                                          --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start \
                                          --axismap -Y1=Y1,-Y2=Y2 \
                                          --ui-axismap x1=REL_X:16,y1=REL_Y:16 \
                                          --ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT,x=KEY_RETURN,y=KEY_ESC,tl=BTN_RIGHT,tr=BTN_LEFT,start=KEY_ESC \
                                          &
                                      
                                      S 1 Reply Last reply Reply Quote 0
                                      • S
                                        sleve_mcdichael @Fenderus
                                        last edited by sleve_mcdichael

                                        @Fenderus

                                        --evdev /dev/input/event0
                                        

                                        Missing a \ backslash here, could that sort you out?

                                        F 2 Replies Last reply Reply Quote 0
                                        • F
                                          Fenderus @sleve_mcdichael
                                          last edited by Fenderus

                                          @sleve_mcdichael It launched normally, but the controls did not work.

                                          Also, does /dev/input/by-id/ exist when there are multiple controllers? Because the directory didn't exist when I typed:

                                          ls /dev/input/by-id/
                                          
                                          1 Reply Last reply Reply Quote 0
                                          • F
                                            Fenderus @sleve_mcdichael
                                            last edited by

                                            @sleve_mcdichael Found the Problem, apparently, I don't know what the ENTER key is, found the problem on the /dev/shm/runcommand.log file:

                                            fallout2
                                            fallout2
                                            
                                            /opt/retropie/ports/fallout2/fallout2.sh
                                            xboxdrv: no process found
                                            
                                            -- [ ERROR ] ------------------------------------------------------
                                            error: invalid argument '--ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT,x=KEY_RETURN,y=K$couldn't convert 'KEY_RETURN' to enum, not a member of EV_KEY
                                            
                                            Parameters:
                                            Executing: /opt/retropie/ports/fallout2/fallout2.sh
                                            
                                            N 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.