Here is some raw C code using windows.gaming.input.h
API:
HSTRING gamepadClassName;
if (FAILED(WindowsCreateString(RuntimeClass_Windows_Gaming_Input_Gamepad,
HbArrayLength(RuntimeClass_Windows_Gaming_Input_Gamepad) - 1, &gamepadClassName))) {
Error("Failed to create a WinRT string reference for Windows.Gaming.Input.Gamepad class name.");
}
static IID const gamepadStaticsInterfaceID = { 0x8BBCE529, 0xD49C, 0x39E9, { 0x95, 0x60, 0xE4, 0x7D, 0xDE, 0x96, 0xB7, 0xC8 } };
if (FAILED(RoGetActivationFactory(gamepadClassName, &gamepadStaticsInterfaceID, &HbInputi_Windows_Gamepad_Statics))) {
Error("Failed to get the IGamepadStatics activation factory for Windows.Gaming.Input.Gamepad.");
}
WindowsDeleteString(gamepadClassName);
Is there any way to get rid of this gamepadStaticsInterfaceID
GUID definition in code? I tried to use IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics
declared in windows.gaming.input.h
header but then then I have error LNK2001: unresolved external symbol IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics
.
What lib should I link to properly define IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics
?
This appears to be not included in the SDK.
Typically, this would come from a lib like uuid.lib. However, I see no evidence that the IID's for Windows.Gaming (or other winrt types that I've spot-checked) are supplied this way in any library in the Windows SDK. C usage is supported for winrt types, but very lightly used.
I'll open a bug to track this when I get back into the office tomorrow. For now, your only option is to define the GUID in your code as you've done here.
Ben Kuhn (MSFT)