forked from lian/msfs2020-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.go
228 lines (200 loc) · 5.99 KB
/
defs.go
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package simconnect
import "fmt"
// MSFS-SDK/SimConnect\ SDK/include/SimConnect.h
const E_FAIL uint32 = 0x80004005
type DWORD uint32
const UNUSED DWORD = 0xffffffff // special value to indicate unused event, ID
const OBJECT_ID_USER DWORD = 0 // proxy value for User vehicle ObjectID
const (
DATATYPE_INVALID DWORD = iota // invalid data type
DATATYPE_INT32 // 32-bit integer number
DATATYPE_INT64 // 64-bit integer number
DATATYPE_FLOAT32 // 32-bit floating-point number (float)
DATATYPE_FLOAT64 // 64-bit floating-point number (double)
DATATYPE_STRING8 // 8-byte string
DATATYPE_STRING32 // 32-byte string
DATATYPE_STRING64 // 64-byte string
DATATYPE_STRING128 // 128-byte string
DATATYPE_STRING256 // 256-byte string
DATATYPE_STRING260 // 260-byte string
DATATYPE_STRINGV // variable-length string
DATATYPE_INITPOSITION // see SIMCONNECT_DATA_INITPOSITION
DATATYPE_MARKERSTATE // see SIMCONNECT_DATA_MARKERSTATE
DATATYPE_WAYPOINT // see SIMCONNECT_DATA_WAYPOINT
DATATYPE_LATLONALT // see SIMCONNECT_DATA_LATLONALT
DATATYPE_XYZ // see SIMCONNECT_DATA_XYZ
DATATYPE_MAX // enum limit
)
const (
TEXT_TYPE_SCROLL_BLACK DWORD = iota
TEXT_TYPE_SCROLL_WHITE
TEXT_TYPE_SCROLL_RED
TEXT_TYPE_SCROLL_GREEN
TEXT_TYPE_SCROLL_BLUE
TEXT_TYPE_SCROLL_YELLOW
TEXT_TYPE_SCROLL_MAGENTA
TEXT_TYPE_SCROLL_CYAN
)
const (
TEXT_TYPE_PRINT_BLACK DWORD = iota + 0x0100
TEXT_TYPE_PRINT_WHITE
TEXT_TYPE_PRINT_RED
TEXT_TYPE_PRINT_GREEN
TEXT_TYPE_PRINT_BLUE
TEXT_TYPE_PRINT_YELLOW
TEXT_TYPE_PRINT_MAGENTA
TEXT_TYPE_PRINT_CYAN
)
const TEXT_TYPE_MENU DWORD = 0x0200
// Notification Group priority values
const GROUP_PRIORITY_HIGHEST DWORD = 1 // highest priority
const GROUP_PRIORITY_HIGHEST_MASKABLE DWORD = 10000000 // highest priority that allows events to be masked
const GROUP_PRIORITY_STANDARD DWORD = 1900000000 // standard priority
const GROUP_PRIORITY_DEFAULT DWORD = 2000000000 // default priority
const GROUP_PRIORITY_LOWEST DWORD = 4000000000 // priorities lower than this will be ignored
func derefDataType(fieldType string) (DWORD, error) {
var dataType DWORD
switch fieldType {
case "int32":
dataType = DATATYPE_INT32
case "int64":
dataType = DATATYPE_INT64
case "float32":
dataType = DATATYPE_FLOAT32
case "float64":
dataType = DATATYPE_FLOAT64
case "[8]byte":
dataType = DATATYPE_STRING8
case "[32]byte":
dataType = DATATYPE_STRING32
case "[64]byte":
dataType = DATATYPE_STRING64
case "[128]byte":
dataType = DATATYPE_STRING128
case "[256]byte":
dataType = DATATYPE_STRING256
case "[260]byte":
dataType = DATATYPE_STRING260
default:
return 0, fmt.Errorf("DATATYPE not implemented: %s", fieldType)
}
return dataType, nil
}
const (
RECV_ID_NULL DWORD = iota
RECV_ID_EXCEPTION
RECV_ID_OPEN
RECV_ID_QUIT
RECV_ID_EVENT
RECV_ID_EVENT_OBJECT_ADDREMOVE
RECV_ID_EVENT_FILENAME
RECV_ID_EVENT_FRAME
RECV_ID_SIMOBJECT_DATA
RECV_ID_SIMOBJECT_DATA_BYTYPE
RECV_ID_WEATHER_OBSERVATION
RECV_ID_CLOUD_STATE
RECV_ID_ASSIGNED_OBJECT_ID
RECV_ID_RESERVED_KEY
RECV_ID_CUSTOM_ACTION
RECV_ID_SYSTEM_STATE
RECV_ID_CLIENT_DATA
RECV_ID_EVENT_WEATHER_MODE
RECV_ID_AIRPORT_LIST
RECV_ID_VOR_LIST
RECV_ID_NDB_LIST
RECV_ID_WAYPOINT_LIST
RECV_ID_EVENT_MULTIPLAYER_SERVER_STARTED
RECV_ID_EVENT_MULTIPLAYER_CLIENT_STARTED
RECV_ID_EVENT_MULTIPLAYER_SESSION_ENDED
RECV_ID_EVENT_RACE_END
RECV_ID_EVENT_RACE_LAP
RECV_ID_PICK
)
const (
SIMOBJECT_TYPE_USER DWORD = iota
SIMOBJECT_TYPE_ALL
SIMOBJECT_TYPE_AIRCRAFT
SIMOBJECT_TYPE_HELICOPTER
SIMOBJECT_TYPE_BOAT
SIMOBJECT_TYPE_GROUND
)
const (
FACILITY_LIST_TYPE_AIRPORT DWORD = iota
FACILITY_LIST_TYPE_WAYPOINT
FACILITY_LIST_TYPE_NDB
FACILITY_LIST_TYPE_VOR
FACILITY_LIST_TYPE_COUNT // invalid
)
type Recv struct {
Size DWORD
Version DWORD
ID DWORD
}
type RecvOpen struct {
Recv
ApplicationName [256]byte
ApplicationVersionMajor DWORD
ApplicationVersionMinor DWORD
ApplicationBuildMajor DWORD
ApplicationBuildMinor DWORD
SimConnectVersionMajor DWORD
SimConnectVersionMinor DWORD
SimConnectBuildMajor DWORD
SimConnectBuildMinor DWORD
Reserved1 DWORD
Reserved2 DWORD
}
type RecvEvent struct {
Recv
//static const DWORD UNKNOWN_GROUP = DWORD_MAX;
GroupID DWORD
EventID DWORD
Data DWORD // uEventID-dependent context
}
type RecvSimobjectData struct {
Recv
RequestID DWORD
ObjectID DWORD
DefineID DWORD
Flags DWORD // SIMCONNECT_DATA_REQUEST_FLAG
entrynumber DWORD // if multiple objects returned, this is number <entrynumber> out of <outof>.
outof DWORD // note: starts with 1, not 0.
DefineCount DWORD // data count (number of datums, *not* byte count)
//SIMCONNECT_DATAV( dwData, dwDefineID, ); // data begins here, dwDefineCount data items
}
type RecvSimobjectDataByType struct {
RecvSimobjectData
}
type RecvException struct {
Recv
Exception DWORD // see SIMCONNECT_EXCEPTION
//static const DWORD UNKNOWN_SENDID = 0;
SendID DWORD // see SimConnect_GetLastSentPacketID
//static const DWORD UNKNOWN_INDEX = DWORD_MAX;
Index DWORD // index of parameter that was source of error
}
type RecvFacilityList struct {
Recv
RequestID DWORD
ArraySize DWORD
EntryNumber DWORD // when the array of items is too big for one send, which send this is (0..dwOutOf-1)
OutOf DWORD // total number of transmissions the list is chopped into
}
type RecvFacilityAirportList struct {
RecvFacilityList
List [1]DataFacilityAirport
}
type DataFacilityAirport struct {
Icao [9]byte // ICAO of the object
Latitude float64 // degrees
Longitude float64 // degrees
Altitude float64 // meters
}
type RecvFacilityWaypointList struct {
RecvFacilityList
List [1]DataFacilityWaypoint
}
type DataFacilityWaypoint struct {
DataFacilityAirport
MagVar float64 // Magvar in degrees
}