yannbouteiller / vgamepad

Virtual XBox360 and DualShock4 gamepads in python
MIT License
169 stars 21 forks source link

Sending inputs to another virtual controller instance #13

Closed crossbr1 closed 1 year ago

crossbr1 commented 1 year ago

Hi, I made a script in python to receive data and send input using vgamepad, the script is working perfectly using keyboard but my intention was that it send inputs to the virtual controller created by ds4windows, I dont know much of coding but from what I noticed both instances have the same hardware ID and the one made by ds4windows is set to xinput id 0 and the one made by vgamepad is set to xinput id 1, could you give me any advice on how I could make it work.

The script is only suppose to simulate the right trigger release sending simulate_right_trigger(0)

yannbouteiller commented 1 year ago

Hi, sorry I am not sure what you are trying to achieve here. Can you describe your project more precisely?

(Closing as this is apparently a question more than an issue, but feel free to continue the discussion here)

crossbr1 commented 1 year ago

The script receives data from a udp socket from the game forza horizon 5, the script then calculates the tire slip rate to kill the right trigger input preventing the car from wheel spin (traction control). I have a ds4 controller so I need vgamepad to release the trigger from the ds4windows virtual controller instead of creating a new one. HTCS.log

yannbouteiller commented 1 year ago

Ah I see, I am afraid vgamepad cannot modify the input from your other gamepads sorry. What maybe you could do is capture the input from your actual gamepad and reproduce it in a second (virtual) gamepad created via vgamepad that you would use in forza instead of your actual gamepad, so you could hack the input as much as you like

crossbr1 commented 1 year ago

I thought because both use the vigem bus driver maybe it was just a matter of specifying the id.

anyway thanks for your time

yannbouteiller commented 1 year ago

But the vigembus driver is for emulating gamepads as far as I know, can it also hook real gamepads?

crossbr1 commented 1 year ago

As I said idk much of coding and how things work but ds4windows uses vigem to create a x360 virtual controller the same as vgamepad, what Im trying to understand is how vgamepad knows which virtual controller is suppose to receive input when there is 2 virtual x360 controllers connected at the same time

I'll try to ask in nefarius discord

yannbouteiller commented 1 year ago

I think vigembus gives an index to each attached device, in vgamepad you can retrieve this index with the get_index method, but I suppose that is what you called device ID 0 and 1.

I think I understand you want to hook into another virtual device that is already created with vigembus? Not sure whether it is possible at all, but if it is you will probably need to use vigem directly, I don't think vgamepad exposes an API that enables doing that atm.