| | 116 | }; |
| | 117 | |
| | 118 | class EventDumperEventHandler : public osgGA::GUIEventHandler { |
| | 119 | |
| | 120 | public: |
| | 121 | bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) |
| | 122 | { |
| | 123 | if (ea.getEventType() == osgGA::GUIEventAdapter::FRAME) |
| | 124 | return false; |
| | 125 | |
| | 126 | static std::map<osgGA::GUIEventAdapter::EventType, std::string> type_mapping; |
| | 127 | if (type_mapping.size() == 0) |
| | 128 | { |
| | 129 | type_mapping[osgGA::GUIEventAdapter::NONE] = "NONE"; |
| | 130 | type_mapping[osgGA::GUIEventAdapter::PUSH] = "PUSH"; |
| | 131 | type_mapping[osgGA::GUIEventAdapter::RELEASE] = "RELEASE"; |
| | 132 | type_mapping[osgGA::GUIEventAdapter::DOUBLECLICK] = "DOUBLECLICK"; |
| | 133 | type_mapping[osgGA::GUIEventAdapter::DRAG] = "DRAG"; |
| | 134 | type_mapping[osgGA::GUIEventAdapter::MOVE] = "MOVE"; |
| | 135 | type_mapping[osgGA::GUIEventAdapter::KEYDOWN] = "KEYDOWN"; |
| | 136 | type_mapping[osgGA::GUIEventAdapter::KEYUP] = "KEYUP"; |
| | 137 | type_mapping[osgGA::GUIEventAdapter::FRAME] = "FRAME"; |
| | 138 | type_mapping[osgGA::GUIEventAdapter::RESIZE] = "RESIZE"; |
| | 139 | type_mapping[osgGA::GUIEventAdapter::SCROLL] = "SCROLL"; |
| | 140 | type_mapping[osgGA::GUIEventAdapter::PEN_PRESSURE] = "PEN_PRESSURE"; |
| | 141 | type_mapping[osgGA::GUIEventAdapter::PEN_ORIENTATION] = "PEN_ORIENTATION"; |
| | 142 | type_mapping[osgGA::GUIEventAdapter::PEN_PROXIMITY_ENTER] = "PEN_PROXIMITY_ENTER"; |
| | 143 | type_mapping[osgGA::GUIEventAdapter::PEN_PROXIMITY_LEAVE] = "PEN_PROXIMITY_LEAVE"; |
| | 144 | type_mapping[osgGA::GUIEventAdapter::CLOSE_WINDOW] = "CLOSE_WINDOW"; |
| | 145 | type_mapping[osgGA::GUIEventAdapter::QUIT_APPLICATION] = "QUIT_APPLICATION"; |
| | 146 | type_mapping[osgGA::GUIEventAdapter::USER] = "USER"; |
| | 147 | } |
| | 148 | |
| | 149 | static std::map<osgGA::GUIEventAdapter::TabletPointerType, std::string> pen_mapping; |
| | 150 | if (pen_mapping.size() == 0) { |
| | 151 | pen_mapping[osgGA::GUIEventAdapter::UNKNOWN] = "UNKNOWN"; |
| | 152 | pen_mapping[osgGA::GUIEventAdapter::PEN] = "PEN"; |
| | 153 | pen_mapping[osgGA::GUIEventAdapter::PUCK] = "BUCK"; |
| | 154 | pen_mapping[osgGA::GUIEventAdapter::ERASER] = "ERASER"; |
| | 155 | } |
| | 156 | |
| | 157 | std::cout << type_mapping[ea.getEventType()] << " with "; |
| | 158 | |
| | 159 | switch (ea.getEventType()) { |
| | 160 | case osgGA::GUIEventAdapter::PUSH: |
| | 161 | case osgGA::GUIEventAdapter::RELEASE: |
| | 162 | case osgGA::GUIEventAdapter::DOUBLECLICK: |
| | 163 | case osgGA::GUIEventAdapter::DRAG: |
| | 164 | case osgGA::GUIEventAdapter::MOVE: |
| | 165 | std::cout << ea.getX() << "/" << ea.getY() << " modifiers: " << ea.getModKeyMask() << std::endl; |
| | 166 | break; |
| | 167 | |
| | 168 | case osgGA::GUIEventAdapter::SCROLL: |
| | 169 | std::cout << ea.getX() << "/" << ea.getY() << " scroll: "; |
| | 170 | switch (ea.getScrollingMotion()) { |
| | 171 | case osgGA::GUIEventAdapter::SCROLL_NONE: |
| | 172 | std::cout << "NONE"; |
| | 173 | break; |
| | 174 | case osgGA::GUIEventAdapter::SCROLL_LEFT: |
| | 175 | std::cout << "SCROLL_LEFT"; |
| | 176 | break; |
| | 177 | case osgGA::GUIEventAdapter::SCROLL_RIGHT: |
| | 178 | std::cout << "SCROLL_RIGHT"; |
| | 179 | break; |
| | 180 | case osgGA::GUIEventAdapter::SCROLL_UP: |
| | 181 | std::cout << "SCROLL_UP"; |
| | 182 | break; |
| | 183 | case osgGA::GUIEventAdapter::SCROLL_DOWN: |
| | 184 | std::cout << "SCROLL_DOWN"; |
| | 185 | break; |
| | 186 | case osgGA::GUIEventAdapter::SCROLL_2D: |
| | 187 | std::cout << "SCROLL_2D"; |
| | 188 | break; |
| | 189 | |
| | 190 | } |
| | 191 | std::cout << " (" << ea.getScrollingDeltaX() << "/" << ea.getScrollingDeltaY() << ") modifiers: " << ea.getModKeyMask() << std::endl; |
| | 192 | break; |
| | 193 | |
| | 194 | case osgGA::GUIEventAdapter::KEYUP: |
| | 195 | case osgGA::GUIEventAdapter::KEYDOWN: |
| | 196 | std::cout << ea.getKey() << " modifiers: " << ea.getModKeyMask() << std::endl; |
| | 197 | break; |
| | 198 | |
| | 199 | case osgGA::GUIEventAdapter::RESIZE: |
| | 200 | std::cout << pen_mapping[ea.getTabletPointerType()] << ": " << ea.getWindowX() << "/" << ea.getWindowY() << " " << ea.getWindowWidth() << "x" << ea.getWindowHeight() << std::endl; |
| | 201 | break; |
| | 202 | |
| | 203 | case osgGA::GUIEventAdapter::PEN_PRESSURE: |
| | 204 | std::cout << pen_mapping[ea.getTabletPointerType()] << ": " << ea.getPenPressure() << " tiltx: " << ea.getPenTiltY() << " tilty: " << ea.getPenTiltY() << std::endl; |
| | 205 | break; |
| | 206 | |
| | 207 | case osgGA::GUIEventAdapter::PEN_ORIENTATION: |
| | 208 | std::cout << pen_mapping[ea.getTabletPointerType()] << ": " << ea.getPenOrientation() << std::endl; |
| | 209 | break; |
| | 210 | |
| | 211 | case osgGA::GUIEventAdapter::PEN_PROXIMITY_ENTER: |
| | 212 | case osgGA::GUIEventAdapter::PEN_PROXIMITY_LEAVE: |
| | 213 | std::cout << pen_mapping[ea.getTabletPointerType()] << std::endl; |
| | 214 | break; |
| | 215 | |
| | 216 | default: |
| | 217 | std::cout << std::endl; |
| | 218 | } |
| | 219 | |
| | 220 | return false; |
| | 221 | } |