Add a version display based on the git tag.

master
Glenn Maynard 7 years ago
parent 3d6eb112e6
commit e57fa5d28e
  1. 4
      sdk/SMX.h
  2. 3
      sdk/Windows/.gitignore
  3. 2
      sdk/Windows/SMX.cpp
  4. 9
      sdk/Windows/SMX.vcxproj
  5. 3
      sdk/Windows/SMX.vcxproj.filters
  6. 43
      sdk/Windows/update-build-version.bat
  7. 22
      smx-config/MainWindow.xaml
  8. 3
      smx-config/MainWindow.xaml.cs
  9. 19
      smx-config/SMX.cs
  10. 2
      smx-config/SMXConfig.csproj

@ -100,6 +100,10 @@ extern "C" SMX_API void SMX_ForceRecalibration(int pad);
extern "C" SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode); extern "C" SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode);
extern "C" SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data); extern "C" SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data);
// Return the build version of the DLL, which is based on the git tag at build time. This
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
extern "C" SMX_API const char *SMX_Version();
// General info about a connected controller. This can be retrieved with SMX_GetInfo. // General info about a connected controller. This can be retrieved with SMX_GetInfo.
struct SMXInfo struct SMXInfo
{ {

@ -0,0 +1,3 @@
# Ignore updates to the auto-generated build version.
SMXBuildVersion.h

@ -6,6 +6,7 @@
#include "../SMX.h" #include "../SMX.h"
#include "SMXManager.h" #include "SMXManager.h"
#include "SMXDevice.h" #include "SMXDevice.h"
#include "SMXBuildVersion.h"
using namespace std; using namespace std;
using namespace SMX; using namespace SMX;
@ -63,3 +64,4 @@ SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { g_pSMX->GetDevice(p
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return g_pSMX->GetDevice(pad)->GetTestData(*data); } SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return g_pSMX->GetDevice(pad)->GetTestData(*data); }
SMX_API void SMX_SetLights(const char lightsData[864]) { g_pSMX->SetLights(string(lightsData, 864)); } SMX_API void SMX_SetLights(const char lightsData[864]) { g_pSMX->SetLights(string(lightsData, 864)); }
SMX_API void SMX_ReenableAutoLights() { g_pSMX->ReenableAutoLights(); } SMX_API void SMX_ReenableAutoLights() { g_pSMX->ReenableAutoLights(); }
SMX_API const char *SMX_Version() { return SMX_BUILD_VERSION; }

@ -13,6 +13,7 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="..\SMX.h" /> <ClInclude Include="..\SMX.h" />
<ClInclude Include="Helpers.h" /> <ClInclude Include="Helpers.h" />
<ClInclude Include="SMXBuildVersion.h" />
<ClInclude Include="SMXDevice.h" /> <ClInclude Include="SMXDevice.h" />
<ClInclude Include="SMXDeviceConnection.h" /> <ClInclude Include="SMXDeviceConnection.h" />
<ClInclude Include="SMXDeviceSearch.h" /> <ClInclude Include="SMXDeviceSearch.h" />
@ -90,6 +91,10 @@
<AdditionalDependencies>hid.lib;setupapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>hid.lib;setupapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(SolutionDir)/out/$(TargetName)$(TargetExt)</OutputFile> <OutputFile>$(SolutionDir)/out/$(TargetName)$(TargetExt)</OutputFile>
</Link> </Link>
<PreBuildEvent>
<Command>$(SolutionDir)sdk\Windows\update-build-version.bat
</Command>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@ -125,6 +130,10 @@
<Inputs> <Inputs>
</Inputs> </Inputs>
</CustomBuildStep> </CustomBuildStep>
<PreBuildEvent>
<Command>$(SolutionDir)sdk\Windows\update-build-version.bat
</Command>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

@ -31,6 +31,9 @@
<ClInclude Include="Helpers.h"> <ClInclude Include="Helpers.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SMXBuildVersion.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="SMX.cpp"> <ClCompile Include="SMX.cpp">

@ -0,0 +1,43 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem A good old 80s batch file, because it's guaranteed to always be available.
rem This assumes git is in the path.
for /F %%I in ('git describe --always --dirty') do set GITVER=%%I
if "%GITVER%" == "" goto git_error
rem Replace -dirty with -devel, to indicate builds with uncommitted changes.
set GITVER=%GITVER:-dirty=-devel%
goto continue
:git_error
rem If calling git fails for some reason, put a message in the version instead of
rem letting it be blank.
set GITVER=git failed
:continue
rem Output the current version to a temp file.
set TEMP_FILE=%TEMP%\temp-SMXBuildVersion.h
set OUTPUT_FILE=SMXBuildVersion.h
echo // This file is auto-generated by update-build-version.bat. > %TEMP_FILE%
echo. >> %TEMP_FILE%
echo #ifndef SMXBuildVersion_h >> %TEMP_FILE%
echo #define SMXBuildVersion_h >> %TEMP_FILE%
echo. >> %TEMP_FILE%
echo #define SMX_BUILD_VERSION "%GITVER%" >> %TEMP_FILE%
echo. >> %TEMP_FILE%
echo #endif >> %TEMP_FILE%
rem Compare the temp file to any existing file. Only copy the new file over the old
rem one if it's different, so we don't trigger dependency rebuilds every time.
fc %TEMP_FILE% %OUTPUT_FILE% > nul
if %errorlevel% == 0 goto end
echo Updated to version %GITVER%
copy %TEMP_FILE% %OUTPUT_FILE% > nul
:end

@ -636,8 +636,11 @@ Use if the platform is too sensitive.</clr:String>
<Grid x:Name="Searching" Visibility="Hidden" Background="#DDD"> <Grid x:Name="Searching" Visibility="Hidden" Background="#DDD">
<Label Content="Searching for controller..." <Label Content="Searching for controller..."
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="33.333"/> HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="33.333"/>
<Label x:Name="Version1" Content="Version"
HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="15" Margin="0 0 0 10" />
</Grid> </Grid>
<TabControl x:Name="Main" Margin="0,0,0,0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<TabControl x:Name="Main" Margin="0,0,0,0" Visibility='Visible' HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<TabItem Header="Settings"> <TabItem Header="Settings">
<Grid Background="#FFE5E5E5" RenderTransformOrigin="0.5,0.5"> <Grid Background="#FFE5E5E5" RenderTransformOrigin="0.5,0.5">
@ -709,6 +712,13 @@ Use if the platform is too sensitive.</clr:String>
<Button x:Name="SetAllPanelsToCurrentColor" Content="Set all panels to this color" HorizontalAlignment="Center" Padding="6,2" Margin="0,6,0,0" /> <Button x:Name="SetAllPanelsToCurrentColor" Content="Set all panels to this color" HorizontalAlignment="Center" Padding="6,2" Margin="0,6,0,0" />
</StackPanel> </StackPanel>
<!-- This version label is tweaked so it's in the same place as the one on the
connecting screen. If we use the same margin, the tab container's border
shifts it by a couple pixels, which makes it fidget around when we connect
and disconnect. -->
<Label x:Name="Version2" Content="Version"
HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="15" Margin="0 0 0 7" />
</Grid> </Grid>
</TabItem> </TabItem>
@ -762,8 +772,8 @@ slider, and deactivate when it reaches the left side of the slider.</TextBlock>
<TabItem Header="Advanced"> <TabItem Header="Advanced">
<StackPanel Background="#FFE5E5E5"> <StackPanel Background="#FFE5E5E5">
<TextBlock HorizontalAlignment="Center" Margin="0,15,0,10" VerticalAlignment="Top" <TextBlock HorizontalAlignment="Center" Margin="0,15,0,10" VerticalAlignment="Top"
TextAlignment="Center" TextAlignment="Center"
xml:space="preserve" FontSize="16">Active panels</TextBlock> xml:space="preserve" FontSize="16">Active panels</TextBlock>
<TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,0,0,0" TextAlignment="Center">Select which directions have sensors, and deselect panels that aren't in use. <TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,0,0,0" TextAlignment="Center">Select which directions have sensors, and deselect panels that aren't in use.
Input will be disabled from deselected panels.</TextBlock> Input will be disabled from deselected panels.</TextBlock>
@ -776,7 +786,7 @@ Input will be disabled from deselected panels.</TextBlock>
<TextBlock HorizontalAlignment="Center" <TextBlock HorizontalAlignment="Center"
xml:space="preserve" FontSize="16">Import/export settings</TextBlock> xml:space="preserve" FontSize="16">Import/export settings</TextBlock>
<TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,5,0,0" TextAlignment="Center" <TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,5,0,0" TextAlignment="Center"
>Export current settings to a file.</TextBlock> >Export current settings to a file.</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Export" Width="50" Padding="5,2" Margin="5,10" Click="ExportSettings" /> <Button Content="Export" Width="50" Padding="5,2" Margin="5,10" Click="ExportSettings" />
<Button Content="Import" Width="50" Padding="5,2" Margin="5,10" Click="ImportSettings" /> <Button Content="Import" Width="50" Padding="5,2" Margin="5,10" Click="ImportSettings" />
@ -784,7 +794,7 @@ Input will be disabled from deselected panels.</TextBlock>
<Separator Margin="0,10,0,10" /> <Separator Margin="0,10,0,10" />
<TextBlock HorizontalAlignment="Center" <TextBlock HorizontalAlignment="Center"
xml:space="preserve" FontSize="16">Reset all settings</TextBlock> xml:space="preserve" FontSize="16">Reset all settings</TextBlock>
<Button Content="Factory reset" Width="140" Margin="0 10 0 0" Padding="0 4" Click="FactoryReset_Click"/> <Button Content="Factory reset" Width="140" Margin="0 10 0 0" Padding="0 4" Click="FactoryReset_Click"/>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
@ -806,7 +816,5 @@ Input will be disabled from deselected panels.</TextBlock>
<Label x:Name="P1Connected" Style="{StaticResource EnabledIcon}" Content="P1" Margin="1,0,4,0" FontSize="10"/> <Label x:Name="P1Connected" Style="{StaticResource EnabledIcon}" Content="P1" Margin="1,0,4,0" FontSize="10"/>
<Label x:Name="P2Connected" Style="{StaticResource EnabledIcon}" Content="P2" Margin="0,0,4,0" FontSize="10"/> <Label x:Name="P2Connected" Style="{StaticResource EnabledIcon}" Content="P2" Margin="0,0,4,0" FontSize="10"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

@ -24,6 +24,9 @@ namespace smx_config
{ {
base.OnApplyTemplate(); base.OnApplyTemplate();
Version1.Content = "SMXConfig version " + SMX.SMX.Version();
Version2.Content = "SMXConfig version " + SMX.SMX.Version();
AutoLightsColor.StartedDragging += delegate() { showAutoLightsColor.Start(); }; AutoLightsColor.StartedDragging += delegate() { showAutoLightsColor.Start(); };
AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); }; AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); };
AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); }; AutoLightsColor.StoppedDragging += delegate() { showAutoLightsColor.Stop(); };

