diff --git a/.prettierrc b/.prettierrc
index 0967ef4..8ae55c4 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1 +1,3 @@
-{}
+{
+ "tabWidth": 2,
+}
diff --git a/TheWay.lua b/TheWay.lua
index d67e5af..d44db8d 100644
--- a/TheWay.lua
+++ b/TheWay.lua
@@ -38,6 +38,8 @@ local lastDevice = ""
local lastCode = ""
local lastNeedDepress = true
local whenToDepress = nil
+local moreWait = false
+local waitTime = nil
function LuaExportBeforeNextFrame()
if upstreamLuaExportBeforeNextFrame ~= nil then
successful, err = pcall(upstreamLuaExportBeforeNextFrame)
@@ -58,6 +60,11 @@ function LuaExportBeforeNextFrame()
isPressed = false
currCommandIndex = currCommandIndex + 1
end
+ elseif moreWait then
+ local currTime = socket.gettime()
+ if currTime >= waitTime then
+ moreWait = false
+ end
else
-- Prepare for new button push
local keys = JSON:decode(data)
@@ -66,9 +73,19 @@ function LuaExportBeforeNextFrame()
lastDevice = keys[currCommandIndex]["device"]
lastCode = keys[currCommandIndex]["code"]
local stringtoboolean = { ["true"] = true,["false"] = false }
- lastNeedDepress = stringtoboolean[keys[currCommandIndex]["addDepress"]]
+ local addDepress_str = keys[currCommandIndex]["addDepress"]
+ --lastNeedDepress = stringtoboolean[keys[currCommandIndex]["addDepress"]]
local delay = tonumber(keys[currCommandIndex]["delay"])
local activate = tonumber(keys[currCommandIndex]["activate"])
+
+ if addDepress_str == "fa18wait" then
+ moreWait = true
+ waitTime = socket.gettime() + (delay / 1000) + 0.05
+ lastNeedDepress = true
+ else
+ lastNeedDepress = stringtoboolean[addDepress_str]
+ end
+
-- Push the button
GetDevice(lastDevice):performClickableAction(lastCode, activate)
--Store the time when we will need to depress
diff --git a/src/components/FourOptionsDialog.js b/src/components/FourOptionsDialog.js
new file mode 100644
index 0000000..beaacec
--- /dev/null
+++ b/src/components/FourOptionsDialog.js
@@ -0,0 +1,28 @@
+import {
+ Button,
+ Dialog,
+ DialogTitle,
+ Stack,
+ } from "@mui/material";
+ import { createModal } from "react-modal-promise";
+
+ const FourSimpleDialog = ({ isOpen, onResolve, onReject, title, op1, op2, op3, op4 }) => {
+ const handleOptionSelected = (option) => {
+ onResolve(option);
+ };
+
+ return (
+
+ );
+ };
+
+ export const FourOptionsSimpleDialog = createModal(FourSimpleDialog);
+
\ No newline at end of file
diff --git a/src/components/TwoOptionsDialog.js b/src/components/TwoOptionsDialog.js
index d9934e3..2b15200 100644
--- a/src/components/TwoOptionsDialog.js
+++ b/src/components/TwoOptionsDialog.js
@@ -55,4 +55,21 @@ const MuiDialog = ({ isOpen, onResolve, onReject, title, op1, op2 }) => {
);
};
+const SimpleDialog = ({ isOpen, onResolve, onReject, title, op1, op2 }) => {
+ const handleOptionSelected = (option) => {
+ onResolve(option);
+ };
+
+ return (
+
+ );
+};
+
export const TwoOptionsDialog = createModal(MuiDialog);
+export const TwoOptionsSimpleDialog = createModal(SimpleDialog);
diff --git a/src/moduleCommands/GetModuleCommands.js b/src/moduleCommands/GetModuleCommands.js
index 63db44d..1c7ea13 100644
--- a/src/moduleCommands/GetModuleCommands.js
+++ b/src/moduleCommands/GetModuleCommands.js
@@ -11,10 +11,14 @@ import uh60l from "./uh60l";
export default function getModuleCommands(module, waypoints, buttonExtraDelay) {
switch (module) {
- case "F-15ESE_pilotA":
- case "F-15ESE_wsoA":
- case "F-15ESE_pilotB":
- case "F-15ESE_wsoB":
+ case "F-15ESE_pilotAJDAM":
+ case "F-15ESE_wsoAJDAM":
+ case "F-15ESE_pilotBJDAM":
+ case "F-15ESE_wsoBJDAM":
+ case "F-15ESE_pilotANOJDAM":
+ case "F-15ESE_wsoANOJDAM":
+ case "F-15ESE_pilotBNOJDAM":
+ case "F-15ESE_wsoBNOJDAM":
f15e.slotVariant = module;
f15e.extraDelay = buttonExtraDelay;
return f15e.createButtonCommands(waypoints);
@@ -30,9 +34,14 @@ export default function getModuleCommands(module, waypoints, buttonExtraDelay) {
return f16.createButtonCommands(waypoints);
}
case "FA-18C_hornet":
+ case "FA-18C_hornetPP1":
+ case "FA-18C_hornetPP2":
+ case "FA-18C_hornetPP3":
+ case "FA-18C_hornetPP4":
case "FA-18E":
case "FA-18F":
case "EA-18G": {
+ fa18.slotVariant = module;
fa18.extraDelay = buttonExtraDelay;
return fa18.createButtonCommands(waypoints);
}
diff --git a/src/moduleCommands/askUserAboutSeat.js b/src/moduleCommands/askUserAboutSeat.js
index 9aaff2a..886d0da 100644
--- a/src/moduleCommands/askUserAboutSeat.js
+++ b/src/moduleCommands/askUserAboutSeat.js
@@ -1,4 +1,8 @@
-import { TwoOptionsDialog } from "../components/TwoOptionsDialog";
+import {
+ TwoOptionsDialog,
+ TwoOptionsSimpleDialog,
+} from "../components/TwoOptionsDialog";
+import { FourOptionsSimpleDialog } from "../components/FourOptionsDialog";
import { AlertDialog } from "../components/AlertDialog";
const askUserAboutSeat = async (module, userPreferences) => {
@@ -24,16 +28,45 @@ const askUserAboutSeat = async (module, userPreferences) => {
module === "FA-18F" ||
module === "EA-18G"
) {
- if (moduleSpecificPreferences?.includes("Hide")) return "FA-18C_hornet";
- else {
- return AlertDialog({
- title: "Please make sure that",
- content:
- "1. PRECISE option is boxed in HSI > DATA\n" +
- "2. You are not in the TAC menu\n" +
- "3. You are in the 00°00.0000' coordinate format",
- }).then(() => "FA-18C_hornet");
+ let PPinput;
+ await TwoOptionsSimpleDialog({
+ title: "Input as PP MSN?",
+ op1: "YES",
+ op2: "NO",
+ }).then((pp) => (PPinput = pp));
+
+ let stations = "";
+ if (PPinput === "YES") {
+ await FourOptionsSimpleDialog({
+ title: "How many STATIONs carry this weapon?",
+ op1: "1",
+ op2: "2",
+ op3: "3",
+ op4: "4",
+ }).then((sta) => (stations = sta));
+ }
+
+ let hide = false;
+ if (moduleSpecificPreferences?.includes("Hide")) {
+ hide = true;
}
+ if (hide === false) {
+ if (PPinput === "YES") {
+ await AlertDialog({
+ title: "Please make sure that",
+ content: "Your LEFT MDI is on PP MSN Page!\n",
+ });
+ } else {
+ await AlertDialog({
+ title: "Please make sure that",
+ content:
+ "1. PRECISE option is boxed in HSI > DATA\n" +
+ "2. You are not in the TAC menu\n" +
+ "3. You are in the 00°00.0000' coordinate format",
+ });
+ }
+ }
+ return `FA-18C_hornet${PPinput === "YES" ? "PP" : ""}${stations}`;
} else if (module === "F-15ESE") {
let seat;
if (moduleSpecificPreferences?.includes("Pilot")) seat = "Pilot";
@@ -56,7 +89,42 @@ const askUserAboutSeat = async (module, userPreferences) => {
op2: "B{1/B}", // op2: "B" // removed because its a nice touch to keep the explicitness of this here, instead of making it more inline.
}).then((chosenRoute) => (route = chosenRoute));
}
- return `F-15ESE_${seat.toLowerCase()}${route === "A{1/A}" ? "A" : "B"}`;
+
+ let jdam;
+ await TwoOptionsSimpleDialog({
+ title: "Input for JDAMs?",
+ op1: "YES",
+ op2: "NO",
+ }).then((forJDAM) => (jdam = forJDAM));
+
+ let hide = false;
+ if (moduleSpecificPreferences?.includes("Hide")) {
+ hide = true;
+ }
+ if (hide === false) {
+ if (seat === "Pilot" && jdam === "YES") {
+ await AlertDialog({
+ title: "Make sure:",
+ content:
+ "1. Your RIGHT MPD is on Smart Weapons page.\n" +
+ "2. Used 'NXT STA' to select the bomb you want to start with.\n" +
+ "3. Do not program the JDAMs in PACS.(Recommend)",
+ });
+ } else if (seat === "WSO" && jdam === "YES") {
+ await AlertDialog({
+ title: "Make sure:",
+ content:
+ "1. The airplane's master mode is A/G\n" +
+ "2. Your RIGHT MPD(Green display) is on Smart Weapons page.\n" +
+ "3. Used 'NXT STA' to select the bomb you want to start with.\n" +
+ "4. Do not program the JDAMs in PACS.(Recommend)",
+ });
+ }
+ }
+
+ return `F-15ESE_${seat.toLowerCase()}${route === "A{1/A}" ? "A" : "B"}${
+ jdam === "YES" ? "JDAM" : "NOJDAM"
+ }`;
} else if (module === "UH-60L") {
if (moduleSpecificPreferences?.includes("Hide")) return "UH-60L";
else {
diff --git a/src/moduleCommands/f15e.js b/src/moduleCommands/f15e.js
index e3df0cb..000e4d6 100644
--- a/src/moduleCommands/f15e.js
+++ b/src/moduleCommands/f15e.js
@@ -1,7 +1,6 @@
class f15e {
static slotVariant = "";
- static extraDelay = 0;
- static delay = 100 + this.extraDelay;
+ static delay = 100;
static #f15eNumberCodes = {
0: 3036,
1: 3020,
@@ -18,110 +17,197 @@ class f15e {
shift: 3033,
A: 3020,
B: 3022,
+ dot: 3029,
+ PB1: 3061,
+ PB2: 3062,
+ AG: 3127,
};
+ static pushJDAMOps(payload, MPDcode) {
+ payload.push({
+ device: MPDcode,
+ code: this.#f15eNumberCodes["PB1"],
+ delay: 2000,
+ activate: 1,
+ addDepress: "true",
+ });
+ payload.push({
+ device: MPDcode,
+ code: this.#f15eNumberCodes["PB2"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
+
static createButtonCommands(waypoints) {
let f15eUFCDevice;
- if (["F-15ESE_pilotA", "F-15ESE_pilotB"].includes(this.slotVariant)) {
+ let f15eACC = 32;
+ let f15eMPDRight;
+ let frontSeat = false;
+ if (
+ [
+ "F-15ESE_pilotAJDAM",
+ "F-15ESE_pilotBJDAM",
+ "F-15ESE_pilotANOJDAM",
+ "F-15ESE_pilotBNOJDAM",
+ ].includes(this.slotVariant)
+ ) {
f15eUFCDevice = 56;
+ f15eMPDRight = 36;
+ frontSeat = true;
} else {
f15eUFCDevice = 57;
+ f15eMPDRight = 39;
}
let route; // This should reduce length of code by a lot, and make it more readable.
if (
- this.slotVariant === "F-15ESE_pilotA" ||
- this.slotVariant === "F-15ESE_wsoA"
+ this.slotVariant === "F-15ESE_pilotAJDAM" ||
+ this.slotVariant === "F-15ESE_wsoAJDAM" ||
+ this.slotVariant === "F-15ESE_pilotANOJDAM" ||
+ this.slotVariant === "F-15ESE_wsoANOJDAM"
) {
route = this.#f15eNumberCodes["A"];
} else {
route = this.#f15eNumberCodes["B"];
}
+ let jdam;
+ if (
+ this.slotVariant === "F-15ESE_pilotAJDAM" ||
+ this.slotVariant === "F-15ESE_wsoAJDAM" ||
+ this.slotVariant === "F-15ESE_pilotBJDAM" ||
+ this.slotVariant === "F-15ESE_wsoBJDAM"
+ ) {
+ jdam = true;
+ } else {
+ jdam = false;
+ }
- {
- // Doesnt need to be Splice-Cleared because payload is created *each time* the function is called, and isnt static.
- let payload = [
- {
- // Clear UFC button
- device: f15eUFCDevice,
- code: 3035,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Clear UFC button
- device: f15eUFCDevice,
- code: 3035,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Clear UFC button
- device: f15eUFCDevice,
- code: 3035,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Menu UFC button
- device: f15eUFCDevice,
- code: 3038,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Press Shift
- device: f15eUFCDevice,
- code: 3033,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Press B / 3 (This switches to the universal Base point / INS Align point)
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes["B"],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Enter B into UFC button 10
- device: f15eUFCDevice,
- code: 3010,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
- {
- // Press UFC button 10
+ // Doesnt need to be Splice-Cleared because payload is created *each time* the function is called, and isnt static.
+ let payload = [
+ {
+ // Clear UFC button
+ device: f15eUFCDevice,
+ code: 3035,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Clear UFC button
+ device: f15eUFCDevice,
+ code: 3035,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Clear UFC button
+ device: f15eUFCDevice,
+ code: 3035,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Menu UFC button
+ device: f15eUFCDevice,
+ code: 3038,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Press Shift
+ device: f15eUFCDevice,
+ code: 3033,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Press B / 3 (This switches to the universal Base point / INS Align point)
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes["B"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Enter B into UFC button 10
+ device: f15eUFCDevice,
+ code: 3010,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Press UFC button 10
+ device: f15eUFCDevice,
+ code: 3010,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ ];
+ // =================== end of setup ===================
+
+ // =================== Set Master Mode ===================
+ if (jdam === true && frontSeat === true) {
+ payload.push({
+ // AG Switch
+ device: f15eACC,
+ code: this.#f15eNumberCodes["AG"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
+ // =================== end of master mode setup ===================
+
+ // =================== Enter Waypoint numbers ===================
+ for (const waypoint of waypoints) {
+ let waypointNumber = waypoints.indexOf(waypoint) + 1;
+ for (let i = 0; i < (waypointNumber + "").length; i++) {
+ // eslint-disable-next-line default-case
+ let digit = (waypointNumber + "").charAt(i);
+ payload.push({
+ // Waypoint Digit
device: f15eUFCDevice,
- code: 3010,
+ code: this.#f15eNumberCodes[digit],
delay: this.delay,
activate: 1,
addDepress: "true",
- },
- ];
- // =================== end of setup ===================
-
- // =================== Enter Waypoint numbers ===================
- for (const waypoint of waypoints) {
- let waypointNumber = waypoints.indexOf(waypoint) + 1;
- for (let i = 0; i < (waypointNumber + "").length; i++) {
- // eslint-disable-next-line default-case
- let digit = (waypointNumber + "").charAt(i);
- payload.push({
- // Waypoint Digit
+ });
+ }
+ if (jdam === true) {
+ payload.push(
+ {
+ // press .
device: f15eUFCDevice,
- code: this.#f15eNumberCodes[digit],
+ code: this.#f15eNumberCodes["dot"],
delay: this.delay,
activate: 1,
addDepress: "true",
- });
- }
+ },
+ {
+ // press shift
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes["shift"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // route letter
+ device: f15eUFCDevice,
+ code: route,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ );
+ } else {
payload.push(
{
// press shift
@@ -140,158 +226,213 @@ class f15e {
addDepress: "true",
},
);
+ }
+
+ // ============================================================
+
+ payload.push({
+ // Press PB 1
+ device: f15eUFCDevice,
+ code: 3001,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
- // ============================================================
+ payload.push({
+ // Press Shift
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes["shift"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ if (waypoint.latHem === "N") {
+ // North
payload.push({
- // Press PB 1
device: f15eUFCDevice,
- code: 3001,
+ code: this.#f15eNumberCodes[2],
delay: this.delay,
activate: 1,
addDepress: "true",
});
-
+ } else {
payload.push({
- // Press Shift
+ // South
device: f15eUFCDevice,
- code: this.#f15eNumberCodes["shift"],
+ code: this.#f15eNumberCodes[8],
delay: this.delay,
activate: 1,
addDepress: "true",
});
+ }
- if (waypoint.latHem === "N") {
- // North
- payload.push({
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes[2],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
- } else {
- payload.push({
- // South
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes[8],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
- }
-
- //Type lat
- for (let i = 0; i < waypoint.lat.length; i++) {
- // enter each digit of lat into scratchpad
- // eslint-disable-next-line default-case
- for (const char of waypoint.lat.charAt(i)) {
- if (char !== ".") {
- payload.push({
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes[char],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
- }
+ //Type lat
+ for (let i = 0; i < waypoint.lat.length; i++) {
+ // enter each digit of lat into scratchpad
+ // eslint-disable-next-line default-case
+ for (const char of waypoint.lat.charAt(i)) {
+ if (char !== ".") {
+ payload.push({
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes[char],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
}
}
+ }
+
+ payload.push({
+ // enter latitutde into UFC
+ device: f15eUFCDevice,
+ code: 3002,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+
+ payload.push({
+ // Press Shift
+ device: f15eUFCDevice,
+ code: 3033,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ if (waypoint.longHem === "E") {
+ // Type hemisphere into scratchpad
payload.push({
- // enter latitutde into UFC
device: f15eUFCDevice,
- code: 3002,
+ code: this.#f15eNumberCodes[6],
delay: this.delay,
activate: 1,
addDepress: "true",
});
-
+ } else {
payload.push({
- // Press Shift
device: f15eUFCDevice,
- code: 3033,
+ code: this.#f15eNumberCodes[4],
delay: this.delay,
activate: 1,
addDepress: "true",
});
+ }
- if (waypoint.longHem === "E") {
- // Type hemisphere into scratchpad
- payload.push({
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes[6],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
- } else {
+ for (let i = 0; i < waypoint.long.length; i++) {
+ // enter each digit of longtitude into scratchpad
+ // eslint-disable-next-line default-case
+ for (const char of waypoint.long.charAt(i)) {
+ if (char !== ".") {
+ payload.push({
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes[char],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
+ }
+ }
+
+ payload.push({
+ // enter longtitude into UFC
+ device: f15eUFCDevice,
+ code: 3003,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+
+ for (let i = 0; i < waypoint.elev.length; i++) {
+ // enter each digit of elevation into scratchpad
+ // eslint-disable-next-line default-case
+ for (const char of waypoint.elev.charAt(i)) {
payload.push({
device: f15eUFCDevice,
- code: this.#f15eNumberCodes[4],
+ code: this.#f15eNumberCodes[char],
delay: this.delay,
activate: 1,
addDepress: "true",
});
}
+ }
- for (let i = 0; i < waypoint.long.length; i++) {
- // enter each digit of longtitude into scratchpad
- // eslint-disable-next-line default-case
- for (const char of waypoint.long.charAt(i)) {
- if (char !== ".") {
- payload.push({
- device: f15eUFCDevice,
- code: this.#f15eNumberCodes[char],
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
- }
- }
- }
+ payload.push({
+ // enter elevation into UFC
+ device: f15eUFCDevice,
+ code: 3007,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
- payload.push({
- // enter longtitude into UFC
- device: f15eUFCDevice,
- code: 3003,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
+ payload.push({
+ // Menu UFC button
+ device: f15eUFCDevice,
+ code: 3038,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ });
- for (let i = 0; i < waypoint.elev.length; i++) {
- // enter each digit of elevation into scratchpad
+ if (jdam === true) {
+ for (const waypoint of waypoints) {
+ let waypointNumber = waypoints.indexOf(waypoint) + 1;
+ for (let i = 0; i < (waypointNumber + "").length; i++) {
// eslint-disable-next-line default-case
- for (const char of waypoint.elev.charAt(i)) {
- payload.push({
+ let digit = (waypointNumber + "").charAt(i);
+ payload.push(
+ {
+ // Waypoint Digit
device: f15eUFCDevice,
- code: this.#f15eNumberCodes[char],
+ code: this.#f15eNumberCodes[digit],
delay: this.delay,
activate: 1,
addDepress: "true",
- });
- }
+ },
+ {
+ // press .
+ device: f15eUFCDevice,
+ code: this.#f15eNumberCodes["dot"],
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // press shift
+ device: f15eUFCDevice,
+ code: 3033,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // enter route letter
+ device: f15eUFCDevice,
+ code: route,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ {
+ // Waypoint UFC button
+ device: f15eUFCDevice,
+ code: 3010,
+ delay: this.delay,
+ activate: 1,
+ addDepress: "true",
+ },
+ );
+ this.pushJDAMOps(payload, f15eMPDRight);
}
-
- payload.push({
- // enter elevation into UFC
- device: f15eUFCDevice,
- code: 3007,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- });
}
+ } else {
payload.push(
- {
- // Menu UFC button
- device: f15eUFCDevice,
- code: 3038,
- delay: this.delay,
- activate: 1,
- addDepress: "true",
- },
{
// Enter 1 button (This re-selects the first waypoint)
device: f15eUFCDevice,
@@ -325,9 +466,8 @@ class f15e {
addDepress: "true",
},
);
-
- return payload;
}
+ return payload;
}
}
diff --git a/src/moduleCommands/fa18.js b/src/moduleCommands/fa18.js
index f24c09b..66547d4 100644
--- a/src/moduleCommands/fa18.js
+++ b/src/moduleCommands/fa18.js
@@ -1,10 +1,16 @@
+import { AlertDialog } from "../components/AlertDialog";
class fa18 {
+ static slotVariant = "";
+ static stations = 4;
static extraDelay = 0;
static #delay100 = this.extraDelay + 100;
static #delay200 = this.extraDelay + 200;
static #delay500 = this.extraDelay + 500;
static #delay800 = this.extraDelay + 800;
static #delay1000 = this.extraDelay + 1000;
+ static device_UFC = 25;
+ static device_AMPCD = 37;
+ static device_MDILeft = 35;
static #kuKeycodes = {
1: 3019,
2: 3020,
@@ -16,201 +22,556 @@ class fa18 {
8: 3026,
9: 3027,
0: 3018,
+ PB1: 3011,
+ PB2: 3012,
+ PB3: 3013,
+ PB4: 3014,
+ PB5: 3015,
+ PB6: 3016,
+ PB7: 3017,
+ PB8: 3018,
+ PB9: 3019,
+ PB10: 3020,
+ PB11: 3021,
+ PB12: 3022,
+ PB13: 3023,
+ PB14: 3024,
+ PB15: 3025,
+ PB16: 3026,
+ PB17: 3027,
+ PB18: 3028,
+ PB19: 3029,
+ PB20: 3030,
+ UFCOpt1: 3010,
+ UFCOpt2: 3011,
+ UFCOpt3: 3012,
+ UFCOpt4: 3013,
+ UFCOpt5: 3014,
+ UFCEnter: 3029,
+ UFCNorth: 3020,
+ UFCSouth: 3026,
+ UFCEast: 3024,
+ UFCWest: 3022,
};
static #codesPayload = [];
- static #addKeyboardCode(character) {
+ static #addKeyboardCode(character, wait) {
const characterCode = this.#kuKeycodes[character.toLowerCase()];
if (characterCode !== undefined)
- this.#codesPayload.push({
- device: 25,
- code: characterCode,
- delay: this.#delay100,
- activate: 1,
- addDepress: "true",
- });
+ if (wait === true) {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: characterCode,
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ } else {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: characterCode,
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
}
- static createButtonCommands(waypoints) {
- this.#codesPayload = [];
- //enter the SUPT menu
+ static generatePPMSNCommands(wpt) {
+ //select STEP
this.#codesPayload.push({
- device: 37,
- code: 3028,
- delay: this.#delay100,
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB13"],
+ delay: this.#delay500,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
+
+ //select TGT UFC
this.#codesPayload.push({
- device: 37,
- code: 3028,
- delay: this.#delay100,
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB14"],
+ delay: this.#delay800,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //select HSD
+
+ //select UFC POSN
this.#codesPayload.push({
- device: 37,
- code: 3012,
- delay: this.#delay100,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt3"],
+ delay: this.#delay200,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //select DATA
+
+ //=============== Input Latitude ===============
+ //select UFC LAT
this.#codesPayload.push({
- device: 37,
- code: 3020,
- delay: this.#delay100,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt1"],
+ delay: this.#delay200,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- for (const waypoint of waypoints) {
- //increment waypoint
+ //Type hem
+ if (wpt.latHem === "N") {
this.#codesPayload.push({
- device: 37,
- code: 3022,
- delay: this.#delay500,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCNorth"],
+ delay: this.#delay100,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //press UFC
+ } else {
this.#codesPayload.push({
- device: 37,
- code: 3015,
- delay: this.#delay800,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCSouth"],
+ delay: this.#delay100,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //press position 1
+ }
+ //enter first lat digits
+ const firstLat = wpt.lat.substring(0, wpt.lat.length - 5);
+ const format_last4lat = (
+ (Number(wpt.lat.substring(wpt.lat.length - 4)) * 60) /
+ 10000.0
+ )
+ .toFixed(2)
+ .toString();
+
+ let add_to_firstLat = format_last4lat.substring(
+ 0,
+ format_last4lat.length - 3,
+ );
+
+ // only one number left, add a '0' before it
+ if (add_to_firstLat.length < 2) {
+ add_to_firstLat = "0" + add_to_firstLat;
+ }
+
+ const first_lat_str = firstLat + add_to_firstLat;
+ const second_lat_str = format_last4lat.substring(
+ format_last4lat.length - 2,
+ );
+ //Type lat
+ for (let i = 0; i < first_lat_str.length; i++) {
+ this.#addKeyboardCode(first_lat_str.charAt(i), true);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //enter last 2 digits
+ for (let i = 0; i < second_lat_str.length; i++) {
+ this.#addKeyboardCode(second_lat_str.charAt(i), true);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //=============== end of Input Latitude ===============
+
+ //=============== Input Longitude ===============
+ //select UFC LON
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt3"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+
+ //Type hem
+ if (wpt.longHem === "E") {
this.#codesPayload.push({
- device: 25,
- code: 3010,
- delay: this.#delay200,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEast"],
+ delay: this.#delay100,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //Type hem
- if (waypoint.latHem === "N") {
- this.#codesPayload.push({
- device: 25,
- code: 3020,
- delay: this.#delay100,
- activate: 1,
- addDepress: "true",
- });
- } else {
- this.#codesPayload.push({
- device: 25,
- code: 3026,
- delay: this.#delay100,
- activate: 1,
- addDepress: "true",
- });
- }
- //enter first lat digits
- const firstLat = waypoint.lat.substring(0, waypoint.lat.length - 5);
- const last4Lat = waypoint.lat.substring(waypoint.lat.length - 5);
- //Type lat
- for (let i = 0; i < firstLat.length; i++) {
- this.#addKeyboardCode(firstLat.charAt(i));
- }
- //press enter
+ } else {
this.#codesPayload.push({
- device: 25,
- code: 3029,
- delay: this.#delay1000,
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCWest"],
+ delay: this.#delay100,
activate: 1,
- addDepress: "true",
+ addDepress: "fa18wait",
});
- //enter last 4 digits
- for (let i = 0; i < last4Lat.length; i++) {
- this.#addKeyboardCode(last4Lat.charAt(i));
+ }
+ //enter first long digits
+
+ const firstLong = wpt.long.substring(0, wpt.long.length - 4);
+ const format_last4long = (
+ (Number(wpt.long.substring(wpt.long.length - 4)) * 60) /
+ 10000.0
+ )
+ .toFixed(2)
+ .toString();
+
+ let add_to_firstLong = format_last4long.substring(
+ 0,
+ format_last4long.length - 3,
+ );
+
+ // only one number left, add a '0' before it
+ if (add_to_firstLong.length < 2) {
+ add_to_firstLong = "0" + add_to_firstLong;
+ }
+
+ let first_long_str = firstLong + add_to_firstLong;
+ const second_long_str = format_last4long.substring(
+ format_last4long.length - 2,
+ );
+
+ // remove starting '0' in longitude, if it is 1xx°, then everything's fine
+ if (first_long_str.charAt(0) === "0") {
+ first_long_str = first_long_str.substring(1);
+ }
+
+ //Type long
+ for (let i = 0; i < first_long_str.length; i++) {
+ this.#addKeyboardCode(first_long_str.charAt(i), true);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //enter last 4 digits
+ for (let i = 0; i < second_long_str.length; i++) {
+ this.#addKeyboardCode(second_long_str.charAt(i), true);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //=============== end of Input Longitude ===============
+
+ //select TGT UFC
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB14"],
+ delay: this.#delay800,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //select TGT UFC
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB14"],
+ delay: this.#delay800,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+
+ //=============== Input Elevation ===============
+ //select UFC ELEV
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt4"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+
+ //press position 3 to select feet
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt3"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //Type elev
+ for (let i = 0; i < wpt.elev.length; i++) {
+ this.#addKeyboardCode(wpt.elev.charAt(i), true);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ //=============== end of Input Elevation ===============
+
+ //select TGT UFC
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB14"],
+ delay: this.#delay800,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ }
+
+ static createPPInputCommands(waypoints) {
+ let inputNum = this.stations * 5;
+
+ let ppmsn = 0;
+ let sta = 0;
+ let count = 0;
+ for (const wpt of waypoints) {
+ if (sta === this.stations) {
+ ppmsn += 1;
+ sta = 0;
+ //select next PP MSN
+ if (ppmsn < 5) {
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB6"] + ppmsn,
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+
+ for (let i = 0; i < this.stations - 1; i++) {
+ //select STEP
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB13"],
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+
+ //select next PP MSN
+ this.#codesPayload.push({
+ device: this.device_MDILeft,
+ code: this.#kuKeycodes["PB6"] + ppmsn,
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "fa18wait",
+ });
+ }
+ }
}
- //press enter
- this.#codesPayload.push({
- device: 25,
- code: 3029,
- delay: this.#delay1000,
- activate: 1,
- addDepress: "true",
- });
- //Type hem
- if (waypoint.longHem === "E") {
- this.#codesPayload.push({
- device: 25,
- code: 3024,
- delay: this.#delay100,
- activate: 1,
- addDepress: "true",
- });
- } else {
- this.#codesPayload.push({
- device: 25,
- code: 3022,
- delay: this.#delay100,
- activate: 1,
- addDepress: "true",
- });
+ this.generatePPMSNCommands(wpt);
+ count++;
+ sta += 1;
+ if (count === inputNum) {
+ break;
}
- //enter first long digits
+ }
+ }
- const firstLong = waypoint.long.substring(0, waypoint.long.length - 4);
- const last4Long = waypoint.long.substring(waypoint.long.length - 4);
- //Type long
- for (let i = 0; i < firstLong.length; i++) {
- this.#addKeyboardCode(firstLong.charAt(i));
+ static createButtonCommands(waypoints) {
+ this.#codesPayload = [];
+ if (
+ this.slotVariant === "FA-18C_hornetPP1" ||
+ this.slotVariant === "FA-18C_hornetPP2" ||
+ this.slotVariant === "FA-18C_hornetPP3" ||
+ this.slotVariant === "FA-18C_hornetPP4"
+ ) {
+ if (this.slotVariant === "FA-18C_hornetPP1") {
+ this.stations = 1;
+ } else if (this.slotVariant === "FA-18C_hornetPP2") {
+ this.stations = 2;
+ } else if (this.slotVariant === "FA-18C_hornetPP3") {
+ this.stations = 3;
+ } else {
+ this.stations = 4;
}
- //press enter
+ this.createPPInputCommands(waypoints);
+ } else {
+ //enter the SUPT menu
this.#codesPayload.push({
- device: 25,
- code: 3029,
- delay: this.#delay1000,
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB18"],
+ delay: this.#delay100,
activate: 1,
addDepress: "true",
});
- //enter last 4 digits
- for (let i = 0; i < last4Long.length; i++) {
- this.#addKeyboardCode(last4Long.charAt(i));
- }
- //press enter
this.#codesPayload.push({
- device: 25,
- code: 3029,
- delay: this.#delay1000,
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB18"],
+ delay: this.#delay100,
activate: 1,
addDepress: "true",
});
- //press position 3 to select elevation
+ //select HSD
this.#codesPayload.push({
- device: 25,
- code: 3012,
- delay: this.#delay200,
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB2"],
+ delay: this.#delay100,
activate: 1,
addDepress: "true",
});
- //press position 1 to select feet
+ //select DATA
this.#codesPayload.push({
- device: 25,
- code: 3010,
- delay: this.#delay200,
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB10"],
+ delay: this.#delay100,
activate: 1,
addDepress: "true",
});
- //Type elev
- for (let i = 0; i < waypoint.elev.length; i++) {
- this.#addKeyboardCode(waypoint.elev.charAt(i));
+
+ for (const waypoint of waypoints) {
+ //increment waypoint
+ this.#codesPayload.push({
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB12"],
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "true",
+ });
+ //press UFC
+ this.#codesPayload.push({
+ device: this.device_AMPCD,
+ code: this.#kuKeycodes["PB5"],
+ delay: this.#delay800,
+ activate: 1,
+ addDepress: "true",
+ });
+ //press position 1
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt1"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "true",
+ });
+ //Type hem
+ if (waypoint.latHem === "N") {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCNorth"],
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "true",
+ });
+ } else {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCSouth"],
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
+ //enter first lat digits
+ const firstLat = waypoint.lat.substring(0, waypoint.lat.length - 5);
+ const last4Lat = waypoint.lat.substring(waypoint.lat.length - 5);
+ //Type lat
+ for (let i = 0; i < firstLat.length; i++) {
+ this.#addKeyboardCode(firstLat.charAt(i), false);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "true",
+ });
+ //enter last 4 digits
+ for (let i = 0; i < last4Lat.length; i++) {
+ this.#addKeyboardCode(last4Lat.charAt(i), false);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "true",
+ });
+ //Type hem
+ if (waypoint.longHem === "E") {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEast"],
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "true",
+ });
+ } else {
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCWest"],
+ delay: this.#delay100,
+ activate: 1,
+ addDepress: "true",
+ });
+ }
+ //enter first long digits
+
+ const firstLong = waypoint.long.substring(0, waypoint.long.length - 4);
+ const last4Long = waypoint.long.substring(waypoint.long.length - 4);
+ //Type long
+ for (let i = 0; i < firstLong.length; i++) {
+ this.#addKeyboardCode(firstLong.charAt(i), false);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "true",
+ });
+ //enter last 4 digits
+ for (let i = 0; i < last4Long.length; i++) {
+ this.#addKeyboardCode(last4Long.charAt(i), false);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay1000,
+ activate: 1,
+ addDepress: "true",
+ });
+ //press position 3 to select elevation
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt3"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "true",
+ });
+ //press position 1 to select feet
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCOpt1"],
+ delay: this.#delay200,
+ activate: 1,
+ addDepress: "true",
+ });
+ //Type elev
+ for (let i = 0; i < waypoint.elev.length; i++) {
+ this.#addKeyboardCode(waypoint.elev.charAt(i), false);
+ }
+ //press enter
+ this.#codesPayload.push({
+ device: this.device_UFC,
+ code: this.#kuKeycodes["UFCEnter"],
+ delay: this.#delay500,
+ activate: 1,
+ addDepress: "true",
+ });
}
- //press enter
- this.#codesPayload.push({
- device: 25,
- code: 3029,
- delay: this.#delay500,
- activate: 1,
- addDepress: "true",
- });
}
-
return this.#codesPayload;
}
}