Sign in to follow this  

[Solved] DirectX/Win32 Input Madness

This topic is 4226 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I posted a couple of weeks ago and the replies I got I followed up and experimented but didn't get very far. My problem is in my DX app I have created a console: I want the console to support both upper/lower case letters, punctuation and numbers. At the moment I have been using the wParam passed like so:
LRESULT CALLBACK WinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
  switch(Msg)
  {
  case WM_CREATE:
    break;
  case WM_DESTROY:
    PostQuitMessage(0);
    break;
  case WM_KEYDOWN:
    switch(wParam)
    {
    case VK_ESCAPE:
      PostQuitMessage(0);
      break;
    case VK_OEM_3:
      D3D->ConsoleToggle();
      break;
    case VK_RETURN:
      D3D->ConsoleReturn();
      break;
    default:
      break;
    };
    if(wParam == 32 || wParam >= 48 && wParam <= 122)
    {
      D3D->ConsoleInput((char)wParam);
    };
    if(wParam == 190)
      D3D->ConsoleInput('.'); // as you can see this is a fairly unintuitive way of doing things...
    break;
  default:
    break;
  };
  return(DefWindowProc(hWnd, Msg, wParam, lParam));
};


But I don't know how to check whether Shift is down or up and also most of the punctuation characters don't work correctly. I'm fairly lost so if you could, please help with code or links to useful pages. I thank you all once again. Jem [Edited by - Jemburula on May 20, 2006 9:17:21 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Jemburula
But I don't know how to check whether Shift is down or up and also most of the punctuation characters don't work correctly. I'm fairly lost so if you could, please help with code or links to useful pages. I thank you all once again.


All you need to do is handle the WM_CHAR Windows message, and check the current character using the isprint function.

Example:

LRESULT CALLBACK WinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CREATE:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;

case WM_CHAR:
{
if(isprint(wParam))
{
D3D->ConsoleInput((char)wParam);
}
}break;


case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
case VK_OEM_3:
D3D->ConsoleToggle();
break;
case VK_RETURN:
D3D->ConsoleReturn();
break;
default:
break;
};
default:
break;
};
return(DefWindowProc(hWnd, Msg, wParam, lParam));
};


Now, everything is taken care of for you [smile] Goodluck!

Share this post


Link to post
Share on other sites

This topic is 4226 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this