DirectInput key always pressed
(I couldn't see any code tags, so i apologise for the ew look)
Hi I've been making an input engine for my game using DirectInput8 - got most of the code from a book. Problem is that I seem to be getting the same mouse information regardless of whether a button is pressed or not.
Here is my initialization:
int res = DirectInput8Create(::GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_di, NULL);
if (FAILED(res)){
g_pLogger->error("Could not create Input Device");
return;
}
res = m_di->CreateDevice(GUID_SysMouse, &m_mouse, NULL);
if (FAILED(res)){
g_pLogger->error("Could not create mouse interface");
return;
}
if (FAILED(m_mouse->SetDataFormat(&c_dfDIMouse))){
g_pLogger->error("Could not set data format for mouse");
return;
}
if (FAILED(m_mouse->SetCooperativeLevel(m_hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))){
g_pLogger->error("Could not set coop level for mouse");
return;
}
if (FAILED(m_mouse->Acquire())){
g_pLogger->error("Could not acquire mouse");
return;
}
Here is the updating:
while (true){
m_mouse->Poll();
if (SUCCEEDED(res = m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), &m_mouseState)))
break;
if (res != DIERR_INPUTLOST && res != DIERR_NOTACQUIRED){
g_pLogger->error("Could not get mouse state???");
return;
}
if (FAILED(m_mouse->Acquire())){
g_pLogger->error("Could not reacquire mouse!!!!");
return;
}
}
Now if i check each of the four .rgbButtons values I get
rgbButtons = {205,205,410,615}
these values don't change if I click any of the buttons...
this is odd - I came about it by finding that my button was always pressed (Coz 205 & 0x80 is not 0)
any help would be much appreciated !!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement