injectKeyDown with WM_KEYDOWN messages

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Bob
Just popping in
Just popping in
Posts: 2
Joined: Thu Dec 14, 2006 22:30

injectKeyDown with WM_KEYDOWN messages

Postby Bob » Fri Dec 15, 2006 00:11

I am using Win32 messages to inject input into CEGUI. Everything works fine except for non alphanumeric characters. So I assume there is something wrong with my call to injectKeyDown/injectKeyUp. The documentation says that it takes the scan code. To get the scan code I use the Win32 function MapVirtualKey. Not sure what the problem is. Any ideas?

Code: Select all

while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
   TranslateMessage(&msg);
   switch(msg.message)
   {
      case WM_MOUSEMOVE:
         CEGUI::System::getSingleton().injectMousePosition(LOWORD(msg.lParam),HIWORD(msg.lParam));
         break;
      case WM_KEYDOWN:
         if(msg.wParam==VK_ESCAPE)
            run=false;
         CEGUI::System::getSingleton().injectKeyDown(MapVirtualKey(msg.wParam,0));
         break;
      case WM_KEYUP:
         CEGUI::System::getSingleton().injectKeyUp(MapVirtualKey(msg.wParam,0));
         break;
      case WM_CHAR:
         CEGUI::System::getSingleton().injectChar(msg.wParam);
         break;
      case WM_LBUTTONDOWN:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MouseButton::LeftButton);
         break;
      case WM_LBUTTONUP:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MouseButton::LeftButton);
         break;
      case WM_RBUTTONDOWN:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MouseButton::RightButton);
         break;
      case WM_RBUTTONUP:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MouseButton::RightButton);
         break;
      case WM_MBUTTONDOWN:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MouseButton::MiddleButton);
         break;
      case WM_MBUTTONUP:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MouseButton::MiddleButton);
         break;
      case WM_MOUSEWHEEL:
         CEGUI::System::getSingleton().injectMouseWheelChange(GET_WHEEL_DELTA_WPARAM(msg.wParam));
         break;
      case WM_MOUSELEAVE:
         CEGUI::System::getSingleton().injectMouseLeaves();
         break;
      default:
         break;
   }
   DispatchMessage(&msg);
}

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Dec 15, 2006 04:31


Bob
Just popping in
Just popping in
Posts: 2
Joined: Thu Dec 14, 2006 22:30

Postby Bob » Fri Dec 15, 2006 16:37

Thank you!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 28 guests