Hi Alexander, I'm afraid I'm not familiar with Win32 API for keyboard bindings so I've to dive into the GraphicsWindowWin32.cpp to understand your suggestion about passing a "VirtualKey". From reading the code it looks to me like the VirtualKey is Win32 specific which would mean the client code would also need to be platform specific so an ideal candidate for integration.
>From what I can make of the functionality you are after what you are after is an unmodified key, i.e. no shift/no control key modification - just the raw key code. Reviewing the GraphicsWindowWin32::adaptKey(..) method the lines of code: else if ((keySymbol & 0xff00)==0) { char asciiKey[2]; int numChars = ::ToAscii(wParam, (lParam>>16)&0xff, keyState, reinterpret_cast<WORD*>(asciiKey), 0); if (numChars>0) keySymbol = asciiKey[0]; } Look to me to be the ones that are likely to be applying the key modification. If this is correct then passing the modifying keySymbol as well as the modified keySymbol should be sufficient. This would still require osgGA::GUIEventAdatper to have a new getRawKey()/getUnmodifiedKey() field and osgViewer to be tweaked to set this new field, but I open to this. Thoughts? Robert. On Fri, Jan 21, 2011 at 11:20 AM, Alexander Sinditskiy <verybigbad...@gmail.com> wrote: > 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 > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org