Hi,

I have a problem with  processing keystokes in osg-viewer window.

I would like to tell about this problem and propound resolution.

First i need to explain what is problem i have:

Assume that you want process ASDW keydown like as in Counter-Strike and F to 
flash light.

that you need to do?
you need to create something like


Code:
case osgGA::GUIEventAdapter::KEYDOWN:
  switch(ea.getKey())
  {
    case 'w':
    // go forward
    break;
    ...
  }



It will work until you need to add crouch.

let's see what will be in this case:

after key is pressed there is message recieved

Code:
case WM_KEYDOWN    :
case WM_SYSKEYDOWN :



their handlers do the following:

 adaptKey(wParam, lParam, keySymbol, modifierMask);
   1. getting a virtual key code
   2. converting virtual key code to symbol code

 then there is a call of

Code:
getEventQueue()->keyPress(keySymbol, eventTime);


 with GUIEventAdapter created inside it, what contain keySymbol


i.e. now to turn flashlight we have to do steps below:


Code:
case osgGA::GUIEventAdapter::KEYDOWN:
  switch(ea.getKey())
  {
    case 'F':
    case 'f':
    case 'f'-0x40 :  // for processing with CTRL
    // do something
  }



as we don't know whick key is pressed by user, we have to include all 
possibilities:

I suggest using virtual keys codes both with current key handles, as the 
following:

Code:
   adaptKey(wParam, lParam, keySymbol, modifierMask, virtualKey);
   ...
   getEventQueue()->keyPress(keySymbol, virtualKey eventTime);



What do you think about it?
Thank you!

Cheers,
Alexander

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35850#35850





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to