Hello,

I have looked src/osgViewer/GraphicsWindowX11.cpp and it helped to
localise my problem.
I printed the debug info with "osg::notify" in key points of the code
and got very interesting results. Here are key points and results:

            case KeyPress:

            {

                if (firstEventTime==0) firstEventTime = ev.xmotion.time;

                Time relativeTime = ev.xmotion.time - firstEventTime;

                eventTime = baseTime + static_cast<double>(relativeTime)*0.001;

                               //!!!!!!!!!!!!

                _modifierState = ev.xkey.state;


osg::notify(osg::INFO)<<"+++ev.xkey.keycode = "<< ev.xkey.keycode <<
std::endl;

                keyMapSetKey(_keyMap, ev.xkey.keycode);

                int keySymbol = 0;

                adaptKey(ev.xkey, keySymbol);



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

                               osg::notify(osg::INFO)<<"+++key = "<<
keySymbol << " press !" << std::endl;

                break;

            }



results:

ey= 97

+++ev.xkey.keycode = 38

+++key = 97 press !

key= 97

+++ev.xkey.keycode = 39

+++key = 115 press !

key= 115

+++ev.xkey.keycode = 40

+++key = 100 press !

key= 100

+++ev.xkey.keycode = 40

+++key = 100 press !

key= 100

+++ev.xkey.keycode = 40

+++key = 100 press !

key= 100

+++ev.xkey.keycode = 64

+++key = 65513 press !

key= 65513

+++ev.xkey.keycode = 50

+++key = 65505 press !

key= 65505

----------------------------------------------------------here I
switched the keyboard layout --

+++ev.xkey.keycode = 39

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 40

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 38

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 38

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 25

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 25

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 25

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 25

+++key = 0 press !

key= 0

+++ev.xkey.keycode = 40

+++key = 0 press !

key= 0


I continued my research :). But the next problem I crossed with, was
the following function (GraphicsWindowX11::adaptKey). I'm not very
competent in Linux coding, and I get confused with conversion into
ASCII, because national characters have another ASCII codes. There is
an ASCII code before conversion and therу isn't after it. (see output
results above). I'd be glad to any help :)



void GraphicsWindowX11::adaptKey(XKeyEvent& keyevent, int& keySymbol)

{

    Display* display = _eventDisplay;



    unsigned char keybuf[32];

    XLookupString( &keyevent, (char *)keybuf, sizeof(keybuf), NULL, NULL );



    KeySym ks = XKeycodeToKeysym( display, keyevent.keycode, 0 );

    int remappedKey = remapX11Key(ks);

    if (remappedKey & 0xff00)

    {

        // special keyboard character

        keySymbol = remappedKey;

    }

    else



    {

        // normal ascii key

        keySymbol = keybuf[0];

    }

}

2009/5/14 Robert Osfield <robert.osfi...@gmail.com>
>
> Hi Gammer?  Maximum?  Could you sign with your first name please so we
> know how to address you, thanks.
>
> I haven't heard of problems with keyboard mappings under Linux before
> so don't have any prior knowledge to share, there must be something
> specific about your setup which isn't supported that others haven't
> used before.
>
> What you'll have to look into is what is happening inside
> src/osgViewer/GraphicsWindowX11.cpp to see what keyboard events are
> being generated and follow these to see how they are mapped before
> passed into the osgGA::EventQueue that is the route into OSG's
> standard event traversal.
>
> Since you're the one that can reproduce the problem, you are also the
> one best placed to look into what the specific issue is, the best we
> can do is point your in roughly the right directions to look.
>
> Robert.
>
> On Thu, May 14, 2009 at 8:31 AM, Maxim Gammer <maxgam...@gmail.com> wrote:
> > Hello,
> >
> > While porting my program to Linux, I encountered the following error.
> > If the keyboard layout is English (USA) then KeyboardEventHandler
> > works fine. But if it's something else, Russian for example,
> > ea.getKey() always returns zero. (Except system keys F1 - F12 and
> > digits)
> >
> > It's the case for Kubuntu 9.04 and SUSE 11.1 (KDE)
> > In WindowsXP and Vista everything works fine.
> >
> > The usage of KeyboardEventHandler:
> >
> > bool KeyboardEventHandler::handle(
> > const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us)
> > {
> >    switch(ea.getEventType())
> >    {
> >        case(osgGA::GUIEventAdapter::KEYDOWN ):
> >        {
> >            int _key = ea.getKey();
> >            std::cout << "key= " << _key << std::endl;
> >
> > ....
> >
> >
> > --
> > Maxim Gammer
> > _______________________________________________
> > 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



--
Maxim Gammer
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to