forked from arpruss/USBComposite_stm32f1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AbsMouse.cpp
56 lines (46 loc) · 946 Bytes
/
AbsMouse.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "USBComposite.h"
//================================================================================
//================================================================================
// Mouse
void HIDAbsMouse::begin(void){
}
void HIDAbsMouse::end(void){
}
void HIDAbsMouse::click(uint8_t b)
{
report.wheel = 0;
report.buttons = b;
sendReport();
report.buttons = 0;
sendReport();
}
void HIDAbsMouse::move(int16 x, int16 y, int8 wheel)
{
report.x = x;
report.y = y;
report.wheel = wheel;
sendReport();
}
void HIDAbsMouse::buttons(uint8_t b)
{
if (b != report.buttons)
{
report.wheel = 0;
report.buttons = b;
sendReport();
}
}
void HIDAbsMouse::press(uint8_t b)
{
buttons(report.buttons | b);
}
void HIDAbsMouse::release(uint8_t b)
{
buttons(report.buttons & ~b);
}
bool HIDAbsMouse::isPressed(uint8_t b)
{
if ((b & report.buttons) != 0)
return true;
return false;
}