Skip to content

Commit e460925

Browse files
committed
[WASimClient] Use local Key Event ID mapping lookup instead of remote query; Requires MSFS 2024 SDK installed; Clean up includes.
1 parent caad3aa commit e460925

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
indent_style=tab
44
indent_size = 2
55
insert_final_newline=true
6+
cpp_include_cleanup_excluded_files = MSFS_EventsEnum.h

src/WASimClient/WASimClient.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ prior written authorization from the authors.
2424

2525
#include <chrono>
2626
#include <condition_variable>
27-
#include <cstdio>
2827
#include <cstring>
29-
#include <ctime>
3028
#include <filesystem>
31-
#include <fstream>
32-
#include <future>
29+
#include <functional>
3330
#include <iomanip>
3431
#include <iostream>
3532
#include <list>
@@ -38,6 +35,7 @@ prior written authorization from the authors.
3835
#include <string>
3936
#include <sstream>
4037
#include <thread>
38+
#include <unordered_map>
4139

4240
#define WIN32_LEAN_AND_MEAN
4341
#include <Windows.h>
@@ -46,11 +44,13 @@ prior written authorization from the authors.
4644
#define LOGFAULT_THREAD_NAME WSMCMND_CLIENT_NAME
4745

4846
#include "client/WASimClient.h"
49-
//#include "private/wasimclient_p.h"
5047
#include "utilities.h"
5148
#include "SimConnectHelper.h"
5249
#include "inipp.h"
5350

51+
#include "MSFS_EventsEnum.h" // from MSFS2024_SDK, for key_events.h
52+
#include "key_events.h"
53+
5454
namespace WASimCommander::Client
5555
{
5656

@@ -2004,6 +2004,16 @@ HRESULT WASimClient::list(LookupItemType itemsType)
20042004

20052005
HRESULT WASimClient::lookup(LookupItemType itemType, const std::string &itemName, int32_t *piResult)
20062006
{
2007+
// Short-circuit Key Event ID lookups from local source
2008+
if (itemType == LookupItemType::KeyEventId) {
2009+
const int32_t keyId = Utilities::getKeyEventId(itemName);
2010+
if (keyId < 0)
2011+
LOG_DBG << "Key Event named " << quoted(itemName) << " was not found in local lookup table.";
2012+
else if (!!piResult)
2013+
*piResult = keyId;
2014+
return keyId < 0 ? E_FAIL : S_OK;
2015+
}
2016+
20072017
if (itemName.length() >= STRSZ_CMD) {
20082018
LOG_ERR << "Item name length " << itemName.length() << " is greater then maximum size of " << STRSZ_CMD-1 << " bytes.";
20092019
return E_INVALIDARG;

src/WASimClient/WASimClient.vcxproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,29 @@
7979
<PropertyGroup Label="UserMacros" />
8080
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8181
<LinkIncremental>true</LinkIncremental>
82-
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)\SimConnect SDK\include;$(IncludePath)</IncludePath>
82+
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)SimConnect SDK\include;$(MSFS2024_SDK)WASM\include\MSFS\Types;$(IncludePath)</IncludePath>
8383
<LibraryPath>$(MSFS_SDK)\SimConnect SDK\lib\static;$(LibraryPath)</LibraryPath>
8484
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
8585
<CopyLocalProjectReference>true</CopyLocalProjectReference>
8686
<TargetName>$(ProjectName)_d</TargetName>
8787
</PropertyGroup>
8888
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8989
<LinkIncremental>false</LinkIncremental>
90-
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)\SimConnect SDK\include;$(IncludePath)</IncludePath>
90+
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)SimConnect SDK\include;$(MSFS2024_SDK)WASM\include\MSFS\Types;$(IncludePath)</IncludePath>
9191
<LibraryPath>$(MSFS_SDK)\SimConnect SDK\lib\static;$(LibraryPath)</LibraryPath>
9292
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
9393
<CopyLocalProjectReference>true</CopyLocalProjectReference>
9494
</PropertyGroup>
9595
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">
9696
<LinkIncremental>false</LinkIncremental>
97-
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)\SimConnect SDK\include;$(IncludePath)</IncludePath>
97+
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)SimConnect SDK\include;$(MSFS2024_SDK)WASM\include\MSFS\Types;$(IncludePath)</IncludePath>
9898
<LibraryPath>$(MSFS_SDK)\SimConnect SDK\lib\static;$(LibraryPath)</LibraryPath>
9999
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
100100
<CopyLocalProjectReference>true</CopyLocalProjectReference>
101101
</PropertyGroup>
102102
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-DLL|x64'">
103103
<LinkIncremental>false</LinkIncremental>
104-
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)\SimConnect SDK\include;$(IncludePath)</IncludePath>
104+
<IncludePath>$(ProjectDir);$(SolutionDir)\shared;$(MSFS_SDK)SimConnect SDK\include;$(MSFS2024_SDK)WASM\include\MSFS\Types;$(IncludePath)</IncludePath>
105105
<LibraryPath>$(MSFS_SDK)\SimConnect SDK\lib\static;$(LibraryPath)</LibraryPath>
106106
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
107107
<CopyLocalProjectReference>true</CopyLocalProjectReference>
@@ -252,10 +252,10 @@
252252
</ItemGroup>
253253
<ItemGroup>
254254
<ClInclude Include="..\include\client\enums.h" />
255+
<ClInclude Include="..\include\client\enums_impl.h" />
255256
<ClInclude Include="..\include\client\exports.h" />
256257
<ClInclude Include="..\include\client\structs.h" />
257258
<ClInclude Include="..\include\client\WASimClient.h" />
258-
<ClInclude Include="..\include\enums.h" />
259259
<ClInclude Include="..\include\enums_impl.h" />
260260
<ClInclude Include="..\include\global.h" />
261261
<ClInclude Include="..\include\WASimCommander.h" />

0 commit comments

Comments
 (0)