I'm quite new to the windows api and raw input is for lack of better terms kicking my tail. I've initialized it in my program, called and defined in the window proc with WM_INPUT, and I'm definitely receiving inputs. However that pesky key repeat delay is still there... First question would be is this direction I should be going programming an input framework in windows? Or is there a more recommended method in modern windows coding when needing on the fly and latency free response?
Here is my window proc:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_DESTROY:
return 0;
case WM_INPUT:
{
char keyBuffer[sizeof(RAWINPUT)] = {};
UINT KBsize = sizeof(RAWINPUT);
GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, keyBuffer, &KBsize, sizeof(RAWINPUTHEADER));
RAWINPUT *raw = (RAWINPUT*)keyBuffer;
if (raw->header.dwType == RIM_TYPEMOUSE)
{
// read the mouse data
}
if (raw->header.dwType == RIM_TYPEKEYBOARD)
{
// Get key value from the keyboard member (of type RAWKEYBOARD)
USHORT keyCode = raw->data.keyboard.VKey;
switch (keyCode) {
case VK_ESCAPE:
PostQuitMessage(0);
break;
case 0x41:
theta += 1.0f; // Rotate left when A is pressed.
break;
case 0x44:
theta -= 1.0f; // Rotate right when D is pressed.
break;
}
}
}
return 0;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
} I understand that I should be defining the buffer to a hard array size, but this isn't my issue in the current case. I simply want the application to react to the key state, and not delay key repeats at the OS setting. Kind of silly to claim low level and I'm being code blocked by the OS. I've tested in this application with dwFlags at 0 (virtual key assign) and no legacy, to no avail.
I'm sure this has probably been asked before, but I could not find an article or post here younger than 11 years on the subject. And what was found not what I was looking for.
I've tried to watch my language -- retired sailor -- if I missed a few let me know for edit.