Question Regarding the Device Api (gpcapi.dll)

Gtuner Plugins support. MaxAim, MaxRemapper, Combo Magick, Game Rec.

Question Regarding the Device Api (gpcapi.dll)

Postby awwwwwjay » Fri Sep 22, 2017 8:51 am

I'll try to keep it quick!
I know the MaxAimDI does some trickery to run a script and do its own thing.

I was wondering how they do this? From the documentation, all it says you can do is write to an output array saying what the state of the axis/buttons are, that get sent to the console. Both interfacing as a plugin OR as in my case, interfacing via the gpcapi.dll, you end up doing just that. That said, just writing to the 36 size output array means plugins and apps can't make the controller rumble.

Originally I intended to write data to the TRACE variables and have a script device side that would wait for the signal and make a rumble request there, however, since you can't run a script AND have a plugin interfacing at the same time, that got shot down fairly quick.

I'm REALLY curious as to how MaxAimDI manages to load a script AND do its own thing (which I assume means it also can write with gcapi_Write provided by the callback pointer given in the gpp_Load.

In short, is there ANY way to make the controller rumble with the device API?

If you read this far I guess I can say for what I'm aiming to do.
I wrote an app that recognizes gestures the player inputs on the PS4's touchpad to trigger combos and such. I'd like a rumble to provide feedback to let the player know the gesture was recognized and fired off.

Anyways, thanks!
User avatar
awwwwwjay
Corporal
Corporal
 
Posts: 4
Joined: Fri Sep 22, 2017 8:41 am

Re: Question Regarding the Device Api (gpcapi.dll)

Postby J2Kbr » Fri Sep 22, 2017 3:54 pm

awwwwwjay wrote:In short, is there ANY way to make the controller rumble with the device API?

The output with 36 bytes in size has only the button states, as you already know how it works. It is possible to send an output with size of 52 - 16 extra bytes prepended, so the regular output starts at index 16. this extra data can be set to send "commands" to the device and controller, such as set the LEDs, rumble and even turn off the controller. Below is an excerpt from the MaxAim DI source code from which you can learn how this works. Having any doubts, please let me know.
Code: Select all
#define        INSTATE_LEDUPD            2
#define        INSTATE_LED1            3
#define        INSTATE_LED2            4
#define        INSTATE_LED3            5
#define        INSTATE_LED4            6
#define        INSTATE_RESETLEDS        7
#define        INSTATE_RUMBLEUPD        8
#define        INSTATE_RUMBLE1            9
#define        INSTATE_RUMBLE2            10
#define        INSTATE_RUMBLE3            11
#define        INSTATE_RUMBLE4            12
#define        INSTATE_RESETRUMBLE        13
#define        INSTATE_RUMBLEBLOCK        14
#define        INSTATE_TURNOFF            15

Code: Select all
    outpacket[0] = 0xFF;
    outpacket[1] = 0x01;
    if(gpvm_pnsin->ledUpd) {
        outpacket[INSTATE_LEDUPD] = 1;
        outpacket[INSTATE_LED1] = gpvm_pnsin->led[0];
        outpacket[INSTATE_LED2] = gpvm_pnsin->led[1];
        outpacket[INSTATE_LED3] = gpvm_pnsin->led[2];
        outpacket[INSTATE_LED4] = gpvm_pnsin->led[3];
        gpvm_pnsin->ledUpd = false;
    } else outpacket[INSTATE_LEDUPD] = 0;
    if(gpvm_pnsin->resetleds) {
        outpacket[INSTATE_RESETLEDS] = 1;
        gpvm_pnsin->resetleds = false;
    } else outpacket[INSTATE_RESETLEDS] = 0;
    if(gpvm_pnsin->rumbleUpd) {
        outpacket[INSTATE_RUMBLEUPD] = 1;
        outpacket[INSTATE_RUMBLE1] = gpvm_pnsin->rumble[0];
        outpacket[INSTATE_RUMBLE2] = gpvm_pnsin->rumble[1];
        outpacket[INSTATE_RUMBLE3] = gpvm_pnsin->rumble[2];
        outpacket[INSTATE_RUMBLE4] = gpvm_pnsin->rumble[3];
        gpvm_pnsin->rumbleUpd = false;
    } else outpacket[INSTATE_RUMBLEUPD] = 0;
    if(gpvm_pnsin->resetrumble) {
        outpacket[INSTATE_RESETRUMBLE] = 1;
        gpvm_pnsin->resetrumble = false;
    } else outpacket[INSTATE_RESETRUMBLE] = 0;
    if(gpvm_pnsin->rumbleBlockUpd) {
        outpacket[INSTATE_RUMBLEBLOCK] = 1;
        gpvm_pnsin->rumbleBlockUpd = false;
    } else outpacket[INSTATE_RUMBLEBLOCK] = 0;
    if(gpvm_pnsin->turnOff) {
        outpacket[INSTATE_TURNOFF] = 1;
        gpvm_pnsin->turnOff = false;
    } else outpacket[INSTATE_TURNOFF] = 0;

