summaryrefslogtreecommitdiff
path: root/hid/lib/drivers-stm32/usb/mouse-relative-stm32.h
diff options
context:
space:
mode:
Diffstat (limited to 'hid/lib/drivers-stm32/usb/mouse-relative-stm32.h')
-rw-r--r--hid/lib/drivers-stm32/usb/mouse-relative-stm32.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/hid/lib/drivers-stm32/usb/mouse-relative-stm32.h b/hid/lib/drivers-stm32/usb/mouse-relative-stm32.h
index 76e3e974..3bf42d91 100644
--- a/hid/lib/drivers-stm32/usb/mouse-relative-stm32.h
+++ b/hid/lib/drivers-stm32/usb/mouse-relative-stm32.h
@@ -19,14 +19,16 @@
# #
*****************************************************************************/
+
#pragma once
+#include <USBComposite.h>
+
#include "mouse.h"
#include "hid-wrapper-stm32.h"
-#include <USBComposite.h>
-namespace DRIVERS {
+namespace DRIVERS {
const uint8_t reportDescriptionMouseRelative[] = {
HID_MOUSE_REPORT_DESCRIPTOR()
};
@@ -43,18 +45,26 @@ namespace DRIVERS {
}
void clear() override {
- _mouse.release(0xff);
+ _mouse.release(0xFF);
}
void sendButtons (
- bool left_select, bool left_state,
- bool right_select, bool right_state,
- bool middle_select, bool middle_state,
- bool up_select, bool up_state,
- bool down_select, bool down_state) override {
- if(left_select) left_state ? _mouse.press(MOUSE_LEFT) : _mouse.release(MOUSE_LEFT);
- if(right_select) right_state ? _mouse.press(MOUSE_RIGHT) : _mouse.release(MOUSE_RIGHT);
- if(middle_select) middle_state ? _mouse.press(MOUSE_MIDDLE) : _mouse.release(MOUSE_MIDDLE);
+ bool left_select, bool left_state,
+ bool right_select, bool right_state,
+ bool middle_select, bool middle_state,
+ bool up_select, bool up_state,
+ bool down_select, bool down_state) override {
+
+# define SEND_BUTTON(x_low, x_up) { \
+ if (x_low##_select) { \
+ if (x_low##_state) _mouse.press(MOUSE_##x_up); \
+ else _mouse.release(MOUSE_##x_up); \
+ } \
+ }
+ SEND_BUTTON(left, LEFT);
+ SEND_BUTTON(right, RIGHT);
+ SEND_BUTTON(middle, MIDDLE);
+# undef SEND_BUTTON
}
void sendRelative(int x, int y) override {
@@ -66,7 +76,7 @@ namespace DRIVERS {
}
bool isOffline() override {
- return USBComposite == false;
+ return (USBComposite == false);
}
private: