当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTINPUT::Initialize方法代码示例

本文整理汇总了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;
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:34,代码来源:directinput.cpp

示例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();
}
开发者ID:icebreaker,项目名称:xboxdrv,代码行数:32,代码来源:hello_world.cpp


注:本文中的LPDIRECTINPUT::Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。