x360ce2ViGEm



  • Originally posted by spacelime


    Sorry to be a noob ass, but I'm just really eager to try x360ce2ViGEm out. I would compile it, but unfortunately I only have VS2008 whithout C++11 compability..

    Could someone be kind enough to upload or email me the two files vigemum.dll and x360ce2vigem.exe?

    spacelime@gmail.com

    Thank you very much 🙂



  • Originally posted by nefarius


    Is x64 only OK? Here's a binary copy (without warranties) https://vigem.org/wp-content/uploads/2017/02/x360ce2ViGEm_x64.7z



  • Originally posted by spacelime


    @nefarius#18 Thank you! 🙂



  • Originally posted by spacelime


    @nefarius#18 Hi! It says:

    Bypassing HidGuardian
    Initializing emulation driver
    Couldn't initialize emulation driver

    I installed the driver with the installer and have 4 files in C:\Program Files\Nefarius Software Solutions\Virtual Gamepad Emulation Driver\ViGEmBus.

    Do I have to install anything else?

    Thanks!



  • Originally posted by nefarius


    It's not enough you have the files there, you need to check if the Virtual Gamepad Emulation Bus Device is in your System devices in Device manager and not reporting any errors.



  • Originally posted by spacelime


    @nefarius#23 Ok! I think it may be because I didn't uninstall SCPToolkit properly.. I'll give it a new try when I get home on friday 🙂

    By the way, I have a question about the features of VigEm. I have 2 game controllers connected by DInput. The problem is that they are not calibrated and I havn't found a way to calibrate them through regular means (joy.cpl for example doesn't work with those).

    So what I want to do is to use x360ce and VigEm in order to create 2 virtual X360 controller and if possible auto calibrate the controllers somewhere along that chain. What I want to do is to read the analogue stick values as soon as a controller is connected and detected, and then assign anything differing from 32767 to 4 variables, leftXOffset, leftYOffset, rightXOffset, and rightYOffset. Then I will make it so that these offsets are subtracted from each axis value before the data is sent further in every cycle.

    So what I wonder is first of all, is this feature already implemented somewhere either in x360ce or in VigEm? And if not, my plan is to get VS2015 and modify the code... but I'm not sure which would be easier - to put the calibration function between the DInput instance of the controller and x360ce, or to put it between x360ce and VigEm (I guess in x360ce2vigem).

    I hope my question makes sense. I still have a very limited knowledge when it comes to these things 🙂

    And one more thing just to clarify my dilemma... The controllers I'm refering to are a couple of WiiU Pro controllers, my all time favourites. They are connected to the computer via a Mayflash adapter, (which surprisingly fails to auto calibrate the controllers! more info here http://www.mayflash.com/products/nintendowiiu/w009.html). This means that when connecting the Mayflash adapter, 4 instances of DInput controllers appear in the device manager. And whichever of my two controllers I turn on first automatically gets assigned as controller 1. This means that Windows have no clue which of the 2 that is connected. So if I were to find a way to calibrate them in Windows it wouldn't work anyway since they are uncalibrated in different ways and if I were to turn off one and turn on the other it would get assigned to the same "slot" and also get the same calibration as the last controller which would make it miscalibrated. That's why it's so crucial for me to find a way to autocalibrate the controllers as soon as they are turned on.

    Thank you for your help 🙂



  • Originally posted by spacelime


    I've made a tweak to x360ce2vigem in order to auto-calibrate game controllers upon connecting. In case anyone has any use for it here's the code:

    int LXOffset[] = { 0,0,0,0 };
    	int LYOffset[] = { 0,0,0,0 };
    	int RXOffset[] = { 0,0,0,0 };
    	int RYOffset[] = { 0,0,0,0 };
    
    	bool calibrated[] = { false,false,false,false };
    
        printf("Starting translation, close window to exit...\n");
    
        while (true)
        {
            auto begin = high_resolution_clock::now();
    
            for (int i = 0; i < XUSER_MAX_COUNT; i++)
            {
                ZeroMemory(&state, sizeof(XINPUT_STATE));
    
    			// The Mayflash WiiUPro adapter assigns the first connected controller to bus 4, the second to bus 0 etc.. This is to sort them properly.
                if (i == 0) result = XInputGetState(3, &state);
    			if (i == 1) result = XInputGetState(0, &state);
    			if (i == 2) result = XInputGetState(1, &state);
    			if (i == 3) result = XInputGetState(2, &state);
    
                if (result == ERROR_SUCCESS)
                {
                    vigem_target_set_vid(&targets[i], 0x1234);
                    vigem_target_set_pid(&targets[i], 0x0001);
    
                    if (VIGEM_SUCCESS(vigem_target_plugin(Xbox360Wired, &targets[i])))
                    {
                        printf("Plugged in controller %d\t\t\t\t\n", targets[i].SerialNo);
                    }
    
    				// Calibrate controller
    				if (state.Gamepad.sThumbRX != 0 && state.Gamepad.sThumbRX != 1 && !calibrated[i])
    				{
    					LXOffset[i] = state.Gamepad.sThumbLX;
    					LYOffset[i] = state.Gamepad.sThumbLY;
    					RXOffset[i] = state.Gamepad.sThumbRX;
    					RYOffset[i] = state.Gamepad.sThumbRY;
    
    					calibrated[i] = true;
    				}
    
    				if (state.Gamepad.sThumbRX == 0 && state.Gamepad.sThumbRY == -1) calibrated[i] = false;
    
    				// Assign the proper offsets
    				if (calibrated[i])
    				{
    					//LX
    					if (LXOffset[i] < 0)
    					{
    						if (state.Gamepad.sThumbLX - LXOffset[i] < 32767 + LXOffset[i]) state.Gamepad.sThumbLX = state.Gamepad.sThumbLX - LXOffset[i];
    						else state.Gamepad.sThumbLX = 32767 + LXOffset[i];
    						state.Gamepad.sThumbLX = state.Gamepad.sThumbLX * (32767.0f / (32767.0f + LXOffset[i]));
    					}
    					if (LXOffset[i] > 0)
    					{
    						if (state.Gamepad.sThumbLX - LXOffset[i] > -32767 + LXOffset[i]) state.Gamepad.sThumbLX = state.Gamepad.sThumbLX - LXOffset[i];
    						else state.Gamepad.sThumbLX = -32767 + LXOffset[i];
    						state.Gamepad.sThumbLX = state.Gamepad.sThumbLX * (32767.0f / (32767.0f - LXOffset[i]));
    					}
    
    
    					//LY
    					if (LYOffset[i] < 0)
    					{
    						if (state.Gamepad.sThumbLY - LYOffset[i] < 32767 + LYOffset[i]) state.Gamepad.sThumbLY = state.Gamepad.sThumbLY - LYOffset[i];
    						else state.Gamepad.sThumbLY = 32767 + LYOffset[i];
    						state.Gamepad.sThumbLY = state.Gamepad.sThumbLY * (32767.0f / (32767.0f + LYOffset[i]));
    					}
    					if (LYOffset[i] > 0)
    					{
    						if (state.Gamepad.sThumbLY - LYOffset[i] > -32767 + LYOffset[i]) state.Gamepad.sThumbLY = state.Gamepad.sThumbLY - LYOffset[i];
    						else state.Gamepad.sThumbLY = -32767 + LYOffset[i];
    						state.Gamepad.sThumbLY = state.Gamepad.sThumbLY * (32767.0f / (32767.0f - LYOffset[i]));
    					}
    
    					//RX
    					if (RXOffset[i] < 0)
    					{
    						if (state.Gamepad.sThumbRX - RXOffset[i] < 32767 + RXOffset[i]) state.Gamepad.sThumbRX = state.Gamepad.sThumbRX - RXOffset[i];
    						else state.Gamepad.sThumbRX = 32767 + RXOffset[i];
    						state.Gamepad.sThumbRX = state.Gamepad.sThumbRX * (32767.0f / (32767.0f + RXOffset[i]));
    					}
    					if (RXOffset[i] > 0)
    					{
    						if (state.Gamepad.sThumbRX - RXOffset[i] > -32767 + RXOffset[i]) state.Gamepad.sThumbRX = state.Gamepad.sThumbRX - RXOffset[i];
    						else state.Gamepad.sThumbRX = -32767 + RXOffset[i];
    						state.Gamepad.sThumbRX = state.Gamepad.sThumbRX * (32767.0f / (32767.0f - RXOffset[i]));
    					}
    
    					//RY
    					if (RYOffset[i] < 0)
    					{
    						if (state.Gamepad.sThumbRY - RYOffset[i] < 32767 + RYOffset[i]) state.Gamepad.sThumbRY = state.Gamepad.sThumbRY - RYOffset[i];
    						else state.Gamepad.sThumbRY = 32767 + RYOffset[i];
    						state.Gamepad.sThumbRY = state.Gamepad.sThumbRY * (32767.0f / (32767.0f + RYOffset[i]));
    					}
    					if (RYOffset[i] > 0)
    					{
    						if (state.Gamepad.sThumbRY - RYOffset[i] > -32767 + RYOffset[i]) state.Gamepad.sThumbRY = state.Gamepad.sThumbRY - RYOffset[i];
    						else state.Gamepad.sThumbRY = -32767 + RYOffset[i];
    						state.Gamepad.sThumbRY = state.Gamepad.sThumbRY * (32767.0f / (32767.0f - RYOffset[i]));
    					}
    				}
    
    
    
                    vigem_xusb_submit_report(targets[i], *reinterpret_cast<XUSB_REPORT*>(&state.Gamepad));
                }
                else
                {
                    if (VIGEM_SUCCESS(vigem_target_unplug(&targets[i])))
                    {
                        printf("Unplugged controller %d\t\t\t\t\n", targets[i].SerialNo);
                    }
                }
            }`
    

Log in to reply