Navigation

    ViGEm Forums

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Twitter
    • GitHub
    • Discord

    Controlling DS4 input programmatically (PC)

    Discussion and Support
    3
    30
    1782
    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.
    • nefarius
      nefarius @Harry last edited by

      @harry said in Controlling DS4 input programmatically (PC):

      All calls but one seem to be working fine. Specifically, VIGEM_API BOOL vigem_target_is_attached(PVIGEM_TARGET target); never returns true, even when the target is actually attached and I can send reports to it. Perhaps I got the API wrong?

      Oh? That's odd, it's expected to return TRUE when the bus has brought it to working stage. This application uses the API so I suspect it to function properly 🤔

      @harry said in Controlling DS4 input programmatically (PC):

      Isn't that API call supposed to be used right after a vigem_target_add call (with polling for instance) to ensure that the device is attached before starting to send reports?

      vigem_target_add is blocking until the device is truly operational and calling vigem_target_is_attached afterwards is expected to return TRUE.

      Cheers

      H 1 Reply Last reply Reply Quote 0
      • nefarius
        nefarius last edited by

        See this line especially.

        1 Reply Last reply Reply Quote 0
        • H
          Harry @nefarius last edited by Harry

          @nefarius said in Controlling DS4 input programmatically (PC):

          @harry said in Controlling DS4 input programmatically (PC):

          All calls but one seem to be working fine. Specifically, VIGEM_API BOOL vigem_target_is_attached(PVIGEM_TARGET target); never returns true, even when the target is actually attached and I can send reports to it. Perhaps I got the API wrong?

          Oh? That's odd, it's expected to return TRUE when the bus has brought it to working stage. This application uses the API so I suspect it to function properly 🤔

          In fact, I used that code as a reference and I was expecting it to work like you described, but it didn't. Everything else is working fine. I've actually integrated it with some tools that I have and it works like a charm.

          Hats off to you sir! You've done an excellent job 🙂

          I'll try that specific API again, see if I did something wrong in the first place.

          nefarius 1 Reply Last reply Reply Quote 0
          • nefarius
            nefarius @Harry last edited by

            @harry said in Controlling DS4 input programmatically (PC):

            Hats off to you sir! You've done an excellent job

            Years of stealing studying other peoples C/C++ code got me there, and for my first real public API it's surprisingly solid and even considers backwards compatibility, the wet dream of every Windows developer 😛

            But thanks, appreciate it.

            If it still bombs for whatever reason maybe we can spin up a quick debugging session; I'm always on the bug-hunt 🔫

            1 Reply Last reply Reply Quote 0
            • H
              Harry last edited by Harry

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • B
                BOCS last edited by

                Had to signup to thank you for this...

                within 20 minutes, I had it installed and sending buttons to remote play.

                then...
                Used a real xbox one controller with xinput, and mapped all the controls.

                now have a nice little app to let you use remote play with an xbox controller, without having a real PS4 controller plugged in.

                1 Reply Last reply Reply Quote 1
                • B
                  BOCS last edited by

                  ran into a problem...

                  I can't get the trigger buttons to work.

                  tried all the combos below:

                  report.SetAxis(DualShock4Axes.RightTrigger, 255);
                  report.RightTrigger = 255;
                  report.SetButtonState(DualShock4Buttons.TriggerRight, true);

                  all the other buttons work flawless...so IDK

                  some info:
                  Windows 10 1809 - 17763.348
                  PS4 Pro 6.50
                  Driver 1.14.3.0 (untouched and signed by you)

                  I really don't know if it worked a few days ago before the PS4 updated to 6.5

                  any idea?

                  1 Reply Last reply Reply Quote 0
                  • B
                    BOCS last edited by

                    made a new test app...
                    winform + timer
                    https://pastebin.com/Tw2dV7as

                    Quick map of keyboard WSAD + numpad to test trigger.

                    triggers do work local, but remote play doesn't...

                    ran a game I know uses PS4 controllers local(axiom verge) + remote play.
                    video here:
                    Youtube Video

                    notice the stick movement works on both..but when I "press" the trigger
                    *axiom verge works (laser) (local)
                    *remote play not working(diablo) should shot out 360 knifes

                    1 Reply Last reply Reply Quote 0
                    • B
                      BOCS last edited by

                      I figured it out!

                      Checked the windows controller settings and noticed these 2 buttons didn't light up on my emulated controller.
                      *did light up on a real controller

                      alt text

                      added the following code:

                              byte lt = XtoP2(xbox.Triggers.Left);//convert float (0-1) to byte (0-255)
                              byte rt = XtoP2(xbox.Triggers.Right);
                      
                              report.LeftTrigger = lt;
                              report.RightTrigger = rt;
                      
                              if (lt > 0)
                                  report.SetButtonState(DualShock4Buttons.TriggerLeft, true);
                              else
                                  report.SetButtonState(DualShock4Buttons.TriggerLeft, false);
                      
                              if (rt > 0)
                                  report.SetButtonState(DualShock4Buttons.TriggerRight, true);
                              else
                                  report.SetButtonState(DualShock4Buttons.TriggerRight, false);
                      

                      working now.

                      didn't realize triggers have an axis and button assigned to the same button.

                      nefarius 1 Reply Last reply Reply Quote 0
                      • nefarius
                        nefarius @BOCS last edited by

                        @BOCS Cool! That needs documentation then I guess 😅

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post