Generate mouse/keyboard events from your mouse.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
interception/MouseDll/event.cpp

64 lines
2.0 KiB

#include "event.hpp"
#include "globals.hpp"
using namespace std ;
// --- CONSTRUCTORS ----------------------------------------------------
Event::Event( const ApiEvent* pEvent , const ApiAction* pActions , int nActions )
: mEventType( (eEventType)pEvent->mEventType )
, mKeyboardState( pEvent->mKeyModifiers )
{
// initialize the Event
for ( int i=0 ; i < nActions ; ++i )
mActions.push_back( Action::allocAction( pActions+i ) ) ;
}
// ---------------------------------------------------------------------
Event::eEventType Event::eventType() const { return mEventType ; }
const KeyboardState& Event::keyboardState() const { return mKeyboardState ; }
const ActionPtrVector& Event::actions() const { return mActions ; }
// ---------------------------------------------------------------------
void
Event::dumpEvent( ostream& os , const char* pPrefix ) const
{
// dump the Event
os << pPrefix << *this << ":" << endl ;
for ( ActionPtrVector::const_iterator it=actions().begin() ; it != actions().end() ; ++it )
os << pPrefix << " " << *(*it) << endl ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ostream&
operator<<( ostream& os , const Event& evt )
{
// insert the Event
os << "{Event:" << evt.eventType() ;
if ( evt.keyboardState().isAnythingDown() )
os << ":" << evt.keyboardState() ;
os << "}" ;
return os ;
}
ostream&
operator<<( ostream& os , const Event::eEventType& eventType )
{
// insert the eEventType
static EnumStringInfo stringTable[] = {
{ Event::etMouseLeft , "mouseLeft" } ,
{ Event::etMouseRight , "mouseRight" } ,
{ Event::etMouseUp , "mouseUp" } ,
{ Event::etMouseDown , "mouseDown" } ,
{ Event::etWheelLeft , "wheelLeft" } ,
{ Event::etWheelRight , "wheelRight" } ,
{ Event::etWheelUp , "wheelUp" } ,
{ Event::etWheelDown , "wheelDown" } ,
{ -1 , NULL }
} ;
os << enumString(stringTable,eventType) ;
return os ;
}