SL-11592 [Mac] Ability to bind extra mouse buttons for push to talk

andreykproductengine 2019-07-18 19:18:02 +03:00
parent ba2429163a
commit a0bf70b41d
6 changed files with 54 additions and 35 deletions

View File

@ -444,7 +444,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMiddleMouseDown(mMousePos, [theEvent modifierFlags]);
callOtherMouseDown(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);
}
- (void) otherMouseUp:(NSEvent *)theEvent
@ -452,7 +452,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMiddleMouseUp(mMousePos, [theEvent modifierFlags]);
callOtherMouseUp(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);
}
- (void) rightMouseDragged:(NSEvent *)theEvent

View File

@ -150,8 +150,8 @@ void callWindowHide();
void callWindowUnhide();
void callWindowDidChangeScreen();
void callDeltaUpdate(float *delta, unsigned int mask);
void callMiddleMouseDown(float *pos, unsigned int mask);
void callMiddleMouseUp(float *pos, unsigned int mask);
void callOtherMouseDown(float *pos, unsigned int mask, int button);
void callOtherMouseUp(float *pos, unsigned int mask, int button);
void callFocus();
void callFocusLost();
void callModifier(unsigned int mask);

View File

@ -417,7 +417,7 @@ void callDeltaUpdate(float *delta, MASK mask)
gWindowImplementation->updateMouseDeltas(delta);
}
void callMiddleMouseDown(float *pos, MASK mask)
void callOtherMouseDown(float *pos, MASK mask, int button)
{
LLCoordGL outCoords;
outCoords.mX = ll_round(pos[0]);
@ -426,10 +426,17 @@ void callMiddleMouseDown(float *pos, MASK mask)
gWindowImplementation->getMouseDeltas(deltas);
outCoords.mX += deltas[0];
outCoords.mY += deltas[1];
gWindowImplementation->getCallbacks()->handleMiddleMouseDown(gWindowImplementation, outCoords, mask);
if (button == 3)
{
gWindowImplementation->getCallbacks()->handleMiddleMouseDown(gWindowImplementation, outCoords, mask);
}
else
{
gWindowImplementation->getCallbacks()->handleOtherMouseDown(gWindowImplementation, outCoords, mask, button);
}
}
void callMiddleMouseUp(float *pos, MASK mask)
void callOtherMouseUp(float *pos, MASK mask, int button)
{
LLCoordGL outCoords;
outCoords.mX = ll_round(pos[0]);
@ -437,8 +444,15 @@ void callMiddleMouseUp(float *pos, MASK mask)
float deltas[2];
gWindowImplementation->getMouseDeltas(deltas);
outCoords.mX += deltas[0];
outCoords.mY += deltas[1];
gWindowImplementation->getCallbacks()->handleMiddleMouseUp(gWindowImplementation, outCoords, mask);
outCoords.mY += deltas[1];
if (button == 3)
{
gWindowImplementation->getCallbacks()->handleMiddleMouseUp(gWindowImplementation, outCoords, mask);
}
else
{
gWindowImplementation->getCallbacks()->handleOtherMouseUp(gWindowImplementation, outCoords, mask, button);
}
}
void callModifier(MASK mask)

View File

@ -2567,7 +2567,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
MASK mask = gKeyboard->currentMask(TRUE);
// generate move event to update mouse coordinates
window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask);
if (window_imp->mCallbacks->handleOtherMouseDown(window_imp, gl_coord, mask, button))
// Windows uses numbers 1 and 2 for buttons, remap to 4, 5
if (window_imp->mCallbacks->handleOtherMouseDown(window_imp, gl_coord, mask, button + 3))
{
return 0;
}
@ -2597,7 +2598,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
MASK mask = gKeyboard->currentMask(TRUE);
// generate move event to update mouse coordinates
window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask);
if (window_imp->mCallbacks->handleOtherMouseUp(window_imp, gl_coord, mask, button))
// Windows uses numbers 1 and 2 for buttons, remap to 4, 5
if (window_imp->mCallbacks->handleOtherMouseUp(window_imp, gl_coord, mask, button + 3))
{
return 0;
}

View File

@ -217,7 +217,9 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down)
{
BOOL result = FALSE;
if (down && clicktype >= 3 && mask == 0)
if (down
&& (clicktype == LLMouseHandler::CLICK_MIDDLE || clicktype == LLMouseHandler::CLICK_BUTTON4 || clicktype == LLMouseHandler::CLICK_BUTTON5)
&& mask == 0)
{
mParent->setMouse(clicktype);
result = TRUE;
@ -1716,29 +1718,30 @@ void LLFloaterPreference::setKey(KEY key)
void LLFloaterPreference::setMouse(LLMouseHandler::EClickType click)
{
if (click >= LLMouseHandler::CLICK_MIDDLE)
std::string bt_name;
std::string ctrl_value;
switch (click)
{
case LLMouseHandler::CLICK_MIDDLE:
bt_name = "middle_mouse";
ctrl_value = MIDDLE_MOUSE_CV;
break;
case LLMouseHandler::CLICK_BUTTON4:
bt_name = "button4_mouse";
ctrl_value = MOUSE_BUTTON_4_CV;
break;
case LLMouseHandler::CLICK_BUTTON5:
bt_name = "button5_mouse";
ctrl_value = MOUSE_BUTTON_5_CV;
break;
default:
break;
}
if (!ctrl_value.empty())
{
std::string bt_name;
std::string ctrl_value;
switch (click)
{
case LLMouseHandler::CLICK_MIDDLE:
bt_name = "middle_mouse";
ctrl_value = MIDDLE_MOUSE_CV;
break;
case LLMouseHandler::CLICK_BUTTON4:
bt_name = "button4_mouse";
ctrl_value = MOUSE_BUTTON_4_CV;
break;
case LLMouseHandler::CLICK_BUTTON5:
bt_name = "button5_mouse";
ctrl_value = MOUSE_BUTTON_5_CV;
break;
default:
break;
}
// We are using text names for readability
LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
// We are using text control names for readability and compatibility with voice
p2t_line_editor->setControlValue(ctrl_value);
LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
if (advanced_preferences)

View File

@ -1288,11 +1288,11 @@ BOOL LLViewerWindow::handleOtherMouse(LLWindow *window, LLCoordGL pos, MASK mask
{
switch (button)
{
case 1:
case 4:
LLVoiceClient::getInstance()->updateMouseState(LLMouseHandler::CLICK_BUTTON4, down);
handleAnyMouseClick(window, pos, mask, LLMouseHandler::CLICK_BUTTON4, down);
break;
case 2:
case 5:
LLVoiceClient::getInstance()->updateMouseState(LLMouseHandler::CLICK_BUTTON5, down);
handleAnyMouseClick(window, pos, mask, LLMouseHandler::CLICK_BUTTON5, down);
break;