Skip to content

Commit

Permalink
Added support for extra mouse buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Nov 27, 2013
1 parent 011f921 commit f06278e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ void sendevent( int code, bool pressed, JoyButtonSlot::JoySlotInputAction device
temp[0].mi.dwFlags = 0x01000;
temp[0].mi.mouseData = pressed ? WHEEL_DELTA : 0;
}
else if (code == 8)
{
temp[0].mi.dwFlags = XBUTTON1;
temp[0].mi.mouseData = pressed ? WM_XBUTTONDOWN : WM_XBUTTONUP;
}
else if (code == 9)
{
temp[0].mi.dwFlags = XBUTTON2;
temp[0].mi.mouseData = pressed ? WM_XBUTTONDOWN : WM_XBUTTONUP;
}

SendInput(1, temp, sizeof(INPUT));
}
Expand Down
8 changes: 8 additions & 0 deletions src/joybuttonslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ QString JoyButtonSlot::getSlotString()
case 3:
newlabel.append(tr("RB"));
break;
#ifdef Q_OS_WIN
case 8:
newlabel.append(tr("B4"));
break;
case 9:
newlabel.append(tr("B5"));
break;
#endif
default:
newlabel.append(QString::number(deviceCode));
break;
Expand Down
24 changes: 24 additions & 0 deletions src/keyboard/virtualkeyboardmousewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ void VirtualKeyboardMouseWidget::setupMouseControlLayout()
pushButton->setSizePolicy(sizePolicy);
pushButton->setMinimumHeight(50);
tempVBoxLayout->addWidget(pushButton);

tempVBoxLayout->setStretch(0, 1);
tempVBoxLayout->setStretch(2, 1);
tempVBoxLayout->setStretch(4, 3);
Expand All @@ -366,6 +367,29 @@ void VirtualKeyboardMouseWidget::setupMouseControlLayout()

tempHBoxLayout->addSpacerItem(new QSpacerItem(10, 20, QSizePolicy::Fixed));

tempVBoxLayout = new QVBoxLayout();
tempVBoxLayout->setSpacing(20);
#ifdef Q_OS_WIN
pushButton = new VirtualMousePushButton(tr("Button 4"), 8, JoyButtonSlot::JoyMouseButton, this);
#else
pushButton = new VirtualMousePushButton(tr("Mouse 8"), 8, JoyButtonSlot::JoyMouseButton, this);
#endif

pushButton->setMinimumHeight(40);
tempVBoxLayout->addWidget(pushButton);
#ifdef Q_OS_WIN
pushButton = new VirtualMousePushButton(tr("Button 5"), 9, JoyButtonSlot::JoyMouseButton, this);
#else
pushButton = new VirtualMousePushButton(tr("Mouse 9"), 9, JoyButtonSlot::JoyMouseButton, this);
#endif

pushButton->setMinimumHeight(40);
tempVBoxLayout->addWidget(pushButton);
tempVBoxLayout->addSpacerItem(new QSpacerItem(20, 50, QSizePolicy::Minimum, QSizePolicy::Expanding));
tempHBoxLayout->addLayout(tempVBoxLayout);

tempHBoxLayout->addSpacerItem(new QSpacerItem(10, 20, QSizePolicy::Fixed));

tempVBoxLayout = new QVBoxLayout();
tempVBoxLayout->setSpacing(20);
tempVBoxLayout->addSpacerItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
Expand Down

0 comments on commit f06278e

Please sign in to comment.