awwwwwjay wrote:I wrote an app that recognizes gestures the player inputs on the PS4's touchpad to trigger combos and such. I'd like a rumble to provide feedback to let the player know the gesture was recognized and fired off.

Awesome!! Please keep us updated on your project. :smile0517:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Question Regarding the Device Api (gpcapi.dll)

Postby awwwwwjay » Sat Sep 23, 2017 2:48 am

Wow, I don't think I've ever had such a reply as perfect as that on any forum I have ever posted a question on.
Thank you so much!
I'll try it out when I get back home.
You really broke new ground for me, every question I've ever asked on a forum, I ended up sighing going why bother with asking.
The next thing I end up naming I will name after your forum name
User avatar
awwwwwjay
Corporal
Corporal
 
Posts: 4
Joined: Fri Sep 22, 2017 8:41 am

Re: Question Regarding the Device Api (gpcapi.dll)

Postby J2Kbr » Mon Sep 25, 2017 6:49 pm

Thank you for your message and you are welcome!! :joia:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Question Regarding the Device Api (gpcapi.dll)

Postby awwwwwjay » Tue Oct 03, 2017 11:48 pm

Hey, sorry for the late reply, I got around to trying it, but I was running into an issue.
The moment I used the prepended array, the rumble works but then for some reason buttons start firing off left and right for no reason

Below you can see the changes I made to try and test out getting the controller to rumble.
if I just write the output state (outputState/36 byte array) it works fine like as before
when I prepend the 16 byte array, creating a merged 52 bye array, and wrote those weird commands in indices 0 and 1
(0xFF and 0x1)

That's where random stuff starts happening. The controller will rumble when I set _doRumble to true, BUT when I look at what the device is sending to the console, it looks like this:

Image

As you can see PS4 square and the values onwards get all jumbles with random data. I counted the number of buttons that get jumbled and it adds up to 16, which I doubt is a coincidence. I must be doing something wrong. Is the code in the .dll reading past the array into random memory? Anyway, I don't wanna add to much noise, so here's the code below. I'll wait for your reply, if you need anything else from me. Thanks!


Code: Select all
                    outputStatePrepend[0] = -1;
                    outputStatePrepend[1] = 1;

                    if (_doRumble)
                    {
                        outputStatePrepend[GCMAPIConstants.INSTATE_RUMBLEUPD] = 1;
                        outputStatePrepend[GCMAPIConstants.INSTATE_RUMBLE1] = 50;
                        outputStatePrepend[GCMAPIConstants.INSTATE_RUMBLE2] = 50;
                        outputStatePrepend[GCMAPIConstants.INSTATE_RUMBLE3] = 50;
                        outputStatePrepend[GCMAPIConstants.INSTATE_RUMBLE4] = 50;
                        _doRumble = false;
                    }
                    var mergedArray = new sbyte[outputState.Length + outputStatePrepend.Length];
                    for (var i = 0; i < outputStatePrepend.Length; i++)
                    {
                        mergedArray[i] = outputStatePrepend[i];
                    }
                    for (var i = 0; i < outputState.Length; i++)
                    {
                        mergedArray[i + outputStatePrepend.Length] = 0;
                        //mergedArray[i + outputStatePrepend.Length] = outputState[i];
                    }
                    _Write(mergedArray);
User avatar
awwwwwjay
Corporal
Corporal
 
Posts: 4
Joined: Fri Sep 22, 2017 8:41 am

Re: Question Regarding the Device Api (gpcapi.dll)

Postby J2Kbr » Wed Oct 04, 2017 6:02 pm

Just checking, are you using the latest version of the gcdapi.dll? you can download it from here:

https://www.consoletuner.com/kbase/device_api.htm
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Question Regarding the Device Api (gpcapi.dll)

Postby awwwwwjay » Wed Oct 04, 2017 11:27 pm

Hey, I went ahead and tried using the latest .dll
Same results.
However, I was using the DS4 with bluetooth, so I went ahead and removed the dongle from the Titan device, connected it to USB directly, reset the speed settings in the GTuner app to default. Then tried again.
Now most of the buttons work except a few. I can trigger the rumble, but like the PS4 home button no longer works along with square.
What's worse is if I bring up the Device Monitor in GTuner it goes back to haywire mode, where all the buttons starts firing off and go crazy.

Are there any settings I should be aware of?

Also, I'm using the C# Wrapper that you guys have linked on the website, for further info
User avatar
awwwwwjay
Corporal
Corporal
 
Posts: 4
Joined: Fri Sep 22, 2017 8:41 am

Re: Question Regarding the Device Api (gpcapi.dll)

Postby J2Kbr » Sun Oct 08, 2017 7:08 pm

I believe what is causing the "buttons starts firing off and go crazy" is the concurrence between Gtuner and gcdapi.dll on access the device. To be able to use the Device Monitor along your application, please use the plugin API. The direct API is not supposed to be used with Gtuner running.

When you described that "Now most of the buttons work except a few.", this means the action your application is sending to the console, or your application is not able to detect some buttons status from the connected controller. Please clarify this and also list the button that are not working, thank you.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to Gtuner Plugins Support

Who is online

Users browsing this forum: No registered users and 66 guests