The GUIEventAdapter header file had KeySymbols for the super and
hyper keys defined already, but these modifiers were missing in
GUIEventAdapter::ModKeyMask, and the EventQueue ingored them as well.

The attached diff/archive adds the missing parts for Super/Hyper
modifier key support.


I'm aware that this might not be supported on all systems/keyboards
out of the box, but decided to submit it anyway because:

- developers are aware of differences between input devices
  (Some mice have scroll wheels, others don't. Some have five or
  more buttons, some have only one. Some keyboards don't have
  numpads, some have AltGr, some don't etc.)

- even if someone relies on Hyper/Super in distributed software,
  this is easy to fix and doesn't create lock-in conditions

- while the names Hyper/Super may only be common on X11, they are
  just symbol names and not OS-specific

- even though some systems might not offer these additional modifiers
  by default, it's likely that all of them have at least 8 modifier
  levels internally, so it should only be a matter of OS configuration
  to make them work

- having super/hyper available is useful to offer a user ways
  to define local key definitions that are safe from collisions with
  predefined "official" key assignments



Changed Files:
  src/osgGA/EventQueue.cpp             
  include/osgGA/GUIEventAdapter
  src/osgViewer/GraphicsWindowX11.cpp
  examples/osgkeyboard/osgkeyboard.cpp

m.
Index: examples/osgkeyboard/osgkeyboard.cpp
===================================================================
--- examples/osgkeyboard/osgkeyboard.cpp	(revision 8066)
+++ examples/osgkeyboard/osgkeyboard.cpp	(working copy)
@@ -389,6 +389,10 @@
                     PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_CTRL);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_META);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_META);
+                    PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_SUPER);
+                    PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_SUPER);
+                    PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_HYPER);
+                    PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_HYPER);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_NUM_LOCK);
                     PRINT(osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK);
                     break;
Index: src/osgViewer/GraphicsWindowX11.cpp
===================================================================
--- src/osgViewer/GraphicsWindowX11.cpp	(revision 8066)
+++ src/osgViewer/GraphicsWindowX11.cpp	(working copy)
@@ -105,19 +105,23 @@
             _keymap[XK_semicolon    ] = ';';
             _keymap[XK_apostrophe   ] = '\'';
             _keymap[XK_Return       ] = osgGA::GUIEventAdapter::KEY_Return;
-            _keymap[XK_Shift_L      ] = osgGA::GUIEventAdapter::KEY_Shift_L;
             _keymap[XK_comma        ] = ',';
             _keymap[XK_period       ] = '.';
             _keymap[XK_slash        ] = '/';
+            _keymap[XK_space        ] = ' ';
+            _keymap[XK_Shift_L      ] = osgGA::GUIEventAdapter::KEY_Shift_L;
             _keymap[XK_Shift_R      ] = osgGA::GUIEventAdapter::KEY_Shift_R;
             _keymap[XK_Control_L    ] = osgGA::GUIEventAdapter::KEY_Control_L;
-            _keymap[XK_Super_L      ] = osgGA::GUIEventAdapter::KEY_Super_L;
-            _keymap[XK_space        ] = ' ';
+            _keymap[XK_Control_R    ] = osgGA::GUIEventAdapter::KEY_Control_R;
+            _keymap[XK_Meta_L       ] = osgGA::GUIEventAdapter::KEY_Meta_L;
+            _keymap[XK_Meta_R       ] = osgGA::GUIEventAdapter::KEY_Meta_R;
             _keymap[XK_Alt_L        ] = osgGA::GUIEventAdapter::KEY_Alt_L;
             _keymap[XK_Alt_R        ] = osgGA::GUIEventAdapter::KEY_Alt_R;
+            _keymap[XK_Super_L      ] = osgGA::GUIEventAdapter::KEY_Super_L;
             _keymap[XK_Super_R      ] = osgGA::GUIEventAdapter::KEY_Super_R;
+            _keymap[XK_Hyper_L      ] = osgGA::GUIEventAdapter::KEY_Hyper_L;
+            _keymap[XK_Hyper_R      ] = osgGA::GUIEventAdapter::KEY_Hyper_R;
             _keymap[XK_Menu         ] = osgGA::GUIEventAdapter::KEY_Menu;
-            _keymap[XK_Control_R    ] = osgGA::GUIEventAdapter::KEY_Control_R;
             _keymap[XK_Print        ] = osgGA::GUIEventAdapter::KEY_Print;
             _keymap[XK_Scroll_Lock  ] = osgGA::GUIEventAdapter::KEY_Scroll_Lock;
             _keymap[XK_Pause        ] = osgGA::GUIEventAdapter::KEY_Pause;
