stm32 hid cleanup

This commit is contained in:
Maxim Devaev
2022-07-22 09:14:49 +03:00
parent d3dbf19399
commit 3a9b433000
12 changed files with 206 additions and 720 deletions

View File

@@ -19,14 +19,16 @@
# #
*****************************************************************************/
#pragma once
#include <USBComposite.h>
#include "mouse.h"
#include "hid-wrapper-stm32.h"
#include <USBComposite.h>
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: