hid: Move mouse::stop from base to the specific implementation

Instead of doing the stop in the base class, delegate it to the specific
implementation. Do this to avoid depending on the exact shape and layout of the
mouse report within the base class.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/1060/head
Gergely Nagy 4 years ago
parent a04525d718
commit f496aaa5d5
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -30,6 +30,7 @@ class NoMouse {
void begin() {}
void sendReport() {}
void move(int8_t x, int8_t y, int8_t vWheel, int8_t hWheel) {}
void stop(bool x, bool y, bool vWheel, bool hWheel) {}
void releaseAll() {}
void press(uint8_t buttons) {}
void release(uint8_t buttons) {}
@ -63,17 +64,7 @@ class Mouse {
mouse_.move(x, y, vWheel, hWheel);
}
void stop(bool x, bool y, bool vWheel = false, bool hWheel = false) {
HID_MouseReport_Data_t report = mouse_.getReport();
if (x)
report.xAxis = 0;
if (y)
report.yAxis = 0;
if (vWheel)
report.vWheel = 0;
if (hWheel)
report.hWheel = 0;
move(report.xAxis, report.yAxis, report.vWheel, report.hWheel);
mouse_.stop(x, y, vWheel, hWheel);
}
void releaseAllButtons() {
mouse_.releaseAll();

@ -50,6 +50,20 @@ class MouseWrapper {
void move(int8_t x, int8_t y, int8_t vWheel, int8_t hWheel) {
Mouse.move(x, y, vWheel, hWheel);
}
void stop(bool x, bool y, bool vWheel = false, bool hWheel = false) {
HID_MouseReport_Data_t report = Mouse.getReport();
if (x)
report.xAxis = 0;
if (y)
report.yAxis = 0;
if (vWheel)
report.vWheel = 0;
if (hWheel)
report.hWheel = 0;
move(report.xAxis, report.yAxis, report.vWheel, report.hWheel);
}
void releaseAll() {
Mouse.releaseAll();
}

Loading…
Cancel
Save