本文整理汇总了C++中IDirectInputDevice8::Acquire方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectInputDevice8::Acquire方法的具体用法?C++ IDirectInputDevice8::Acquire怎么用?C++ IDirectInputDevice8::Acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectInputDevice8
的用法示例。
在下文中一共展示了IDirectInputDevice8::Acquire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
IDirectInputDevice8 *BaseInputDevice::create_device(IDirectInput8 *pDI, GUID guid)
{
IDirectInputDevice8 *device;
HRESULT hr;
hr = pDI->CreateDevice(guid, &device, NULL);
if(FAILED(hr)) return NULL;
hr = device->SetCooperativeLevel(Render::hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
if(FAILED(hr))
{
device->Release(); return NULL;
}
device->Acquire();
return device;
}
示例2: pimpl
Gosu::Input::Input(HWND window)
: pimpl(new Impl)
{
pimpl->window = window;
pimpl->mouseFactorX = pimpl->mouseFactorY = 1.0;
// Create the main input object (only necessary for setup).
IDirectInput8* inputRaw;
Impl::check("creating the main DirectInput object",
::DirectInput8Create(Win::instance(), DIRECTINPUT_VERSION,
IID_IDirectInput8, reinterpret_cast<void**>(&inputRaw), 0));
pimpl->input = Win::shareComPtr(inputRaw);
// Prepare property struct for setting the amount of data to buffer.
DIPROPDWORD bufferSize;
bufferSize.diph.dwSize = sizeof(DIPROPDWORD);
bufferSize.diph.dwHeaderSize = sizeof(DIPROPHEADER);
bufferSize.diph.dwHow = DIPH_DEVICE;
bufferSize.diph.dwObj = 0;
bufferSize.dwData = Impl::inputBufferSize;
// Set up the system keyboard.
IDirectInputDevice8* kbRaw;
Impl::check("creating the keyboard device object",
pimpl->input->CreateDevice(GUID_SysKeyboard, &kbRaw, 0));
pimpl->keyboard = Win::shareComPtr(kbRaw);
Impl::check("setting the keyboard's data format",
kbRaw->SetDataFormat(&c_dfDIKeyboard));
Impl::check("setting the keyboard's cooperative level",
kbRaw->SetCooperativeLevel(window,
DISCL_FOREGROUND | DISCL_NONEXCLUSIVE));
Impl::check("setting the keyboard's buffer size",
kbRaw->SetProperty(DIPROP_BUFFERSIZE, &bufferSize.diph));
kbRaw->Acquire();
// Set up the system mouse.
IDirectInputDevice8* mouseRaw;
Impl::check("creating the mouse device object",
pimpl->input->CreateDevice(GUID_SysMouse, &mouseRaw, 0));
pimpl->mouse = Win::shareComPtr(mouseRaw);
Impl::check("setting the mouse's data format",
mouseRaw->SetDataFormat(&c_dfDIMouse));
Impl::check("setting the mouse's cooperative level",
mouseRaw->SetCooperativeLevel(window,
DISCL_FOREGROUND | DISCL_NONEXCLUSIVE));
Impl::check("setting the mouse's buffer size",
mouseRaw->SetProperty(DIPROP_BUFFERSIZE, &bufferSize.diph));
mouseRaw->Acquire();
pimpl->swapMouse = ::GetSystemMetrics(SM_SWAPBUTTON) != 0;
// Set up all gamepads.
pimpl->input->EnumDevices(DI8DEVCLASS_GAMECTRL, Impl::gamepadCallback,
pimpl.get(), DIEDFL_ATTACHEDONLY);
// Get into a usable default state.
pimpl->mouseX = pimpl->mouseY = 0;
pimpl->updateMousePos();
buttons.assign(false);
}
示例3: Acquire
HRESULT _stdcall Acquire(void) { return RealDevice->Acquire(); }