add two new options: 1) remap wheel button 2) remap gesture button
thanks Paul Guertin for discovering the magic numbers
--- a/cadMousePro-daemon/src/CLIParser.h Tue Jun 09 16:10:20 2020 +0200
+++ b/cadMousePro-daemon/src/CLIParser.h Tue Jun 09 16:12:00 2020 +0200
@@ -49,6 +49,8 @@
static const std::wstring OPTION_FREQUENCY;
static const std::wstring OPTION_SMART_SCROLLING;
static const std::wstring OPTION_LIFT_OFF_DETECTION;
+ static const std::wstring OPTION_REMAP_WHEEL_PRESS;
+ static const std::wstring OPTION_REMAP_GESTURE_BUTTON;
static const std::wstring OPTION_DAEMON;
CLIConfiguration parse(const std::vector<std::wstring>& arguments) {
@@ -63,6 +65,10 @@
c.cadMouseConfig.setSmartScrolling(parseBoolean(readNext(arguments, i)));
} else if (option == OPTION_LIFT_OFF_DETECTION) {
c.cadMouseConfig.setLiftOffDetection(parseBoolean(readNext(arguments, i)));
+ } else if (option == OPTION_REMAP_WHEEL_PRESS) {
+ c.cadMouseConfig.setWheelPressRemapped(parseBoolean(readNext(arguments, i)));
+ } else if (option == OPTION_REMAP_GESTURE_BUTTON) {
+ c.cadMouseConfig.setRemapGestureButton(parseBoolean(readNext(arguments, i)));
} else if (option == OPTION_DAEMON) {
c.daemon = parseBoolean(readNext(arguments, i));
} else throw CLIException(L"Unsupported CLI option: " + option, CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
@@ -79,4 +85,6 @@
const std::wstring CLIParser::OPTION_FREQUENCY = L"--frequency";
const std::wstring CLIParser::OPTION_SMART_SCROLLING = L"--smart-scrolling";
const std::wstring CLIParser::OPTION_LIFT_OFF_DETECTION = L"--lift-off-detection";
+const std::wstring CLIParser::OPTION_REMAP_WHEEL_PRESS = L"--remap-wheel-press";
+const std::wstring CLIParser::OPTION_REMAP_GESTURE_BUTTON = L"--remap-gesture-button";
const std::wstring CLIParser::OPTION_DAEMON = L"--daemon";
--- a/cadMousePro-daemon/src/CadMouseConfig.h Tue Jun 09 16:10:20 2020 +0200
+++ b/cadMousePro-daemon/src/CadMouseConfig.h Tue Jun 09 16:12:00 2020 +0200
@@ -34,6 +34,8 @@
bool liftOffDetection = true;
bool smartScrolling = false;
Frequency frequency = Frequency::Hz_1000;
+ bool remapWheelPress = true;
+ bool remapGestureButton = true;
public:
void setFrequency(Frequency frequency) {
@@ -48,6 +50,22 @@
this->smartScrolling = smartScrolling;
}
+ /**
+ * @param remapGestureButton whether the gesture button (the small one behind the wheel)
+ * should send a button signal (11) otherwise it sends no button signal
+ */
+ void setRemapGestureButton(bool remapGestureButton) {
+ this->remapGestureButton = remapGestureButton;
+ }
+
+ /**
+ * @param remapWheelPress whether the wheel pressed
+ * should send different button signal (10) than the middle button (2)
+ */
+ void setWheelPressRemapped(bool remapWheelPress) {
+ this->remapWheelPress = remapWheelPress;
+ }
+
Packet serialize() {
Packet data;
data.reserve(32);
@@ -80,10 +98,10 @@
data.push_back(0x0a);
data.push_back(0x0b);
data.push_back(0x0c);
- data.push_back(0x0c);
+ data.push_back(remapWheelPress ? 0x0f : 0x0c);
data.push_back(0x0e);
data.push_back(0x0d);
- data.push_back(0x2f);
+ data.push_back(remapGestureButton ? 0x10 : 0x2f);
data.push_back(0x00);
data.push_back(0x1e);
--- a/cadMousePro-daemon/src/Daemon.h Tue Jun 09 16:10:20 2020 +0200
+++ b/cadMousePro-daemon/src/Daemon.h Tue Jun 09 16:12:00 2020 +0200
@@ -68,12 +68,14 @@
}
}
- void configure(bool liftOffDetection, bool smartScrolling, int frequency) {
+ void configure(bool liftOffDetection, bool smartScrolling, bool remapWheelPress, bool remapGestureButton, int frequency) {
std::wcout << L"configuring mouse" << std::endl;
try {
CadMouseConfig config;
config.setLiftOffDetection(liftOffDetection);
config.setSmartScrolling(smartScrolling);
+ config.setWheelPressRemapped(remapWheelPress);
+ config.setRemapGestureButton(remapGestureButton);
config.setFrequency(Common::parseFrequency(std::to_wstring(frequency)));
getMouse().sendFeatureReport(config.serialize());
} catch (HIDException& e) {
--- a/cadMousePro-gui/src/MouseMainWindow.cpp Tue Jun 09 16:10:20 2020 +0200
+++ b/cadMousePro-gui/src/MouseMainWindow.cpp Tue Jun 09 16:12:00 2020 +0200
@@ -46,7 +46,7 @@
statusBattery->setOrientation(Qt::Orientation::Horizontal);
statusBattery->setMinimum(0);
statusBattery->setMaximum(100);
-
+
statusUPower->setToolTip("UPower interface is used for getting the battery level");
statusName->setToolTip("name of the USB device – usually the wireless adaptor");
statusBattery->setToolTip("battery charge level");
@@ -71,8 +71,12 @@
int f = 0;
configureLiftOffDetection->setChecked(true);
+ configureRemapWheelPressed->setChecked(true);
+ configureRemapGestureButton->setChecked(true);
layout->setWidget(f++, QFormLayout::FieldRole, configureLiftOffDetection);
layout->setWidget(f++, QFormLayout::FieldRole, configureSmartScrolling);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureRemapWheelPressed);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureRemapGestureButton);
configureFrequency250->setChecked(true);
layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency125);
layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency250);
@@ -150,7 +154,12 @@
else if (configureFrequency1000->isChecked()) frequency = 1000;
else frequency = 250;
- auto response = proxy->configure(configureLiftOffDetection->isChecked(), configureSmartScrolling->isChecked(), frequency);
+ auto response = proxy->configure(
+ configureLiftOffDetection->isChecked(),
+ configureSmartScrolling->isChecked(),
+ configureRemapWheelPressed->isChecked(),
+ configureRemapGestureButton->isChecked(),
+ frequency);
response.waitForFinished();
if (response.isError()) message->setText("Error: " + response.error().message());
--- a/cadMousePro-gui/src/MouseMainWindow.h Tue Jun 09 16:10:20 2020 +0200
+++ b/cadMousePro-gui/src/MouseMainWindow.h Tue Jun 09 16:12:00 2020 +0200
@@ -48,6 +48,8 @@
QCheckBox* configureSmartScrolling = new QCheckBox("smart scrolling (free wheel)", this);
QCheckBox* configureLiftOffDetection = new QCheckBox("lift-off detection", this);
+ QCheckBox* configureRemapWheelPressed = new QCheckBox("remap wheel button: from 2 (same as middle) to 10", this);
+ QCheckBox* configureRemapGestureButton = new QCheckBox("remap gesture button: from none to 11", this);
QRadioButton* configureFrequency125 = new QRadioButton("125 Hz", this);
QRadioButton* configureFrequency250 = new QRadioButton("250 Hz", this);
QRadioButton* configureFrequency500 = new QRadioButton("500 Hz", this);
@@ -62,9 +64,9 @@
void initStatusPanel();
void initConfigurationPanel();
void initAboutPanel();
-
+
void appendAboutLine(QFormLayout* layout, const QString& label, const QString& value, QWidget* parent);
-
+
int getBatteryLevel();
private slots:
--- a/d-bus/info.globalcode.mouse.cadMousePro.xml Tue Jun 09 16:10:20 2020 +0200
+++ b/d-bus/info.globalcode.mouse.cadMousePro.xml Tue Jun 09 16:12:00 2020 +0200
@@ -16,6 +16,8 @@
<method name="configure">
<arg name="liftOffDetection" type="b" direction="in"/>
<arg name="smartScrolling" type="b" direction="in"/>
+ <arg name="remapWheelPress" type="b" direction="in"/>
+ <arg name="remapGestureButton" type="b" direction="in"/>
<arg name="frequency" type="i" direction="in"/>
</method>