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

    Changing Xbox driver based off game

    Scheduled Pinned Locked Moved Help and Support
    xboxdrvparsecxpadxbox controllerxbox one
    7 Posts 3 Posters 967 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.
    • ?
      A Former User
      last edited by

      Pi Model or other hardware: (B, B+, 2 B, 3, X86 PC etc..): 3B
      Power Supply used: Canakit
      RetroPie Version Used (eg 3.6, 3.8.1, 4.1 - do not write latest): 4.4
      Built From: Pre-made SD
      USB Devices connected: Corsair Keyboard
      Controller used: Xbox One S Wired

      This is more of a setup question rather than an issue, but I currently have Parsec for Raspberry Pi installed on the Pi. I then created a new "Emulator" called Parsec that has a bash file in it calling the command parsec server_id=MY_SERVER_ID with MY_SERVER_ID being my actual server id.

      The part above isn't an issue, since it loads into the Parsec server fine, but the issue is with mapping the Xbox controller. Since, by default, xpad is used for mapping, it leads to weird effects. For example, the Right Trigger maps to the start button and left and right on the right stick correspond to up and down on the right stick.

      I have looked at html5gamepad to see what the computer was receiving and noticed that it kept the xpad driver where the triggers are marked as buttons and it's missing two axes. So, I wanted to see if there way any way to virtually 'reconnect' the devices using a different driver (specifically the xboxdrv) only when running a specific game.

      Thanks ahead of time!

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User
        last edited by

        Or, if it's possible, could you temporarily disable the xpad flag to treat triggers as buttons?

        mituM 1 Reply Last reply Reply Quote 0
        • mituM
          mitu Global Moderator @A Former User
          last edited by mitu

          @aditkrator You can use the triggers_to_buttons module parameters to control this. Edit /etc/modprobe.d/xpad.conf and replace

          triggers_to_buttons=1
          

          with

          triggers_to_buttons=0
          

          then reboot to see if it takes effect. This will globally change the driver behavior.
          If you want to do it only for some games, then use the onstart/onend scripts of the Runcommand script and load the driver with the desired parameters

          # Unload the driver
          sudo rmmod xpad
          
          # a) Disable the triggers as buttons
          sudo modprobe xpad triggers_to_buttons=0
          
          # OR, b) enable it
          sudo modprobe xpad triggers_to_buttons=1
          
          ? 1 Reply Last reply Reply Quote 0
          • ?
            A Former User @mitu
            last edited by

            @mitu Would something like this under ~/Retropie/roms/parsec/parsec.sh work?

            sudo rmmod xpad
            sudo modprobe xpad triggers_to_buttons=0
            sudo insmod xpad
            
            parsec server_id=MY_SERVER_ID
            
            sudo rmmod xpad
            sudo modprobe xpad triggers_to_buttons=1
            sudo insmod xpad
            
            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @A Former User
              last edited by

              @aditkrator Should work, but ditch the insmod commands, the driver is loaded through modprobe already.

              ? 1 Reply Last reply Reply Quote 0
              • ?
                A Former User @mitu
                last edited by A Former User

                @mitu Thanks for the help! Sorry -- I suck with Linux. I'm going to try out your fix to updating xpad as soon as I finish this so I can isolate different issues.

                Edit 1: Hmm, sudo modprobe xpad triggers_to_buttons=0 doesn't seem to change /etc/modprobe.d/xpad.conf/, it leaves xpad triggers_to_buttons=1.

                1 Reply Last reply Reply Quote 0
                • S
                  spud11
                  last edited by

                  @aditkrator said in Changing Xbox driver based off game:

                  Parsec for Raspberry Pi

                  I hadn't heard of Parsec, but it looks like something similar to Moonlight, which I use (or did use, but ever since I updated to RetroPie 4.4 I can't seem to get it to work). I have quite a few individual bash scripts that invoke xboxdrv and then start moonlight and then individual games, so it can be done:

                  sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
                  --silent \
                  --detach-kernel-driver \
                  --deadzone=4000 \
                  --deadzone-trigger 15% \
                  --force-feedback \
                  --mimic-xpad \
                  --trigger-as-button \
                  --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
                  --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.2:1.0-event-joystick \
                  --device-name "Player_1" \
                  --evdev-absmap ABS_X=x1,ABS_Y=y1 \
                  --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
                  --ui-axismap X1=KEY_DOWN:KEY_UP,Y1=KEY_RIGHT:KEY_LEFT \
                  --ui-buttonmap a=KEY_Z,b=KEY_E,x=KEY_X,y=KEY_Q,back=KEY_SPACE,start=KEY_ENTER \
                  --ui-buttonmap back+start=cycle-key:KEY_ESC:KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_LEFTALT+KEY_Q \
                  &
                  sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
                  --silent \
                  --detach-kernel-driver \
                  --deadzone=4000 \
                  --deadzone-trigger 15% \
                  --force-feedback \
                  --mimic-xpad \
                  --trigger-as-button \
                  --ui-buttonmap rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
                  --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.4:1.0-event-joystick \
                  --device-name "Player_2" \
                  --evdev-absmap ABS_X=x1,ABS_Y=y1 \
                  --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_BASE=lb,BTN_THUMB2=back,BTN_TOP2=start \
                  --ui-axismap X1=KEY_F:KEY_R,Y1=KEY_G:KEY_D \
                  --ui-buttonmap a=KEY_S,b=KEY_P,x=KEY_A,y=KEY_W,back=KEY_J,start=KEY_H \
                  --ui-buttonmap back+start=cycle-key:KEY_ESC:KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_LEFTALT+KEY_Q \
                  &
                  sudo /opt/retropie/emulators/moonlight/moonlight stream -bitrate 5000 -audio local -720 -fps 30 192.168.0.5 -app "UnderDefeat"
                  moonlight quit 192.168.0.5
                  sudo killall > /dev/null 2>&1 xboxdrv
                  

                  The above script invokes xboxdrv, maps out 2 of my joysticks as against keyboard inputs and then starts moonlight and, ultimately, the game Under Defeat via an emulator on my Windows 7 based PC.

                  RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                  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.