Index: src/osgGA/EventQueue.cpp
===================================================================
--- src/osgGA/EventQueue.cpp	(revision 8066)
+++ src/osgGA/EventQueue.cpp	(working copy)
@@ -275,6 +275,10 @@
         case(GUIEventAdapter::KEY_Meta_R):       _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_RIGHT_META | _accumulateEventState->getModKeyMask()); break;
         case(GUIEventAdapter::KEY_Alt_L):        _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_LEFT_ALT | _accumulateEventState->getModKeyMask()); break;
         case(GUIEventAdapter::KEY_Alt_R):        _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_RIGHT_ALT | _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Super_L):      _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_LEFT_SUPER | _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Super_R):      _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_RIGHT_SUPER | _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Hyper_L):      _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_LEFT_HYPER | _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Hyper_R):      _accumulateEventState->setModKeyMask(GUIEventAdapter::MODKEY_RIGHT_HYPER | _accumulateEventState->getModKeyMask()); break;
         case(GUIEventAdapter::KEY_Caps_Lock):
         {
             if ((_accumulateEventState->getModKeyMask() & GUIEventAdapter::MODKEY_CAPS_LOCK)!=0) 
@@ -314,6 +318,10 @@
         case(GUIEventAdapter::KEY_Meta_R):       _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_RIGHT_META & _accumulateEventState->getModKeyMask()); break;
         case(GUIEventAdapter::KEY_Alt_L):        _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_LEFT_ALT & _accumulateEventState->getModKeyMask()); break;
         case(GUIEventAdapter::KEY_Alt_R):        _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_RIGHT_ALT & _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Super_L):      _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_LEFT_SUPER & _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Super_R):      _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_RIGHT_SUPER & _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Hyper_L):      _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_LEFT_HYPER & _accumulateEventState->getModKeyMask()); break;
+        case(GUIEventAdapter::KEY_Hyper_R):      _accumulateEventState->setModKeyMask(~GUIEventAdapter::MODKEY_RIGHT_HYPER & _accumulateEventState->getModKeyMask()); break;
         default: break;
     }        
 
Index: include/osgGA/GUIEventAdapter
===================================================================
--- include/osgGA/GUIEventAdapter	(revision 8066)
+++ include/osgGA/GUIEventAdapter	(working copy)
@@ -208,18 +208,24 @@
         {
             MODKEY_LEFT_SHIFT  = 0x0001,
             MODKEY_RIGHT_SHIFT = 0x0002,
-            MODKEY_LEFT_CTRL   = 0x0040,
-            MODKEY_RIGHT_CTRL  = 0x0080,
-            MODKEY_LEFT_ALT    = 0x0100,
-            MODKEY_RIGHT_ALT   = 0x0200,
-            MODKEY_LEFT_META   = 0x0400,
-            MODKEY_RIGHT_META  = 0x0800,
+            MODKEY_LEFT_CTRL   = 0x0004,
+            MODKEY_RIGHT_CTRL  = 0x0008,
+            MODKEY_LEFT_ALT    = 0x0010,
+            MODKEY_RIGHT_ALT   = 0x0020,
+            MODKEY_LEFT_META   = 0x0040,
+            MODKEY_RIGHT_META  = 0x0080,
+            MODKEY_LEFT_SUPER  = 0x0100,
+            MODKEY_RIGHT_SUPER = 0x0200,
+            MODKEY_LEFT_HYPER  = 0x0400,
+            MODKEY_RIGHT_HYPER = 0x0800,
             MODKEY_NUM_LOCK    = 0x1000,
             MODKEY_CAPS_LOCK   = 0x2000,
             MODKEY_CTRL        = (MODKEY_LEFT_CTRL|MODKEY_RIGHT_CTRL),
             MODKEY_SHIFT       = (MODKEY_LEFT_SHIFT|MODKEY_RIGHT_SHIFT),
             MODKEY_ALT         = (MODKEY_LEFT_ALT|MODKEY_RIGHT_ALT),
-            MODKEY_META        = (MODKEY_LEFT_META|MODKEY_RIGHT_META)
+            MODKEY_META        = (MODKEY_LEFT_META|MODKEY_RIGHT_META),
+            MODKEY_SUPER       = (MODKEY_LEFT_SUPER|MODKEY_RIGHT_SUPER),
+            MODKEY_HYPER       = (MODKEY_LEFT_HYPER|MODKEY_RIGHT_HYPER)
         };
 
         enum MouseYOrientation

Attachment: superhyper.tar.bz2
Description: application/tbz

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

Reply via email to