Skip to content

Commit

Permalink
Merge pull request #3 from BitsAndDroids/dev
Browse files Browse the repository at this point in the history
moved wasm registration to the frontend
  • Loading branch information
BitsAndDroids authored Apr 28, 2024
2 parents d3ffc1a + f8d35d8 commit b7dac50
Show file tree
Hide file tree
Showing 22 changed files with 793 additions and 657 deletions.
Binary file modified MSFS/Release/WASM_Module_BitsAndDroids.wasm
Binary file not shown.
273 changes: 273 additions & 0 deletions UpgradeLog3.htm

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\WASM_Module_BitsAndDroids\WASM_Module_BitsAndDroids.cpp;E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\WASM_Module_BitsAndDroids\MSFS\Debug\WASM_Module_BitsAndDroids.obj
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PlatformToolSet=MSFS:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Debug|MSFS|C:\Users\Dave Riedel\source\repos\WASM_Module_BitsAndDroids\|
PlatformToolSet=MSFS:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
Debug|MSFS|E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
542 changes: 205 additions & 337 deletions WASM_Module_BitsAndDroids/MSFS/Debug/WASM_Module_BitsAndDroids.log

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Dave Riedel\source\repos\WASM_Module_BitsAndDroids\MSFS\Debug\WASM_Module_BitsAndDroids.wasm</FullPath>
<FullPath>E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\MSFS\Debug\WASM_Module_BitsAndDroids.wasm</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\WASM_Module_BitsAndDroids\WASM_Module_BitsAndDroids.cpp;E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\WASM_Module_BitsAndDroids\MSFS\Release\WASM_Module_BitsAndDroids.obj
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PlatformToolSet=MSFS:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionATL=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:VCServicingVersionCompilers=14.29.30136:TargetPlatformVersion=10.0.19041.0:
Release|MSFS|C:\Users\Dave Riedel\source\repos\WASM_Module_BitsAndDroids\|
PlatformToolSet=MSFS:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
Release|MSFS|E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
574 changes: 307 additions & 267 deletions WASM_Module_BitsAndDroids/MSFS/Release/WASM_Module_BitsAndDroids.log

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Dave Riedel\source\repos\WASM_Module_BitsAndDroids\MSFS\Release\WASM_Module_BitsAndDroids.wasm</FullPath>
<FullPath>E:\BitsAndDroids\WASM\Bits-and-Droids-WASM-module\MSFS\Release\WASM_Module_BitsAndDroids.wasm</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
Expand Down
47 changes: 0 additions & 47 deletions WASM_Module_BitsAndDroids/WASM_Module_BitsAndDroids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,52 +115,8 @@ void register_event(std::string event_message)
std::cout << "Adding event to inputs " << event.id << " " << event.action.c_str() << std::endl;
wasmEvents.insert({ event.id, event });
}


}
void readEventFile()
{
std::cout << "reading event file" << std::endl;
FILE* fp = fopen(relativeJSONEventFilePath, "rb");
char readBuffer[65536];
FileReadStream is(fp, readBuffer, sizeof(readBuffer));

Document d;
if (d.ParseStream(is).HasParseError())
{
fprintf(stderr, "Error parsing input event json");
}
fclose(fp);

const Value& event_array = d["events"];
if (!event_array.IsArray())
{
fprintf(stderr, "Invalid JSON format - 'events' is not an array");
}
int event_counter = 0;
for (const Value& event : event_array.GetArray())
{
WASMEvent event_found = {
event["id"].GetInt(),
event["action"].GetString(),
event["action_text"].GetString(),
event["action_type"].GetString(),
event["output_format"].GetString(),
event["update_every"].GetFloat(),
event["min"].GetFloat(),
event["max"].GetFloat(),
0.0,
sizeof(float) * event_counter
};
event_counter++;
if(event_found.action_type != "input")
{
return;
}
wasmEvents.insert({event_found.id, event_found});
std::cout << "Added event: " << event_found.id << " " << event_found.action << " as output" << std::endl;
}
}
void clear_sim_vars()
{
for (auto& event : registeredWASMEvents)
Expand Down Expand Up @@ -267,7 +223,6 @@ void CALLBACK myDispatchHandler(SIMCONNECT_RECV* pData, DWORD cbData,
if (event_found.id == 9999)
{
wasmEvents.clear();
readEventFile();
break;
}
if (prefix == 9998)
Expand Down Expand Up @@ -380,8 +335,6 @@ extern "C" MSFS_CALLBACK void module_init(void)
SIMCONNECT_CLIENTDATAOFFSET_AUTO, 256,
0);

readEventFile();

// COMMANDS
SimConnect_MapClientDataNameToID(hSimConnect, "command_client", commandCLientDataID);
SimConnect_CreateClientData(hSimConnect, commandCLientDataID, 4096, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT);
Expand Down

0 comments on commit b7dac50

Please sign in to comment.