* Robert Osfield -- Monday 25 May 2009:
> Good to hear that it's now working.

Sorry, but it's not! This totally breaks non-russian keyboards. Did you
try osgkeyboard lately? Type an upper-case letter. You'll get lower-case
instead.

The code that you threw out was meant to turn lowercase into uppercase when
shift was pressed, and ctrl-codes to the control range (ctr-a -> 0x1). Now
we always get 'a', no matter which modifiers are pressed. (The modifiers
themselves are still reported correctly, of course.)

I don't say that the new behavior is wrong, but it'll break about *any*
keyboard using program out there. If this is to stay, then all of them have
to be adapted and do the conversion themselves.

Here's a comparison of what we got before and what we get now. The numbers
are getModKeyMask()-getKey().

Typing    before r10269                     with r10269
---------------------------------------------------------------------------
a         0000-0061 'a' shift:   ctrl:      0000-0061 'a' shift:   ctrl:
Shift-a   0001-0041 'A' shift: L ctrl:      0001-0061 'a' shift: L ctrl:
Ctrl-a    0004-0001     shift:   ctrl: L    0004-0061 'a' shift:   ctrl: L


I've got the attached patch applied to osgkeyboard.cpp ever since I worked on
GraphicsWindowX11.cpp. This outputs some more useful information than it does
normally.

m.
Index: osgkeyboard.cpp
===================================================================
--- osgkeyboard.cpp	(revision 10292)
+++ osgkeyboard.cpp	(working copy)
@@ -16,6 +16,8 @@
 *  THE SOFTWARE.
 */
 
+#include <iomanip>
+
 #include <osgViewer/Viewer>
 #include <osgViewer/ViewerEventHandlers>
 #include <osg/io_utils>
@@ -360,6 +362,8 @@
 
 
 
+#include <iostream>
+#include <iomanip>
 class KeyboardEventHandler : public osgGA::GUIEventHandler
 {
 public:
@@ -374,13 +378,13 @@
 
 //            osg::notify(osg::NOTICE)<<"Mouse "<<ea.getButtonMask()<<std::endl;
 
-            #define PRINT(mask) osg::notify(osg::NOTICE)<<#mask<<" ="<<(ea.getModKeyMask() & mask)<<std::endl;
+            #define PRINT(mask) //osg::notify(osg::NOTICE)<<#mask<<" ="<<(ea.getModKeyMask() & mask)<<std::endl;
             switch(ea.getEventType())
             {
                 case(osgGA::GUIEventAdapter::KEYDOWN):
                 case(osgGA::GUIEventAdapter::KEYUP):
                 {
-                    osg::notify(osg::NOTICE)<<std::endl;
+                    //osg::notify(osg::NOTICE)<<std::endl;
                     PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_SHIFT);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_SHIFT);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_ALT);
@@ -395,6 +399,30 @@
                     PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_HYPER);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_NUM_LOCK);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK);
+
+                    unsigned mask = ea.getModKeyMask();
+                    unsigned key = ea.getKey();
+                    using namespace std;
+                    #define isfoo(c) (isgraph(c) && !isspace(c) || c == ' ')
+                    #define EA osgGA::GUIEventAdapter
+                    #define MOD(m) (mask & EA::MODKEY_LEFT_##m ? 'L' : ' ') << (mask & EA::MODKEY_RIGHT_##m ? 'R' : ' ')
+                    cerr
+                        << (ea.getEventType() == EA::KEYDOWN ? "\033[32m" : "\033[31m")
+                        << hex << setfill('0') << setw(4) << mask << dec << "-"
+                        << hex << setfill('0') << setw(4) << key << dec << "  "
+                        << (isfoo(key) ? '\'' : ' ')
+                        << (isfoo(key) ? char(key) : ' ')
+                        << (isfoo(key) ? '\'' : ' ')
+                        << "\033[m  "
+                        << "shift: " << MOD(SHIFT) << "  "
+                        << "alt: " << MOD(ALT) << "  "
+                        << "ctrl: " << MOD(CTRL) << "  "
+                        << "meta: " << MOD(META) << "  "
+                        << "super: " << MOD(SUPER) << "  "
+                        << "hyper: " << MOD(HYPER) << "  "
+                        << "numlock: " << (mask & EA::MODKEY_NUM_LOCK) << "  "
+                        << "capslock: " << (mask & EA::MODKEY_CAPS_LOCK) << "  "
+                        << endl;
                     break;
                 }
                 default:
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to