Original Post
I had my input system written but it was a strange mix of windows messages and polling with getasync() ect. The real problem though was that when trying to use the mouse and the keyboard the entire engine stuttered. I'm no too sure what I did there but it pushed me to try to wrap raw input and depend only on that. Its resolved the stuttering but now I'm getting mouse lag like Ive never seen. Everything keeps moving fine but a second of mouse movement is turning into a minute of movement and being locked out of further input. So if i move the mouse and hit esc to quit I have to wait for the extremely slowed input lag to finish. The whole thing is rather frustrating I'm almost ready to say die and hook in directinput, but then again that may be more hours of debugging.
What I really want to do is sidestep the message queue and go with nothing but getasync() for movement controls, will that cause problems down the line?
Raw Input is recommended but its the most complicated, for movement controls is it really the best choice?
Anyone have a link / name for some demo code and / or wrappers for raw input (c++)?
Lastly, if anyone has a minute could you take a look at the input code's latest incarnation and let me know if a message queue lagging issue pops? Any comments on the code are more than welcome too.
Thanks guys n gals.
What I really want to do is sidestep the message queue and go with nothing but getasync() for movement controls, will that cause problems down the line?
Raw Input is recommended but its the most complicated, for movement controls is it really the best choice?
Anyone have a link / name for some demo code and / or wrappers for raw input (c++)?
Lastly, if anyone has a minute could you take a look at the input code's latest incarnation and let me know if a message queue lagging issue pops? Any comments on the code are more than welcome too.
switch(umsg)
{
case WM_CREATE:
{
RAWINPUTDEVICE Rid[2];
Rid[0].usUsagePage = 0x01;
Rid[0].usUsage = 0x02;
Rid[0].dwFlags = 0; // adds HID mouse
Rid[0].hwndTarget = 0;
Rid[1].usUsagePage = 0x01;
Rid[1].usUsage = 0x06;
Rid[1].dwFlags = 0; // adds HID keyboard
Rid[1].hwndTarget = 0;
if (RegisterRawInputDevices(Rid, 2, sizeof(Rid[0])) == FALSE) {
strPrinter("input registration failed");
}
}
case WM_INPUT:
{
UINT dwSize;
// Determine how big the buffer should be
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize,
sizeof(RAWINPUTHEADER));
BYTE* lpb;
lpb = new BYTE[dwSize];
if (lpb == NULL)
{
strPrinter("lpb not initialized");
return 0;
}
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize,
sizeof(RAWINPUTHEADER)) != dwSize )
strPrinter("GetRawInputData does not return correct size !");
GetRawInputData((HRAWINPUT)lParam, RID_INPUT,(LPVOID)lpb, &dwSize,
sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
switch (raw->header.dwType)
{
case RIM_TYPEMOUSE:
{
// read the mouse data
long mx = raw->data.mouse.lLastX;
long my = raw->data.mouse.lLastY;
m_Input->mouseMove(mx, my);
delete[] lpb;
return 0;
}
case RIM_TYPEKEYBOARD:
{
// read the keyboard data
m_Input->KeyUp(raw->data.keyboard.VKey);
delete[] lpb;
return 0;
}
}
delete[] lpb;
return 0;
}
Thanks guys n gals.