-
Notifications
You must be signed in to change notification settings - Fork 1
/
mouse_data.h
54 lines (44 loc) · 1.55 KB
/
mouse_data.h
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
#ifndef MOUSE_DATA_H
#define MOUSE_DATA_H
#include <Arduino.h>
/*
* Simple structure containing data baout the current state of a 2-button, 2-axis mouse
*/
struct MouseData {
byte leftButtonPressed; // Current state of the left button, 1 = pressed, 2 = not pressed
byte rightButtonPressed; // Current state of the right button, 1 = pressed, 2 = not pressed
char xDelta; // Current x-axis movement amount
char yDelta; // Current y-axis movement amount
void reset() {
this->leftButtonPressed = 0;
this->rightButtonPressed = 0;
this->xDelta = 0;
this->yDelta = 0;
}
};
/*
* Reads incoming serial data from a physical port and converts it into a MouseData struct
*/
class MouseDataProducer {
public:
virtual void initialize() {}
virtual int getSerialPortSpeed() {
return 1200;
}
virtual byte getSerialPortConfig() {
return SERIAL_7N1;
}
// Process an incoming serial byte. If the byte completes an entire packet
// of data, the supplied MouseData object is filled out and 1 is returned.
// Otherwise 0 is returned and no change is made to the supplied MouseData object
virtual int readIncomingSerialByte(byte, MouseData*) { return 0; }
};
/*
* Processes MouseData
*/
class MouseDataConsumer {
public:
virtual void initialize() {}
virtual void consumeMouseData(MouseData*) {}
};
#endif