Commit a30d79db authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[ADD #41] keyboard logging

parent 4321ff00
......@@ -31,7 +31,7 @@ WClickHandler::WClickHandler( WMPointConnector* connector ):
bool WClickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>( &aa );
osgViewer::Viewer* viewer = dynamic_cast< osgViewer::Viewer* >( &aa );
if( ea.getEventType() == osgGA::GUIEventAdapter::RELEASE && ea.getButton() != osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON )
{
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WKeyboardHandler.h"
WKeyboardHandler::WKeyboardHandler( WMPointConnector* connector ):
m_connector( connector )
{
}
bool WKeyboardHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if( ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN )
{
std::cout << "DOWN KEY:\t\t\t" << ea.getKey() << std::endl;
std::cout << "\tUnmodified Key:\t\t" << ea.getUnmodifiedKey() << std::endl;
std::cout << "\tModKeyMask:\t\t"<< ea.getModKeyMask() << std::endl;
}
if( ea.getEventType() == osgGA::GUIEventAdapter::KEYUP )
{
std::cout << "UP KEY:\t\t\t\t" << ea.getKey() << std::endl;
std::cout << "\tUnmodified Key:\t\t" << ea.getUnmodifiedKey() << std::endl;
std::cout << "\tModKeyMask:\t\t"<< ea.getModKeyMask() << std::endl;
}
return false;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WKEYBOARDHANDLER_H
#define WKEYBOARDHANDLER_H
#include <iostream>
#include <string>
#include <osg/Geode>
#include <osg/Viewport>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Viewer>
#include "WMPointConnector.h"
/**
* Forward declartion for the WMPointConnector
*/
class WMPointConnector;
/**
* The click handler for the mouse keyboard events of WMPointConnector
*/
class WKeyboardHandler : public osgGA::GUIEventHandler
{
public:
/**
* Constructs one WKeyboardHandler.
* \param connector The WMPointConnector this handler belongs to.
*/
explicit WKeyboardHandler( WMPointConnector* connector );
/**
* The callback for the event listener.
* \param ea The Adapter of the event.
* \param aa The Adapter of the action.
* \return Whether the event should be passed on.
*/
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
private:
/**
* The WMPointConnector this handler belongs to.
*/
WMPointConnector* m_connector;
bool m_isCtrl = false;
};
#endif // WKEYBOARDHANDLER_H
......@@ -27,6 +27,7 @@
#include "WConnectorData.h"
#include "WClickHandler.h"
#include "WKeyboardHandler.h"
#include "WFiberHandler.h"
#include "WMPointConnector.h"
......@@ -87,7 +88,7 @@ void WMPointConnector::moduleMain()
m_moduleState.add( m_pointInput->getDataChangedCondition() );
createPointRenderer();
createClickHandler();
createHandler();
ready();
......@@ -115,11 +116,13 @@ void WMPointConnector::createPointRenderer()
m_properties->addProperty( m_pointRenderer->getProperties()->getProperty( "Point Size" ) );
}
void WMPointConnector::createClickHandler()
void WMPointConnector::createHandler()
{
osg::ref_ptr< osgViewer::View > viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getView();
osg::ref_ptr< WClickHandler > handler = new WClickHandler( this );
viewer->addEventHandler( handler.get() );
osg::ref_ptr< WClickHandler > clickHandler = new WClickHandler( this );
viewer->addEventHandler( clickHandler.get() );
osg::ref_ptr< WKeyboardHandler > keyboardHandler = new WKeyboardHandler( this );
viewer->addEventHandler( keyboardHandler.get() );
}
void WMPointConnector::handleInput()
......
......@@ -155,9 +155,9 @@ private:
void createPointRenderer();
/**
* Creates the WClickHandler and registers it.
* Creates the WClickHandler and the WKeyboardHandler and registers them.
*/
void createClickHandler();
void createHandler();
/**
* Handles the input of this module.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment