Jump to content
  • Advertisement
Sign in to follow this  
Jemburula

[Solved] DirectX/Win32 Input Madness

This topic is 4445 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
Advertisement
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
Ah thanks Drew, I'd rate you up again if you weren't already rated to the top [smile] Take it easy everyone. *Scrambles off into the madness again*

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!