Merge pull request #2313 from OTHGMars/MousePos

Switches to absolute position for mouse tracking.
This commit is contained in:
Areloch 2019-03-31 14:16:52 -05:00 committed by GitHub
commit 14fdd84d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 25 deletions

View file

@ -33,7 +33,6 @@ extern InputModifiers convertModifierBits(const U32 in);
// Constructor/Destructor // Constructor/Destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
WindowInputGenerator::WindowInputGenerator( PlatformWindow *window ) : WindowInputGenerator::WindowInputGenerator( PlatformWindow *window ) :
mNotifyPosition(true),
mWindow(window), mWindow(window),
mInputController(NULL), mInputController(NULL),
mLastCursorPos(0,0), mLastCursorPos(0,0),
@ -135,6 +134,7 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S
// Because of this we always have to generate and send off for processing // Because of this we always have to generate and send off for processing
// relative events, even if the mouse is not locked. // relative events, even if the mouse is not locked.
// I'm considering removing this in the Canvas refactor, thoughts? [7/6/2007 justind] // I'm considering removing this in the Canvas refactor, thoughts? [7/6/2007 justind]
// Now sends the absolute position event whenever an absolute position is received from the OS. [2/13/2019 mar]
// Generate a base Movement along and Axis event // Generate a base Movement along and Axis event
InputEventInfo event; InputEventInfo event;
@ -192,33 +192,23 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S
} }
// When the window gains focus, we send a cursor position event // We use SI_MAKE to signify that the position is being set, not relatively moved.
if( mNotifyPosition ) event.action = SI_MAKE;
{
mNotifyPosition = false;
// We use SI_MAKE to signify that the position is being set, not relatively moved. // X Axis
event.action = SI_MAKE; event.objInst = SI_XAXIS;
event.fValue = (F32)x;
generateInputEvent(event);
// X Axis // Y Axis
event.objInst = SI_XAXIS; event.objInst = SI_YAXIS;
event.fValue = (F32)x; event.fValue = (F32)y;
generateInputEvent(event); generateInputEvent(event);
// Y Axis
event.objInst = SI_YAXIS;
event.fValue = (F32)y;
generateInputEvent(event);
}
mLastCursorPos = Point2I(x,y); mLastCursorPos = Point2I(x,y);
} }
else else
{
mLastCursorPos += Point2I(x,y); mLastCursorPos += Point2I(x,y);
mNotifyPosition = true;
}
} }
void WindowInputGenerator::handleMouseButton( WindowId did, U32 modifiers, U32 action, U16 button ) void WindowInputGenerator::handleMouseButton( WindowId did, U32 modifiers, U32 action, U16 button )
@ -388,8 +378,6 @@ void WindowInputGenerator::handleAppEvent( WindowId did, S32 event )
} }
else if(event == GainFocus) else if(event == GainFocus)
{ {
// Set an update flag to notify the consumer of the absolute mouse position next move
mNotifyPosition = true;
mFocused = true; mFocused = true;
} }

View file

@ -37,8 +37,6 @@ class PlatformWindow;
class WindowInputGenerator class WindowInputGenerator
{ {
bool mNotifyPosition;
protected: protected:
PlatformWindow *mWindow; PlatformWindow *mWindow;