本文整理汇总了C++中LPDIRECTINPUT::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTINPUT::Initialize方法的具体用法?C++ LPDIRECTINPUT::Initialize怎么用?C++ LPDIRECTINPUT::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTINPUT
的用法示例。
在下文中一共展示了LPDIRECTINPUT::Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DirectInput_Init
int DirectInput_Init(void)
{
HRESULT hr;
if(dInput || dInput3) return true;
// Create the DirectInput interface instance. Try version 8 first.
if(FAILED(hr = CoCreateInstance(CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER,
IID_IDirectInput8, (LPVOID*)&dInput)) ||
FAILED(hr = dInput->Initialize(app.hInstance, DIRECTINPUT_VERSION)))
{
Con_Message("DirectInput 8 init failed (0x%x).", hr);
// Try the older version 3 interface instead.
// I'm not sure if this works correctly.
if(FAILED(hr = CoCreateInstance(CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
IID_IDirectInput2W, (LPVOID*)&dInput3)) ||
FAILED(hr = dInput3->Initialize(app.hInstance, 0x0300)))
{
Con_Message("Failed to create DirectInput 3 object (0x%x).", hr);
return false;
}
Con_Message("Using DirectInput 3.");
}
if(!dInput && !dInput3)
{
Con_Message(" DirectInput init failed.");
return false;
}
return true;
}
示例2: WinMain
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR pCmdLine,
int nShowCmd)
{
HRESULT result = CoInitialize(0);
LPDIRECTINPUT directinput;
if (FAILED(result))
{
std::cerr << "CL_DisplayWindow_Win32: Damn murphy must hate you. CoInitialize failed!" << std::endl;
}
result = CoCreateInstance(CLSID_DirectInput, 0, CLSCTX_INPROC_SERVER, IID_IDirectInput, (LPVOID *) &directinput);
if (FAILED(result))
{
std::cerr << "FAILURE" << std::endl;
}
else
{
std::cerr << "SUCCESS" << std::endl;
result = directinput->Initialize(GetModuleHandle(0), DIRECTINPUT_VERSION);
}
if (!InitWindowsApp(hInstance, nShowCmd))
{
::MessageBox(0, "Init - Failed", "Error", MB_OK);
return 0;
}
return Run();
}