forked from hedgar2017/loki-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse.h
71 lines (55 loc) · 2.47 KB
/
mouse.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include "device.h"
#include <Windows.h>
#include <vector>
class Mouse : public Device
{
public:
explicit Mouse();
Mouse(const Mouse &) = delete;
void operator =(const Mouse &) = delete;
virtual ~Mouse() override = default;
virtual void initialize() override;
virtual void abort() override;
virtual void leftButtonDown();
virtual void leftButtonUp();
virtual void leftButtonClick();
virtual void rightButtonDown();
virtual void rightButtonUp();
virtual void rightButtonClick();
virtual void middleButtonDown();
virtual void middleButtonUp();
virtual void middleButtonClick();
virtual void moveCursor(POINT);
virtual void moveCursor(LONG x, LONG y);
protected:
enum Button {
BUTTON_NONE = 0x00,
BUTTON_LEFT = 0x01,
BUTTON_RIGHT = 0x02,
BUTTON_MIDDLE = 0x04
};
void populateRangeSpeedVector();
int getSpeedByRange(int range) const;
static int getRangeBySpeed(int speed);
static POINT getCurrentCursorPosition(LPDWORD error);
BYTE m_buttons {BUTTON_NONE};
std::vector<int> m_rangeSpeedVector;
static const BYTE REPORT_ID {0x02};
static const LONG MAX_ABSOLUTE_SPEED {127};
static const int DISTANCE_TOLERANCE {3};
static const int EPP_DISABLED {0};
static const int EPP_ENABLED {1};
static const int SENSITIVITY_MIN {1};
static const int SENSITIVITY_MAX {20};
private:
#pragma pack(1)
struct Report {
BYTE reportId;
BYTE buttons;
CHAR x;
CHAR y;
};
#pragma pack()
virtual void sendMouseReport(CHAR xSpeed, CHAR ySpeed);
};