@ -246,12 +246,29 @@ namespace SMX
private static extern bool SMX_SetLights(byte[] buf); private static extern bool SMX_SetLights(byte[] buf);
[DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern bool SMX_ReenableAutoLights(); private static extern bool SMX_ReenableAutoLights();
[DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern IntPtr SMX_Version();
public static string Version()
{
if(!DLLAvailable()) return "";
// I can't find any way to marshal a simple null-terminated string. Marshalling
// UnmanagedType.LPStr tries to deallocate the string, which crashes since it's
// a static string.
unsafe {
sbyte *p = (sbyte *) SMX_Version();
int length = 0;
while(p[length] != 0)
++length;
return new string(p, 0, length);
}
}
// Check if the native DLL is available. This is mostly to avoid exceptions in the designer. // Check if the native DLL is available. This is mostly to avoid exceptions in the designer.
// This returns false if the DLL doesn't load. // This returns false if the DLL doesn't load.
public static bool DLLAvailable() public static bool DLLAvailable()
{ {
return LoadLibrary("SMX.dll") != IntPtr.Zero; return LoadLibrary("SMX.dll") != IntPtr.Zero;
} }

@ -70,7 +70,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
<LangVersion>default</LangVersion> <LangVersion>default</LangVersion>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

Loading…
Cancel
Save