nefarius / ViGEmClient

ViGEm Client SDK for feeder development.
https://docs.nefarius.at/projects/ViGEm/
MIT License
134 stars 65 forks source link

diffrent process access gamepad #14

Closed zhaokaixs closed 3 years ago

zhaokaixs commented 3 years ago

Process A: Create gamepad Process B: Access gamepad and Update state

Can I do this?

nefarius commented 3 years ago

Nope, this is not allowed by design so no other processes can "hijack" your emulated devices. There is no setting to allow it, it's baked into the driver concept.

zhaokaixs commented 3 years ago

Nope, this is not allowed by design so no other processes can "hijack" your emulated devices. There is no setting to allow it, it's baked into the driver concept.

i change source

void vigem_target_set_index(PVIGEM_TARGET target, ULONG index)
{
    target->SerialNo = index;
}

int main()
{

        PVIGEM_CLIENT           client,client1;
    PVIGEM_TARGET           target,target1;
    target = vigem_target_x360_alloc();
    target1 = vigem_target_x360_alloc();

    client = vigem_alloc();
    client1 = vigem_alloc();
    const auto retval = vigem_connect(client);
    if (!VIGEM_SUCCESS(retval))
    { 
        return false;
    }
    const auto retval1 = vigem_connect(client1);
    if (!VIGEM_SUCCESS(retval1))
    {
        return false;
    }
    vigem_target_add(client, target);
    vigem_target_set_index(target1,1);

    for (;;)
    {
        XUSB_REPORT x;
        x.wButtons = 0x4000;
        vigem_target_x360_update(client1, target1, x);
        Sleep(500);
    }
}

it's work well~

nefarius commented 3 years ago

Well, if you execute it like the snippet describes it's still in the same process so you didn't really do what you described you want to do...

zhaokaixs commented 3 years ago

Well, if you execute it like the snippet describes it's still in the same process so you didn't really do what you described you want to do...

you are right ! many thanks.

nefarius commented 3 years ago

If that's the behaviour you want, good! But be careful, the serial number field is kept hidden for a reason; you're not supposed to change it. As long as you know what you're doing you should be fine though.

Is this topic resolved?

zhaokaixs commented 3 years ago

If that's the behaviour you want, good! But be careful, the serial number field is kept hidden for a reason; you're not supposed to change it. As long as you know what you're doing you should be fine though.

Is this topic resolved?

thank you!