Added the ability to adjust the speed of events.

master
Pacman Ghost 7 years ago
parent 7ef678fc25
commit 86ca9514b4
  1. 2
      MainApp/AppConfig.cs
  2. 23
      MouseDll/actions.cpp
  3. 3
      MouseDll/actions.hpp
  4. 1
      MouseDll/api.hpp

@ -92,6 +92,7 @@ namespace MouseInterception
}
public int mActionType ;
public int mKeyModifiers ;
public int mSpeed ;
}
public ApiAction[] mActions ;
public ApiAction[] actions { get { return mActions ; } }
@ -175,6 +176,7 @@ namespace MouseInterception
ApiAction action = new ApiAction() ;
action.mActionType = (int) Enum.Parse( typeof(ApiAction.ActionType) , actionXmlNode.Attributes["type"].Value , true ) ;
action.mKeyModifiers = getXmlNodeKeyModifiers( actionXmlNode ) ;
action.mSpeed = Utils.getXmlChildVal( actionXmlNode , "speed" , 0 ) ;
actions.Add( action ) ;
evt.mActionCount ++ ;
}

@ -8,6 +8,7 @@ using namespace std ;
Action::Action( const ApiAction* pAction )
: mKeyModifiers( pAction->mKeyModifiers )
, mSpeed( pAction->mSpeed )
{
}
@ -34,6 +35,17 @@ Action::allocAction( const ApiAction* pAction )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Action::adjustForSpeed( int val ) const
{
// NOTE: Speed values are percentages, offset by 100.
int percentDelta = 100 + speed() ;
if ( percentDelta <= 0 )
percentDelta = 1 ; // nb: never go below 0%, always return something
return val * percentDelta / 100 ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string
Action::asString() const
{
@ -42,6 +54,8 @@ Action::asString() const
buf << "<" << pActionName() ;
if ( keyModifiers() != 0 )
buf << ":" << keyModifiersString(keyModifiers()) ;
if ( speed() != 0 )
buf << ":" << speed() ;
buf << ">" ;
return buf.str() ;
}
@ -49,6 +63,7 @@ Action::asString() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Action::keyModifiers() const { return mKeyModifiers ; }
int Action::speed() const { return mSpeed ; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -75,6 +90,7 @@ MouseLeftAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "mouse move left" event
int scrollSize = (int) pInfo ;
scrollSize = scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendMouseMoveInput( -scrollSize , 0 , keyModifiers() ) ;
}
@ -97,6 +113,7 @@ MouseRightAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "mouse move right" event
int scrollSize = (int) pInfo ;
scrollSize = scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendMouseMoveInput( scrollSize , 0 , keyModifiers() ) ;
}
@ -119,6 +136,7 @@ MouseUpAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "mouse move up" event
int scrollSize = (int) pInfo ;
scrollSize = scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendMouseMoveInput( 0 , -scrollSize , keyModifiers() ) ;
}
@ -141,6 +159,7 @@ MouseDownAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "mouse move down" event
int scrollSize = (int) pInfo ;
scrollSize = scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendMouseMoveInput( 0 , scrollSize , keyModifiers() ) ;
}
@ -163,6 +182,7 @@ WheelLeftAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "scroll wheel left" event
int scrollSize = (int) pInfo ;
scrollSize = WHEEL_DELTA * scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendHorzWheelInput( -scrollSize , keyModifiers() ) ;
}
@ -185,6 +205,7 @@ WheelRightAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "scroll wheel left" event
int scrollSize = (int) pInfo ;
scrollSize = WHEEL_DELTA * scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendHorzWheelInput( scrollSize , keyModifiers() ) ;
}
@ -207,6 +228,7 @@ WheelUpAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "scroll wheel up" event
int scrollSize = (int) pInfo ;
scrollSize = WHEEL_DELTA * scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendWheelInput( scrollSize , keyModifiers() ) ;
}
@ -229,6 +251,7 @@ WheelDownAction::doAction( void* pInfo , CSendInput* pSendInput ) const
// send a "scroll wheel down" event
int scrollSize = (int) pInfo ;
scrollSize = WHEEL_DELTA * scrollSize / 100 ; // unscale the movement (100 = 1 unit)
scrollSize = adjustForSpeed( scrollSize ) ;
pSendInput->sendWheelInput( -scrollSize , keyModifiers() ) ;
}

@ -32,13 +32,16 @@ public:
// access methods:
public:
int keyModifiers() const ;
int speed() const ;
virtual std::string asString() const ;
protected:
virtual const char* pActionName() const = 0 ;
int adjustForSpeed( int val ) const ;
// data members:
private:
int mKeyModifiers ;
int mSpeed ;
} ;

@ -60,6 +60,7 @@ struct ApiAction
{
int mActionType ;
int mKeyModifiers ;
int mSpeed ;
} ;
// ---------------------------------------------------------------------

Loading…
Cancel
Save