-
Notifications
You must be signed in to change notification settings - Fork 76
/
Mouse.cpp
56 lines (45 loc) · 874 Bytes
/
Mouse.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
#include "USBComposite.h"
//================================================================================
//================================================================================
// Mouse
void HIDMouse::begin(void){
}
void HIDMouse::end(void){
}
void HIDMouse::click(uint8_t b)
{
_buttons = b;
move(0,0,0);
_buttons = 0;
move(0,0,0);
}
void HIDMouse::move(signed char x, signed char y, signed char wheel)
{
reportBuffer[1] = _buttons;
reportBuffer[2] = x;
reportBuffer[3] = y;
reportBuffer[4] = wheel;
sendReport();
}
void HIDMouse::buttons(uint8_t b)
{
if (b != _buttons)
{
_buttons = b;
move(0,0,0);
}
}
void HIDMouse::press(uint8_t b)
{
buttons(_buttons | b);
}
void HIDMouse::release(uint8_t b)
{
buttons(_buttons & ~b);
}
bool HIDMouse::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)
return true;
return false;
}