Jump to content

  • Log In with Google      Sign In   
  • Create Account


DaFox

Member Since 20 Nov 2011
Offline Last Active Mar 28 2014 02:40 PM
-----

Posts I've Made

In Topic: Turn off XBOX 360 Controller

20 November 2011 - 06:04 PM

Very possible. I would not use this in anything more than a controller manager. This is not something that any other type of application should be doing anyway.

Windows 7 ships with 4 versions of the XInput.dll though. I expect that Windows 8 will ship with the exact same XInput1_3.dll, and a new XInput1_4.dll.

In Topic: Turn off XBOX 360 Controller

20 November 2011 - 07:15 AM

Glad that you got it working MemphiZ, this is basically the only thread that I could find that was discussing this issue.

Here is some sample code on how to do this.

AutoIT:
$nController = 1
$XInputDLL = DllOpen("xinput1_3.dll")
DllCall($XInputDLL, "long", 103, "int", $nController)

C++:
#include <windows.h>
#include <iostream>
#include "C:/Program Files (x86)\\Microsoft DirectX SDK (June 2010)\\Include\\XInput.h"

#pragma comment(lib, "C:\\Program Files (x86)\\Microsoft DirectX SDK (June 2010)\\Lib\\x64\\XInput.lib")

using namespace std;

typedef int (*FnOff)(int);

int wmain() {
	HINSTANCE hXInputDLL = LoadLibraryA("XInput1_3.dll");
	if (hXInputDLL == NULL) {
		cout << "ERROR: Unable to load XInput1_3.dll!" << endl;
		fgetc(stdin);
		return 1;
	}

	unsigned result;
	for (short i = 0; i < XUSER_MAX_COUNT; ++i) {
		XINPUT_STATE state;
		memset(&state, 0, sizeof(XINPUT_STATE));

		result = XInputGetState(i, &state);

		if(result == ERROR_SUCCESS) {
			FnOff pOff;
			pOff = FnOff(GetProcAddress(hXInputDLL, reinterpret_cast<char*>(103)));
			pOff(i);
		}
	}
	
	FreeLibrary(hXInputDLL);
	return 0;
}

This C++ Code simply turns off all connected XInput devices.
You can probably safely skip the XInputGetState stuff though I have not tried calling XInput1_3.dll#103 on a device that is not connected. I'm sure it will be fine.

PARTNERS