Is there a way of detecting keyboard input within the message loop. Here is something I've tried below:
LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
// WM_DESTROY is sent when the window is being destroyed.
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
BYTE keyboardState[256];
if (keyboardState[DIK_W]) {
OutputDebugStringW(L"W Button Pressed\n");
}
if (keyboardState[DIK_A]) {
OutputDebugStringW(L"A Button Pressed\n");
}
if (keyboardState[DIK_S]) {
OutputDebugStringW(L"S Button Pressed\n");
}
if (keyboardState[DIK_D]) {
OutputDebugStringW(L"D Button Pressed\n");
}
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
The problem is the it seems to return all of the keyboard states: Output is as follows...
W Button Pressed
A Button Pressed
S Button Pressed
D Button Pressed
How can I implement this so it just detects the key input pressed. I'm new so this might be a stupid implementation :)