I don't know C++

From: Mikee16 Apr 2012 11:18
To: ALL1 of 3
Hi all,

I'm trying/failing to do a bit of C++.

My project is to inject a DLL into XInput to emulate xbox controllers via a mouse.

I'm hopefully going to allow the user to connect up to 4 virtual xbox controllers, and switch between them using F1/F2/F3/F4, and the 'controller' will then be controlled via a mouse/keyboard.

Ideally I'd have done this in a language I know - C# or something. But to inject a DLL into xInput it seems I need to use C++.

Fortunately I've found a bit of code that's doing just this. But, compiling it seems to give me a few errors and I can't for the life of me work out whats causing it.

Here is an example of some of the code that's not compiling:

c++ code:
 
DWORD WINAPI XInputGetBatteryInformation
(
 DWORD                       dwUserIndex,        // [in]  Index of the gamer associated with the device
 BYTE                        devType,            // [in]  Which device on this user index
 XINPUT_BATTERY_INFORMATION* pBatteryInformation // [out] Contains the level and types of batteries
 )
 
{
	if(!GamepadMapping[dwUserIndex].enabled) return ERROR_DEVICE_NOT_CONNECTED;
 
	// Report a wired controller
	pBatteryInformation->BatteryType = BATTERY_TYPE_WIRED;
	return ERROR_SUCCESS;
 
}
 


It's reporting that XINPUT_BATTERY_INFORMATION is undefined - but I'm confused because if I "go to definition" for that, it takes me to the XInput.h file within the XInput library - seems quite defined to me?

I've also tried explicitly including "XInput.h" at the top of this file and still no luck.

I know it's a long shot, but maybe someone can point me in the right direction? I'm using VS11 Beta.
From: Mikee16 Apr 2012 11:43
To: ALL2 of 3
Hmm.

XInput.h:

c++ code:
 
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
 
typedef struct _XINPUT_BATTERY_INFORMATION
{
    BYTE BatteryType;
    BYTE BatteryLevel;
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
 


Showing as commented out. If _WIN32_WINNT >= _WIN32_WINNT_WIN8 ? :/
From: Mikee16 Apr 2012 15:33
To: ALL3 of 3

Hrm. I seem to have fixed it.

 

I don't like C++ :(