Skip to content

Commit b5cd376

Browse files
Updated USBComposite library. Thanks to @arpruss
1 parent 6a9c795 commit b5cd376

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1792
-1532
lines changed
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
#include "USBHID.h"
2-
3-
//================================================================================
4-
//================================================================================
5-
// Mouse
6-
7-
void HIDAbsMouse::begin(void){
8-
}
9-
10-
void HIDAbsMouse::end(void){
11-
}
12-
13-
void HIDAbsMouse::click(uint8_t b)
14-
{
15-
report.wheel = 0;
16-
report.buttons = b;
17-
sendReport();
18-
report.buttons = 0;
19-
sendReport();
20-
}
21-
22-
void HIDAbsMouse::move(int16 x, int16 y, int8 wheel)
23-
{
24-
report.x = x;
25-
report.y = y;
26-
report.wheel = wheel;
27-
28-
sendReport();
29-
}
30-
31-
void HIDAbsMouse::buttons(uint8_t b)
32-
{
33-
if (b != report.buttons)
34-
{
35-
report.wheel = 0;
36-
report.buttons = b;
37-
sendReport();
38-
}
39-
}
40-
41-
void HIDAbsMouse::press(uint8_t b)
42-
{
43-
buttons(report.buttons | b);
44-
}
45-
46-
void HIDAbsMouse::release(uint8_t b)
47-
{
48-
buttons(report.buttons & ~b);
49-
}
50-
51-
bool HIDAbsMouse::isPressed(uint8_t b)
52-
{
53-
if ((b & report.buttons) != 0)
54-
return true;
55-
return false;
56-
}
1+
#include "USBComposite.h"
2+
3+
//================================================================================
4+
//================================================================================
5+
// Mouse
6+
7+
void HIDAbsMouse::begin(void){
8+
}
9+
10+
void HIDAbsMouse::end(void){
11+
}
12+
13+
void HIDAbsMouse::click(uint8_t b)
14+
{
15+
report.wheel = 0;
16+
report.buttons = b;
17+
sendReport();
18+
report.buttons = 0;
19+
sendReport();
20+
}
21+
22+
void HIDAbsMouse::move(int16 x, int16 y, int8 wheel)
23+
{
24+
report.x = x;
25+
report.y = y;
26+
report.wheel = wheel;
27+
28+
sendReport();
29+
}
30+
31+
void HIDAbsMouse::buttons(uint8_t b)
32+
{
33+
if (b != report.buttons)
34+
{
35+
report.wheel = 0;
36+
report.buttons = b;
37+
sendReport();
38+
}
39+
}
40+
41+
void HIDAbsMouse::press(uint8_t b)
42+
{
43+
buttons(report.buttons | b);
44+
}
45+
46+
void HIDAbsMouse::release(uint8_t b)
47+
{
48+
buttons(report.buttons & ~b);
49+
}
50+
51+
bool HIDAbsMouse::isPressed(uint8_t b)
52+
{
53+
if ((b & report.buttons) != 0)
54+
return true;
55+
return false;
56+
}

STM32F1/libraries/USBComposite/BootKeyboard.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include "USBHID.h"
2-
3-
void HIDConsumer::begin(void) {}
4-
void HIDConsumer::end(void) {}
5-
void HIDConsumer::press(uint16_t button) {
6-
report.button = button;
7-
sendReport();
8-
}
9-
10-
void HIDConsumer::release() {
11-
report.button = 0;
12-
sendReport();
13-
}
1+
#include "USBComposite.h"
2+
3+
void HIDConsumer::begin(void) {}
4+
void HIDConsumer::end(void) {}
5+
void HIDConsumer::press(uint16_t button) {
6+
report.button = button;
7+
sendReport();
8+
}
9+
10+
void HIDConsumer::release() {
11+
report.button = 0;
12+
sendReport();
13+
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#include "USBHID.h"
2-
3-
#define REPORT(name, ...) \
4-
static uint8_t raw_ ## name[] = { __VA_ARGS__ }; \
5-
static const HIDReportDescriptor desc_ ## name = { raw_ ##name, sizeof(raw_ ##name) }; \
6-
const HIDReportDescriptor* hidReport ## name = & desc_ ## name;
7-
8-
REPORT(KeyboardMouseJoystick, HID_MOUSE_REPORT_DESCRIPTOR(), HID_KEYBOARD_REPORT_DESCRIPTOR(), HID_JOYSTICK_REPORT_DESCRIPTOR());
9-
REPORT(KeyboardMouse, HID_MOUSE_REPORT_DESCRIPTOR(), HID_KEYBOARD_REPORT_DESCRIPTOR());
10-
REPORT(Keyboard, HID_KEYBOARD_REPORT_DESCRIPTOR());
11-
REPORT(Mouse, HID_MOUSE_REPORT_DESCRIPTOR());
12-
REPORT(KeyboardJoystick, HID_KEYBOARD_REPORT_DESCRIPTOR(), HID_JOYSTICK_REPORT_DESCRIPTOR());
13-
REPORT(Joystick, HID_JOYSTICK_REPORT_DESCRIPTOR());
14-
REPORT(BootKeyboard, HID_BOOT_KEYBOARD_REPORT_DESCRIPTOR());
1+
#include "USBComposite.h"
2+
3+
#define REPORT(name, ...) \
4+
static uint8_t raw_ ## name[] = { __VA_ARGS__ }; \
5+
static const HIDReportDescriptor desc_ ## name = { raw_ ##name, sizeof(raw_ ##name) }; \
6+
const HIDReportDescriptor* hidReport ## name = & desc_ ## name;
7+
8+
REPORT(KeyboardMouseJoystick, HID_MOUSE_REPORT_DESCRIPTOR(), HID_KEYBOARD_REPORT_DESCRIPTOR(), HID_JOYSTICK_REPORT_DESCRIPTOR());
9+
REPORT(KeyboardMouse, HID_MOUSE_REPORT_DESCRIPTOR(), HID_KEYBOARD_REPORT_DESCRIPTOR());
10+
REPORT(Keyboard, HID_KEYBOARD_REPORT_DESCRIPTOR());
11+
REPORT(Mouse, HID_MOUSE_REPORT_DESCRIPTOR());
12+
REPORT(KeyboardJoystick, HID_KEYBOARD_REPORT_DESCRIPTOR(), HID_JOYSTICK_REPORT_DESCRIPTOR());
13+
REPORT(Joystick, HID_JOYSTICK_REPORT_DESCRIPTOR());
14+
REPORT(BootKeyboard, HID_BOOT_KEYBOARD_REPORT_DESCRIPTOR());

0 commit comments

Comments
 (0)