summaryrefslogtreecommitdiff
path: root/indra/newview/lljoystickbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lljoystickbutton.cpp')
-rw-r--r--indra/newview/lljoystickbutton.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index bd6702a0b2..0acc67ff5a 100644
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -134,16 +134,33 @@ void LLJoystick::updateSlop()
return;
}
+bool LLJoystick::pointInCircle(S32 x, S32 y) const
+{
+ if(this->getLocalRect().mTop!=this->getLocalRect().mRight)
+ {
+ llwarns << "Joystick shape is not square"<<llendl;
+ return TRUE;
+ }
+ //center is x and y coordinates of center of joystick circle, and also its radius
+ int center = this->getLocalRect().mTop/2;
+ bool in_circle = (x - center) * (x - center) + (y - center) * (y - center) <= center * center;
+ return in_circle;
+}
BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
{
//llinfos << "joystick mouse down " << x << ", " << y << llendl;
+ bool handles = false;
- mLastMouse.set(x, y);
- mFirstMouse.set(x, y);
+ if(pointInCircle(x, y))
+ {
+ mLastMouse.set(x, y);
+ mFirstMouse.set(x, y);
+ mMouseDownTimer.reset();
+ handles = LLButton::handleMouseDown(x, y, mask);
+ }
- mMouseDownTimer.reset();
- return LLButton::handleMouseDown(x, y, mask);
+ return handles;
}