diff options
| author | a1xd <[email protected]> | 2020-12-02 05:25:19 -0500 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-12-02 05:25:19 -0500 |
| commit | 7d14daf1d5fce4d09471a3abe2aca49cf7680816 (patch) | |
| tree | 43411443aadc79d36ad1da8063208cd51fdb15fe /converter | |
| parent | merge common-install with common (diff) | |
| download | rawaccel-7d14daf1d5fce4d09471a3abe2aca49cf7680816.tar.xz rawaccel-7d14daf1d5fce4d09471a3abe2aca49cf7680816.zip | |
embed version info into assemblies
check app versions against lib, lib against driver
add an 'about' dialog which displays version details, accessible from menu
refactor error handling + add check for negative offset
Diffstat (limited to 'converter')
| -rw-r--r-- | converter/AssemblyInfo.cpp | 12 | ||||
| -rw-r--r-- | converter/converter.cpp | 28 | ||||
| -rw-r--r-- | converter/converter.rc | 100 | ||||
| -rw-r--r-- | converter/converter.vcxproj | 13 | ||||
| -rw-r--r-- | converter/converter.vcxproj.filters | 13 | ||||
| -rw-r--r-- | converter/resource.h | 14 |
6 files changed, 173 insertions, 7 deletions
diff --git a/converter/AssemblyInfo.cpp b/converter/AssemblyInfo.cpp new file mode 100644 index 0000000..cbe3aec --- /dev/null +++ b/converter/AssemblyInfo.cpp @@ -0,0 +1,12 @@ +#include <rawaccel-version.h> + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +[assembly:AssemblyVersion(RA_VER_STRING)] + +[assembly:ComVisible(false)] ; +[assembly:CLSCompliantAttribute(true)] ; diff --git a/converter/converter.cpp b/converter/converter.cpp index af2699b..230e1be 100644 --- a/converter/converter.cpp +++ b/converter/converter.cpp @@ -192,7 +192,7 @@ bool try_convert(const ia_settings_t& ia_settings) { auto errors = DriverInterop::GetSettingsErrors(new_settings); if (!errors->Empty()) { - Console::WriteLine("Bad settings: " + errors->x->ToArray()[0]); + Console::WriteLine("Bad settings: {0}", errors); return false; } @@ -208,8 +208,26 @@ bool try_convert(const ia_settings_t& ia_settings) { return true; } +public ref struct ASSEMBLY { + static initonly Version^ VERSION = ASSEMBLY::typeid->Assembly->GetName()->Version; +}; + int main() { + auto close_prompt = [] { + std::cout << "Press any key to close this window . . ." << std::endl; + _getwch(); + std::exit(0); + }; + + try { + VersionHelper::ValidateAndGetDriverVersion(ASSEMBLY::VERSION); + } + catch (VersionException^ ex) { + Console::WriteLine(ex->Message); + close_prompt(); + } + std::optional<fs::path> opt_path; if (fs::exists(IA_SETTINGS_NAME)) { @@ -235,11 +253,8 @@ int main() if (!try_convert(parse_ia_settings(opt_path.value()))) std::cout << "Unable to convert settings.\n"; } - catch (DriverNotInstalledException^) { - Console::WriteLine("\nDriver is not installed."); - } catch (Exception^ e) { - Console::WriteLine("\nError: " + e->ToString()); + Console::WriteLine("\nError: {0}", e); } catch (const std::exception& e) { std::cout << "Error: " << e.what() << '\n'; @@ -251,6 +266,5 @@ int main() "Then run this program to generate the equivalent Raw Accel settings.\n"; } - std::cout << "Press any key to close this window . . ." << std::endl; - _getwch(); + close_prompt(); } diff --git a/converter/converter.rc b/converter/converter.rc new file mode 100644 index 0000000..94bc8b5 --- /dev/null +++ b/converter/converter.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include <rawaccel-version.h> + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "InterAccel -> RawAccel settings file converter" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "converter.exe" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/converter/converter.vcxproj b/converter/converter.vcxproj index 2bc5080..049dec7 100644 --- a/converter/converter.vcxproj +++ b/converter/converter.vcxproj @@ -67,6 +67,9 @@ <SubSystem>Console</SubSystem> <GenerateDebugInformation>DebugFull</GenerateDebugInformation> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -89,8 +92,12 @@ <PostBuildEvent> <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> </PostBuildEvent> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="AssemblyInfo.cpp" /> <ClCompile Include="converter.cpp" /> </ItemGroup> <ItemGroup> @@ -103,6 +110,12 @@ <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="converter.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/converter/converter.vcxproj.filters b/converter/converter.vcxproj.filters index 954dbfa..f1ad70a 100644 --- a/converter/converter.vcxproj.filters +++ b/converter/converter.vcxproj.filters @@ -18,5 +18,18 @@ <ClCompile Include="converter.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="AssemblyInfo.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="converter.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/converter/resource.h b/converter/resource.h new file mode 100644 index 0000000..a2c7ba8 --- /dev/null +++ b/converter/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by converter.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif |