Skip to content

Commit e28dcf6

Browse files
author
Scott Vincent
committed
New release
1 parent b068b4a commit e28dcf6

File tree

8 files changed

+115
-5
lines changed

8 files changed

+115
-5
lines changed

instrument-data-link/LVars-PA28.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef _LVARS_PA28_H_
2+
#define _LVARS_PA28_H_
3+
4+
#include <stdio.h>
5+
6+
// LVars for Just Flight Piper Arrow PA-28R
7+
const char PA28_XPNDR_STATE[] = "L:KT76_mode_knob, number";
8+
9+
#endif // _LVARS_PA28_H_

instrument-data-link/instrument-data-link.cpp

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ bool isA310 = false;
6969
bool isA320 = false;
7070
bool is747 = false;
7171
bool isK100 = false;
72+
bool isPA28 = false;
7273
bool isAirliner = false;
7374
double lastHeading = 0;
7475
int lastSoftkey = 0;
@@ -213,6 +214,7 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
213214
isA320 = false;
214215
is747 = false;
215216
isK100 = false;
217+
isPA28 = false;
216218
isAirliner = false;
217219

218220
if (strncmp(simVars.aircraft, "A310", 4) == 0 || strncmp(simVars.aircraft, "Airbus A310", 11) == 0) {
@@ -230,6 +232,9 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
230232
else if (strncmp(simVars.aircraft, "Kodiak 100", 10) == 0) {
231233
isK100 = true;
232234
}
235+
else if (strncmp(simVars.aircraft, "Just Flight PA28", 16) == 0) {
236+
isPA28 = true;
237+
}
233238
else if (strncmp(simVars.aircraft, "Airbus", 6) == 0 || strncmp(simVars.aircraft, "Boeing", 6) == 0) {
234239
isAirliner = true;
235240
}
@@ -249,7 +254,7 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
249254
else {
250255
simVars.apuPercentRpm = 0;
251256
}
252-
simVars.suctionPressure = 5;
257+
253258
if (seatBeltsReplicateDelay > 0) {
254259
seatBeltsReplicateDelay--;
255260
}
@@ -373,6 +378,11 @@ void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContex
373378
simVars.elecBat1 = simVars.dcVolts > 0;
374379
}
375380

381+
if (simVars.connected && isAirliner && simVars.engineFuelFlow1 > 0 && simVars.suctionPressure < 0.001) {
382+
// Stop Annunciator reporting a vacuum fault on airliners
383+
simVars.suctionPressure = 5;
384+
}
385+
376386
if (simVars.altAboveGround > 50) {
377387
hasFlown = true;
378388
simVars.landingRate = -999;
@@ -550,6 +560,14 @@ void init()
550560
addReadDefs();
551561
mapEvents();
552562

563+
for (int i = 0; i < 7; i++) {
564+
if (i < 4) {
565+
simVars.sbEncoder[i] = 0;
566+
}
567+
simVars.sbButton[i] = 1;
568+
}
569+
simVars.sbMode = 3; // Autopilot / Radio / Instruments
570+
553571
// Start requesting data
554572
if (SimConnect_RequestDataOnSimObject(hSimConnect, REQ_ID, DEF_READ_ALL, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME, 0, 0, 0, 0) != 0) {
555573
printf("Failed to start requesting data\n");
@@ -934,6 +952,30 @@ void processG1000Events()
934952
time(&lastG1000Press);
935953
}
936954

955+
void processSwitchBox(int joyNum)
956+
{
957+
switch (joyNum) {
958+
case 1: simVars.sbEncoder[0]++; break;
959+
case 2: simVars.sbEncoder[0]--; break;
960+
case 3: simVars.sbButton[0]++; break;
961+
case 4: simVars.sbEncoder[1]++; break;
962+
case 5: simVars.sbEncoder[1]--; break;
963+
case 6: simVars.sbButton[1]++; break;
964+
case 7: simVars.sbEncoder[2]++; break;
965+
case 8: simVars.sbEncoder[2]--; break;
966+
case 9: simVars.sbButton[2]++; break;
967+
case 10: simVars.sbEncoder[3]++; break;
968+
case 11: simVars.sbEncoder[3]--; break;
969+
case 12: simVars.sbButton[3]++; break;
970+
case 13: simVars.sbButton[4]++; break;
971+
case 14: simVars.sbButton[5]++; break;
972+
case 15: simVars.sbButton[6]++; break;
973+
case 17: simVars.sbMode = 1; break; // Autopilot
974+
case 18: simVars.sbMode = 2; break; // Radio
975+
case 19: simVars.sbMode = 3; break; // Instruments
976+
}
977+
}
978+
937979
void processRequest()
938980
{
939981
if (request.requestedSize == writeDataSize) {
@@ -961,8 +1003,8 @@ void processRequest()
9611003

9621004
//// For testing only - Leave commented out
9631005
//if (request.writeData.eventId == KEY_CABIN_SEATBELTS_ALERT_SWITCH_TOGGLE) {
964-
// request.writeData.eventId = KEY_CABIN_SEATBELTS_ALERT_SWITCH_TOGGLE;
965-
// request.writeData.value = 1;
1006+
// request.writeData.eventId = KEY_COM2_VOLUME_SET;
1007+
// request.writeData.value = 0;
9661008
// printf("Intercepted event - Changed to: %d = %f\n", request.writeData.eventId, request.writeData.value);
9671009
//}
9681010
//else {
@@ -1006,6 +1048,9 @@ void processRequest()
10061048
else if (isK100 && jetbridgeK100ButtonPress(request.writeData.eventId, request.writeData.value)) {
10071049
return;
10081050
}
1051+
else if (isPA28 && jetbridgePA28ButtonPress(request.writeData.eventId, request.writeData.value)) {
1052+
return;
1053+
}
10091054
else if (jetbridgeMiscButtonPress(request.writeData.eventId, request.writeData.value)) {
10101055
return;
10111056
}
@@ -1054,6 +1099,22 @@ void processRequest()
10541099
processG1000Events();
10551100
}
10561101

1102+
if (request.writeData.eventId == SWITCHBOX_JOY) {
1103+
processSwitchBox(request.writeData.value);
1104+
if (request.writeData.value > 16) {
1105+
// Mode switch so send reply to client
1106+
EVENT_ID event;
1107+
if (strncmp(simVars.aircraft, "Cessna 152", 10) == 0) {
1108+
event = EVENT_IS_CESSNA_152;
1109+
}
1110+
else {
1111+
event = EVENT_NOT_CESSNA_152;
1112+
}
1113+
sendto(sockfd, (char*)&event, sizeof(int), 0, (SOCKADDR*)&senderAddr, addrSize);
1114+
}
1115+
return;
1116+
}
1117+
10571118
if (request.writeData.eventId == KEY_TOGGLE_RAMPTRUCK) {
10581119
printf("Ramp truck requested\n");
10591120
}

instrument-data-link/instrument-data-link.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
<ClInclude Include="LVars-A310.h" />
191191
<ClInclude Include="LVars-A32NX.h" />
192192
<ClInclude Include="LVars-Kodiak100.h" />
193+
<ClInclude Include="LVars-PA28.h" />
193194
<ClInclude Include="simvarDefs.h" />
194195
<ClInclude Include="vjoy.h" />
195196
</ItemGroup>

instrument-data-link/instrument-data-link.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ClInclude Include="LVars-Kodiak100.h" />
2626
<ClInclude Include="jetbridge.h" />
2727
<ClInclude Include="vjoy.h" />
28+
<ClInclude Include="LVars-PA28.h" />
2829
</ItemGroup>
2930
<ItemGroup>
3031
<None Include="C:\MSFS SDK\SimConnect SDK\VS\SimConnectClient-static.props" />

instrument-data-link/jetbridge.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "LVars-A310.h"
88
#include "LVars-A32NX.h"
99
#include "LVars-Kodiak100.h"
10+
#include "LVars-PA28.h"
1011

1112
extern SimVars simVars;
1213
extern LVars_A310 a310Vars;
@@ -508,6 +509,21 @@ bool jetbridgeK100ButtonPress(int eventId, double value)
508509
return false;
509510
}
510511

512+
bool jetbridgePA28ButtonPress(int eventId, double value)
513+
{
514+
switch (eventId) {
515+
case KEY_XPNDR_STATE:
516+
// Uses slightly different values
517+
if (value == 4) {
518+
value = 3;
519+
}
520+
writeJetbridgeVar(PA28_XPNDR_STATE, value);
521+
return true;
522+
}
523+
524+
return false;
525+
}
526+
511527
bool jetbridgeMiscButtonPress(int eventId, double value)
512528
{
513529
switch (eventId) {

instrument-data-link/jetbridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void updateA320FromJetbridge(const char* data);
2828
bool jetbridgeA310ButtonPress(int eventId, double value);
2929
bool jetbridgeA320ButtonPress(int eventId, double value);
3030
bool jetbridgeK100ButtonPress(int eventId, double value);
31+
bool jetbridgePA28ButtonPress(int eventId, double value);
3132
bool jetbridgeMiscButtonPress(int eventId, double value);
3233

3334
void readA310Jetbridge();

instrument-data-link/simvarDefs.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include "simvarDefs.h"
33

4-
const char* versionString = "v1.7.7";
4+
const char* versionString = "v1.7.8";
55

66
const char* SimVarDefs[][2] = {
77
// Vars for Jetbridge (must come first)
@@ -21,6 +21,18 @@ const char* SimVarDefs[][2] = {
2121
{ "Autobrake Armed", "jetbridge" },
2222
{ "Pitch Trim", "jetbridge" },
2323
{ "Tcas Mode", "jetbridge" },
24+
{ "SwitchBox Encoder 1", "jetbridge" },
25+
{ "SwitchBox Encoder 2", "jetbridge" },
26+
{ "SwitchBox Encoder 3", "jetbridge" },
27+
{ "SwitchBox Encoder 4", "jetbridge" },
28+
{ "SwitchBox Button 1", "jetbridge" },
29+
{ "SwitchBox Button 2", "jetbridge" },
30+
{ "SwitchBox Button 3", "jetbridge" },
31+
{ "SwitchBox Button 4", "jetbridge" },
32+
{ "SwitchBox Button 5", "jetbridge" },
33+
{ "SwitchBox Button 6", "jetbridge" },
34+
{ "SwitchBox Button 7", "jetbridge" },
35+
{ "SwitchBox Mode", "jetbridge" },
2436

2537
// Vars required for all panels (screensaver, aircraft identification etc.)
2638
{ "Title", "string32" },
@@ -96,7 +108,7 @@ const char* SimVarDefs[][2] = {
96108
{ "Airspeed True Calibrate", "degrees" },
97109
{ "Plane Heading Degrees True", "degrees" },
98110
{ "Plane Alt Above Ground", "feet" },
99-
{ "Turn Indicator Rate", "radians per second" },
111+
{ "Turn Indicator Rate", "degrees per second" },
100112
{ "Turn Coordinator Ball", "position" },
101113
{ "Elevator Trim Position", "degrees" },
102114
{ "Rudder Trim Pct", "percent" },
@@ -356,6 +368,9 @@ WriteEvent WriteEvents[] = {
356368
{ EVENT_LANDING_PREPARE_CABIN, "EVENT_LANDING_PREPARE_CABIN" },
357369
{ EVENT_SEATS_FOR_LANDING, "EVENT_SEATS_FOR_LANDING" },
358370
{ EVENT_GO_AROUND, "EVENT_GO_AROUND" },
371+
{ EVENT_IS_CESSNA_152, "EVENT_IS_CESSNA_152" },
372+
{ EVENT_NOT_CESSNA_152, "EVENT_NOT_CESSNA_152" },
373+
{ SWITCHBOX_JOY, "SWITCHBOX_JOY" },
359374
{ VJOY_BUTTONS, "VJOY_BUTTONS" },
360375
{ VJOY_BUTTON_1, "VJOY_BUTTON_1" },
361376
{ VJOY_BUTTON_2, "VJOY_BUTTON_2" },

instrument-data-link/simvarDefs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ struct SimVars
2424
double jbAutobrake = 0;
2525
double jbPitchTrim = 0;
2626
double jbTcasMode = 0;
27+
double sbEncoder[4]; // SwitchBox
28+
double sbButton[7]; // SwitchBox
29+
double sbMode; // SwitchBox
2730

2831
// Vars required for all panels (screensaver, aircraft identification etc.)
2932
char aircraft[32] = "\0";
@@ -360,6 +363,9 @@ enum EVENT_ID {
360363
EVENT_LANDING_PREPARE_CABIN,
361364
EVENT_SEATS_FOR_LANDING,
362365
EVENT_GO_AROUND,
366+
EVENT_IS_CESSNA_152,
367+
EVENT_NOT_CESSNA_152,
368+
SWITCHBOX_JOY,
363369
VJOY_BUTTONS,
364370
// Buttons must start from 1 and must be sequential until VJOY_BUTTONS_END
365371
VJOY_BUTTON_1,

0 commit comments

Comments
 (0)