Permalink
Browse files

Fix MMB use.

fixes ticket:2578

Also add mouse button state to LOG_INPUT
  • Loading branch information...
1 parent 23f318f commit b3dcccba1dc0cedd7e2463a223875bf004a22cb7 @buginator buginator committed Mar 24, 2011
Showing with 37 additions and 8 deletions.
  1. +37 −8 lib/framework/wzapp.cpp
View
45 lib/framework/wzapp.cpp
@@ -346,13 +346,31 @@ MOUSE_KEY_CODE WzMainWindow::buttonToIdx(Qt::MouseButton button)
switch (button)
{
- case Qt::LeftButton : idx = MOUSE_LMB; break;
- case Qt::RightButton : idx = MOUSE_RMB; break;
- case Qt::MidButton : idx = MOUSE_MMB; break;
- case Qt::XButton1 : idx = MOUSE_MMB; break;
- case Qt::XButton2 : idx = MOUSE_MMB; break;
+ case Qt::LeftButton:
+ idx = MOUSE_LMB;
+ debug(LOG_INPUT, "MOUSE_LMB clicked");
+ break;
+ case Qt::RightButton:
+ idx = MOUSE_RMB;
+ debug(LOG_INPUT, "MOUSE_RMB clicked");
+ break;
+ case Qt::MidButton:
+ idx = MOUSE_MMB;
+ debug(LOG_INPUT, "MOUSE_MMB clicked");
+ break;
+ case Qt::XButton1:
+ idx = MOUSE_MMB;
+ debug(LOG_INPUT, "MOUSE_MMB (Xbutton1) clicked");
+ break;
+ case Qt::XButton2:
+ idx = MOUSE_MMB;
+ debug(LOG_INPUT, "MOUSE_MMB (Xbutton2) clicked");
+ break;
default:
- case Qt::NoButton : idx = MOUSE_BAD; break; // strange case
+ case Qt::NoButton:
+ idx = MOUSE_BAD;
+ debug(LOG_INPUT, "NoButton (strange case ?");
+ break; // strange case
}
return idx;
@@ -851,7 +869,12 @@ void SetMousePos(uint16_t x, uint16_t y)
/* This returns true if the mouse key is currently depressed */
bool mouseDown(MOUSE_KEY_CODE code)
{
- return (aMouseState[code].state != KEY_UP);
+ return ((aMouseState[code].state != KEY_UP)
+ ||
+ // holding down LMB and RMB counts as holding down MMB
+ (code == MOUSE_MMB)
+ ||
+ (aMouseState[MOUSE_LMB].state != KEY_UP && aMouseState[MOUSE_RMB].state != KEY_UP));
}
/* This returns true if the mouse key was double clicked */
@@ -879,7 +902,13 @@ bool mouseReleased(MOUSE_KEY_CODE code)
/* Check for a mouse drag, return the drag start coords if dragging */
bool mouseDrag(MOUSE_KEY_CODE code, UDWORD *px, UDWORD *py)
{
- if (aMouseState[code].state == KEY_DRAG)
+
+ if ((aMouseState[code].state == KEY_DRAG)
+ ||
+ code == MOUSE_MMB )
+ ||
+ // dragging LMB and RMB counts as dragging MMB
+ (aMouseState[MOUSE_LMB].state != KEY_UP && aMouseState[MOUSE_RMB].state == KEY_DRAG))
{
*px = dragX;
*py = dragY;

0 comments on commit b3dcccb

Please sign in to comment.