3
3
#ifndef CTYPES_H_
4
4
#define CTYPES_H_1
5
5
6
+ #include "pico.h"
7
+
8
+
9
+ /* -------------------- Some Basic emums -------------------- */
10
+
6
11
// Mouse tracking speed modifier
7
12
enum LED_STATE {
8
13
LED_OFF = 0 ,
9
14
LED_ON = 1 ,
10
15
LED_UNKNOWN_DEVICE = 2 ,
11
16
LED_UNKNOWN_DEVICE_1 = 3 ,
12
- LED_SERIAL_CONNECTED = 4 ,
13
- LED_SERIAL_CONNECTED_1 = 5 ,
14
- LED_SERIAL_DISCONNECTED = 6 ,
15
- LED_SERIAL_DISCONNECTED_1 = 7 ,
16
- };
17
-
18
- // Mouse tracking speed modifier
19
- enum MO_SPEED {
20
- SPEED100 = 0 , // 100% speed
21
- SPEED75 = 1 , // 75% speed
22
- SPEED50 = 2 , // 50% speed
23
- SPEED25 = 3 // 50% speed
17
+ LED_SERIAL_CONNECTED = 4 ,
18
+ LED_SERIAL_CONNECTED_1 = 5 ,
19
+ LED_SERIAL_DISCONNECTED = 6 ,
20
+ LED_SERIAL_DISCONNECTED_1 = 7 ,
24
21
};
25
22
26
23
// Mouse Type enum
@@ -37,30 +34,155 @@ enum PC_INIT_STATES {
37
34
CTS_TOGGLED = 2 // CTS was low, now high -> do ident.
38
35
};
39
36
40
- typedef struct { // Mouse report information
37
+ /* -------------------- Mouse Packet Structure -------------------- */
38
+ /* This is the hold the mouse state for the previous cycle.
39
+ Each cycle is defined by the Baud rate. */
40
+
41
+ typedef struct {
42
+ // State of left, middle and right buttons
41
43
bool left , middle , right ;
44
+
45
+ // mouse location delta
42
46
int16_t x , y , wheel ;
47
+
48
+ // Is update required this cycle?
43
49
bool update ;
50
+
44
51
} MOUSE_PKT ;
45
52
46
- typedef struct { // Mouse Settings and information
47
- uint8_t speed ; // Mouse Tracking Speed
48
- uint8_t type ; // Mouse Type
49
- uint8_t pc_state ; // CTS state tracker | taken from Aviancer's code since it was more straightforward than what I had already
50
- MOUSE_PKT mpkt ; // Current Mouse Packet
53
+ /* -------------------- Raw Mouse Packet Structure -------------------- */
54
+ /* This is the hold the mouse state for the previous cycle.
55
+ Each cycle is defined by the Baud rate. */
56
+ typedef struct {
57
+
58
+ // The Button Flip Flop | Left Click + Middle Click + Right Click
59
+ bool btnFlipFlop [3 ];
60
+
61
+ // FlipFlop Cycle Update Flag | Left Click + Middle Click + Right Click
62
+ bool btnUpdated [3 ];
63
+
64
+ // FlipFlop toggle flag | Left Click + Middle Click + Right Click
65
+ bool btnToggle [3 ];
66
+
67
+ // Mouse location delta | X + Y + Wheel
68
+ int16_t x , y , wheel ;
69
+
70
+ // Is update required this cycle?
71
+ //bool update;
72
+
73
+ } MOUSE_RPKT ;
74
+
75
+ /* -------------------- Persistent Data Structure -------------------- */
76
+ /* This is to hold the mouse data that is to survive hard reboots */
77
+
78
+ typedef struct {
79
+ // 255 = first time execution | false = ran before.
80
+ uint8_t firstrun ;
81
+
82
+ // global limit | Range 1 -> 200
83
+ uint8_t xytravel_percentage ;
84
+
85
+ // seperate x and y limits. | Range 1 -> 200
86
+ uint8_t xtravel_percentage ;
87
+ uint8_t ytravel_percentage ;
88
+
89
+ // TWOBTN = 0 | THREEBTN = 1 | WHEELBTN = 2
90
+ uint8_t mousetype ;
91
+
92
+ // Double Stop Bit
93
+ // 7N1 = 0 | 7N2 = 1
94
+ bool doublestopbit ;
95
+
96
+ // Baud rate
97
+ // 1200 | 2400 | 4800 | 9600
98
+ uint16_t baudrate ;
99
+
100
+ // Swap the left and right buttons
101
+ bool swap_left_right ;
102
+
103
+ // use forward and backward as ALT left and right buttons
104
+ bool use_forward_backward ;
105
+
106
+ // Swap forward and backwards
107
+ bool swap_forward_backward ;
108
+
109
+ // Invert X and Y movement
110
+ bool invert_x ;
111
+ bool invert_y ;
112
+
113
+ // Firmware Versioning
114
+ uint8_t FW_V_MAJOR ;
115
+ uint8_t FW_V_MINOR ;
116
+ uint8_t FW_V_REVISION ;
117
+
118
+ // Previous DipSwitch Button State
119
+ bool ST_DIPSW_THREEBTN ; // DIP 1
120
+ bool ST_DIPSW_WHEEL ; // DIP 2
121
+ bool ST_DIPSW_75XYSPEED ; // DIP 3
122
+ bool ST_DIPSW_50XYSPEED ; // DIP 4
123
+ bool ST_DIPSW_7N2 ; // DIP 5
124
+ bool ST_DIPSW_2400 ; // DIP 6
125
+
126
+ } PERSISTENT_MOUSE_DATA ;
127
+
128
+ extern PERSISTENT_MOUSE_DATA pmData ;
129
+
130
+ /* -------------------- Mouse Settings -------------------- */
131
+ // Mouse Settings and information
132
+
133
+ typedef struct {
134
+
135
+ // CTS state tracker | taken from Aviancer's code since it was more straightforward than what I had already
136
+ uint8_t pc_state ;
137
+
138
+ // serial state tracker. 0 = Mouse mode | 1 = terminal mode.
139
+ uint8_t serial_state ;
140
+
141
+ // Current Processed Mouse Packet.
142
+ MOUSE_PKT mpkt ;
143
+
144
+ // Raw Mouse data.
145
+ MOUSE_RPKT rmpkt ;
146
+
147
+ // Persisten Mouse data, survives reboots.
148
+ PERSISTENT_MOUSE_DATA persistent ;
149
+
150
+ // One Byte Delay Time, calculated on startup.
151
+ int32_t serialdelay_1B ;
152
+
153
+ // Three Byte Delay Time, calculated on startup.
154
+ int32_t serialdelay_3B ;
155
+
156
+ // Four Byte Delay Time, calculated on startup.
157
+ int32_t serialdelay_4B ;
158
+
159
+ // M3Z | Ident info serial mouse.
160
+ uint8_t intro_pkts [3 ];
161
+
162
+ // Is mouse connected flag
163
+ bool mouse_conn ;
164
+
51
165
} MOUSE_DATA ;
52
166
167
+ // Extern value, declared again in usb-2-232.c, can be used everywhere ctypes is included.
168
+ extern MOUSE_DATA mouse_data ;
169
+
170
+
171
+ /* -------------------- Make the file work stuff -------------------- */
172
+
53
173
#if CTYPES_C_
54
174
55
175
enum MO_SPEED MO_SPEED ;
56
176
enum MO_TYPE MO_TYPE ;
57
177
enum PC_INIT_STATES PC_INIT_STATES ;
178
+ //PersistentData persistentData;
58
179
59
180
#else
60
181
61
182
extern enum MO_SPEED MO_SPEED ;
62
183
extern enum MO_TYPE MO_TYPE ;
63
184
extern enum PC_INIT_STATES PC_INIT_STATES ;
185
+ //extern PersistentData persistentData;
64
186
65
187
#endif
66
188
0 commit comments