Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
a0557a3
Adding fixes for 1903 from R-T-B
jshafer817 Jun 30, 2019
75ad723
Update README.md
jshafer817 Jun 30, 2019
8ab25d9
Added new version number
jshafer817 Jul 14, 2019
30f1cc1
Changed the cert
jshafer817 Jul 14, 2019
4337c2a
More version number fixes, and a fix for inf and attestation signing.
jshafer817 Jul 14, 2019
663a5a3
Now cross signed and EV signed for Windows 7 SP1 to Windows 10
jshafer817 Jul 21, 2019
5261ebc
try try again.
jshafer817 Jul 21, 2019
a896ad8
Update SDK files (dll/inc) to match latest 2.1.9.1 version of driver
Jan 10, 2020
9688f85
Remove SpectreMitigation from compilation flags
Jan 10, 2020
c5925f4
Fix display of FFB values (2s complement)
Jan 10, 2020
a3a8200
Update of x64 dll
Jan 10, 2020
96a146a
Corrected project files to compile with VS2019 community + WDK 10.0.1…
Mar 2, 2020
848793b
Cleanup and use VS2019 in BuildAll.bat
Mar 2, 2020
9fec7ce
Fix path to MSBuild with VS2019 Community
Mar 2, 2020
baa49eb
Clean up of project files
njz3 Mar 2, 2020
c7357d1
Add more information in README.md
Mar 5, 2020
5e65c19
Change back to use "git annoted tag" for versionning
Mar 5, 2020
8d8c983
Add DigiCertUtil.exe, just in case
njz3 Mar 5, 2020
24b6f38
Updated hidmapper with latest code from Windows-driver-samples\hid\hi…
njz3 Mar 10, 2020
877d06b
Started to add BlockIndex fix (not yet working)
njz3 Mar 10, 2020
baace73
Add missing prototype in Wrapper.cs
njz3 Mar 11, 2020
741d5d5
Update of PID BlockIndex works, allowing simultaneous effects.
njz3 Mar 11, 2020
6b3b2dc
Shifted BlockIndex to be 0..max-1 and add a check. Fix a small bug in…
njz3 Mar 11, 2020
1839287
Simplified includes in project files and use only one public.h and vj…
njz3 Mar 12, 2020
0b1b619
Add VS settings for C++ coding style. Rename a field.
njz3 Mar 13, 2020
58a0277
Experimental branch for code cleanup. Add 8 more axes (mainly for dri…
njz3 Mar 14, 2020
bdfaeab
Re-target C# wrapper for .Net 4.7.2
njz3 Mar 14, 2020
ccc9b5e
Add a shortcut to CreateSdk.bat
njz3 Mar 14, 2020
b8fdf05
Merge branch 'InternalEffects' of https://github.com/njz3/vJoy into I…
njz3 Mar 14, 2020
ef03dfd
Add axes to vJoyConf
njz3 Mar 14, 2020
ec9ffdc
Add new axes to vJoy Feeder
njz3 Mar 14, 2020
aada5a5
Update SDK and binaries
njz3 Mar 14, 2020
4bebcde
Add new axes into vJoyConf
njz3 Mar 14, 2020
694d795
Fix size of struct for IoDev
njz3 Mar 14, 2020
d496ff5
Add more names for new axes
njz3 Mar 14, 2020
8827b52
Reverted change for buttons size in registry
njz3 Mar 14, 2020
87a6e60
Save acquired state in vJoy Feeder
njz3 Mar 14, 2020
d1f7f06
Avoid to acquire when starting
njz3 Mar 14, 2020
bf4d368
Working, but needs cleaning, in particular in vJoyInterface API to av…
njz3 Mar 16, 2020
c5f6f3a
Slightly changed vJoyInterface API for FFB
njz3 Mar 16, 2020
9517e77
Migrate to API v2.2.0
njz3 Mar 16, 2020
3c9b062
Update README.md
njz3 Mar 16, 2020
dc556eb
Update README.md
njz3 Mar 16, 2020
dda1aea
Fix position structure in the C# wrapper
njz3 Mar 16, 2020
0ba7df7
Corrected some typos
njz3 Mar 16, 2020
db506dd
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Mar 16, 2020
d629f96
Fix alignement of struct for backward compatibility
njz3 Mar 17, 2020
9e7ad09
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Mar 17, 2020
ad86eee
Revert "Fix alignement of struct for backward compatibility"
njz3 Mar 17, 2020
8ad3304
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Mar 17, 2020
fd43992
UseLocalTime when signing to avoid an error
njz3 Mar 17, 2020
d017bc9
New fix for struct alignment to make vJoy backward compatible
njz3 Mar 18, 2020
2ca388b
Merge branch 'InternalEffects' of https://github.com/njz3/vJoy into I…
njz3 Mar 18, 2020
56e4b72
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Mar 18, 2020
b6a2e7a
Change how Ffb_GetNextFreeEffect scan available slots. Save 2 (full) …
njz3 Mar 19, 2020
2a34dc3
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Mar 19, 2020
38a9429
Fix a few typos
njz3 Apr 2, 2020
edd3707
Increase to 128 effect block index. Fix version numbering in C# wrapp…
njz3 Apr 2, 2020
f105b89
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 2, 2020
3fec1e0
Reverted to 40 block index, and fix an issue in wrapper structures al…
njz3 Apr 2, 2020
533d1af
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 2, 2020
fe94549
Use VJOY_FFB_MAX_EFFECTS_BLOCK_INDEX in HID descriptor.
njz3 Apr 2, 2020
1ab96db
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 2, 2020
78462be
Increase to 100 effect block index
njz3 Apr 2, 2020
827d556
Fix an issue within C# wrapper dll (direction was wrongly aligned). U…
njz3 Apr 2, 2020
4722d0f
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 2, 2020
d043edb
Move PID State report to end of HID descriptor. Change Direction from…
njz3 Apr 3, 2020
ac0526b
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 3, 2020
3a37785
Remove unused HID_ID_STATE
njz3 Apr 3, 2020
f9af102
Merge remote-tracking branch 'remotes/origin/InternalEffects' into Bl…
njz3 Apr 3, 2020
76832cf
Set .Net framework to 4.5.2
njz3 Apr 15, 2020
1c0754a
Updated SDK files to report v2.2.0.0 (from git tag)
njz3 Apr 15, 2020
5ddb653
For installer, set minimum OS version to Windows 7 SP1 (6.1.7601)
njz3 Apr 16, 2020
07667c9
Fix bug detected by Rubikoid : one multiple FFB vJoy device were enab…
njz3 Apr 30, 2020
0fbe59b
Update code comments.
njz3 May 21, 2020
80d2595
SDK/vJoyinterface: Fix a bug detected and corrected by ivan-kljajic r…
njz3 May 23, 2020
fa1fefe
Bug Fix from ivan-kljajic: wrong test of for effect report in vJoyInt…
njz3 May 23, 2020
9a2401b
- use only 1 autogenerated gen-versionfile.h in inc/ (generated by Cr…
njz3 Jun 11, 2020
6649f35
- introduce bugfix number in versionning (this is not the # of commit…
njz3 Jun 11, 2020
b259633
- API: Add a VJOY_HAS_FFB compile flag
njz3 Jun 11, 2020
64228d2
- Change driver PID when deploying
njz3 Jun 11, 2020
742244f
- code cleanup and traces added
njz3 Jun 11, 2020
6ba2c7b
- Added new files and remove temporary ones
njz3 Jun 11, 2020
48235af
- reverted back to BEAD as the PID for FFB device, now that vJoy work…
njz3 Jun 11, 2020
903d42f
- Add third key "BEAD" to remove in OEMForceFeedback.
njz3 Jun 11, 2020
e310adc
- fix bug when registry key was not there and code was leaving early
njz3 Jun 11, 2020
9eb09a1
- set PID 1FFB back into INF file, as it seems like BEAD is now alway…
njz3 Jun 11, 2020
9bd2d35
- cleanup and added more traces
njz3 Jun 12, 2020
9cf3546
- add registry file to run when FFB is not detected automatically (bu…
njz3 Jun 12, 2020
daed59c
- updated text in vJoyConf.
njz3 Jun 12, 2020
98cddb8
- Removed hardcoded version string (will use git annoted tag)
njz3 Jun 12, 2020
f66ef44
- update version of SDK file
njz3 Jun 12, 2020
9d85b85
- synchronized VERSION_N between vJoyInterface.cpp and driver (use sa…
njz3 Jun 12, 2020
6f91caf
- update SDK file with a build done from last master
njz3 Jun 12, 2020
a577ff7
- Code cleanup
njz3 Jun 13, 2020
c50f793
- add commented code for RAM pool updated in PID (seems not useful)
njz3 Jun 13, 2020
8a68cf2
- Add FIRST_EID_PREALLOCATED compile flag to preallocate an effect ev…
njz3 Jun 13, 2020
ca57587
Update SDK files
njz3 Jun 13, 2020
0a889ef
- simplify code for FIRST_EID_PREALLOCATED
njz3 Jun 13, 2020
e00cce0
Update SDK files
njz3 Jun 13, 2020
bc3cd3c
Fix a bug in RAM pool available when freeing an effect block.
njz3 Jun 25, 2020
229a334
Fix C++ sample in SDK
njz3 Jun 25, 2020
d44fe7c
Set .NET framework to 4.0 for wrapper
njz3 Jun 25, 2020
ea8bbbd
Fixed C# sample and added example FFB handler from my feeder
njz3 Jun 25, 2020
5b04ae8
Add missing file
njz3 Jun 25, 2020
1216c20
Update SDK files
njz3 Jun 25, 2020
d88d74d
Set all targets (Libs, SDK samples) to .Net version to 4.5.2 instead …
njz3 Jun 28, 2020
7f21096
SDK: Increase version to v2.2.1.1, now uses .Net 4.5.2
njz3 Jun 28, 2020
53d6a39
Update README.md
njz3 Jul 17, 2020
5d7cfdc
Use hardcoded version string instead of 'git describe' to embed versi…
njz3 Jul 18, 2020
e52bbbc
Merge branch 'master' of https://github.com/njz3/vJoy
njz3 Jul 18, 2020
28bede0
Set to v2.2.1.1 to match tag of the SDK
njz3 Jul 18, 2020
07ed213
Update README.md
BraINstinct0 Aug 11, 2020
69ac600
vJoyInterfaceWrap: calling convention of all imports from vJoyInterfa…
lukester1975 Dec 12, 2020
af0ae72
Merge pull request #1 from BraINstinct0/patch-1
njz3 Dec 19, 2020
d56de94
Merge pull request #2 from lukester1975/cdecl-fix
njz3 Dec 19, 2020
6f059b4
Fix compiling with latest VS2019 + WDK (v10.0.19041.0)
Aug 11, 2023
11e237c
Use latest WDK 10.0.22621.0.
Aug 16, 2023
80efb0c
Fix inno setup script
Aug 16, 2023
f9cfc50
Update README.md and remove old files
njz3 Aug 16, 2023
a96da3e
remove unused file
njz3 Aug 16, 2023
8797dec
Update c++ dependencies for apps
njz3 Aug 16, 2023
39ca771
Fid dependencies and SDK for x64 only
njz3 Aug 16, 2023
c42976d
Fix dependencies and user project parameters
njz3 Aug 16, 2023
5371c1f
Put temp file in ignore list
njz3 Aug 16, 2023
0d59562
Enforce version in the code rather than retrieving from git for peopl…
njz3 Aug 16, 2023
e731f98
Set version to 2.2.2.0
njz3 Aug 16, 2023
9257adf
Add tools and missing dlls
njz3 Aug 17, 2023
68ddf43
Set installer minimum OS version to 10.0.14393: Windows 10 Version 16…
njz3 Aug 17, 2023
b9fca05
removed unused dirs files
njz3 Aug 17, 2023
42007bb
Change the message related to vJoyInit.reg, as it reports a "false-po…
njz3 Aug 17, 2023
e2e6ea7
Update README.md
Strat00s Sep 20, 2024
9066d9f
Update .NET framework for apps solution to 4.8
code-monet Oct 25, 2024
b778820
Add proof of concept version of Python API with demo script.
code-monet Oct 25, 2024
bfc57f3
Add some more functions for first PR
code-monet Oct 25, 2024
e4953c4
Add vJoy device object enumeration to the Python API
code-monet Oct 26, 2024
9a7e669
Retarget apps solution to newer SDK
code-monet Oct 26, 2024
4ca6b3d
Implement most of the remaining inputs API.
code-monet Oct 26, 2024
6de542c
Add the function for setting all inputs in one call. Add missing enum…
code-monet Oct 26, 2024
321987b
Update the compiled Python extension in the examples directory. Minor…
code-monet Oct 26, 2024
7a856f4
Normalized values should lie in [0, 1]
code-monet Oct 27, 2024
4da2edf
Merge pull request #27 from Strat00s/patch-1
njz3 Oct 27, 2024
02a337b
Merge pull request #28 from code-monet/python_api
njz3 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*.suo
*.user

/apps/vJoyFeeder/vJoyFeeder01.vcxproj

# Folders
win32/
x64/
Expand Down Expand Up @@ -56,7 +54,6 @@ apps/common/vJoyInterfaceCS/vJoyInterfaceWrap/obj/Debug_CPP/build.force
apps/common/vJoyInterfaceCS/WrapperTest/obj/
apps/common/vJoyInterfaceCS/vJoyInterfaceWrap/bin/
apps/common/vJoyInterfaceCS/vJoyInterfaceWrap/obj/
Release_STAT/
apps/common/vJoyInterfaceStat/bldInterface.bat
apps/common/vJoyInterfaceStat/makefile
apps/common/vJoyInterfaceStat/makefile.inc
Expand All @@ -74,9 +71,11 @@ apps/common/vJoyInterfaceStat/gen-versioninfo.h
driver/sys/gen-versioninfo.h
apps/vJoyInstall/CmdLine/gen-versioninfo.h
driver/Package/gen-versioninfo.h
driver/sys/vJoy.vcxproj.user
SDK/ReadMe-2.1.5.odt
apps/vJoyList/gen-versioninfo.h
SDK.zip
SDK/ReadMe.pdf
SDK/c#/ReadMe.pdf
apps/vJoyConf/vJoyConf.aps
/apps/vJoyList/vJoyList.aps
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "extern/pybind11"]
path = extern/pybind11
url = ../../pybind/pybind11
branch = stable
28 changes: 17 additions & 11 deletions BuildAll.bat
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
echo off
SET VS=14.0
SET BUILDER=%ProgramFiles(x86)%\MSBuild\%VS%\Bin\MSBuild.exe
SET Target64=x64\Release
SET Target32=Win32\Release
SET DigiCertUtil=%USERPROFILE%\DESKTOP\DigiCertUtil.exe
SET InnoCompiler=%ProgramFiles(x86)%\Inno Setup 5\ISCC.exe

SET BuildMode=Release
REM SET BuildMode=Debug

SET VS=2022\Community
SET BUILDER=%ProgramFiles%\Microsoft Visual Studio\%VS%\MSBuild\Current\Bin\MSBuild.exe
SET Target64=x64\%BuildMode%
SET Target32=Win32\%BuildMode%
SET DigiCertUtil=DigiCertUtil.exe
SET InnoCompiler=%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe

REM Skip x86 for Windows 10 and above
goto build64

:build32
echo %DATE% %TIME%: Cleaning vJoy (x86)
"%BUILDER%" vjoy.sln /maxcpucount:1 /t:clean /p:Platform=Win32;Configuration=Release
"%BUILDER%" vJoyAll.sln /maxcpucount:1 /t:clean /p:Platform=Win32;Configuration=%BuildMode%
set BUILD_STATUS=%ERRORLEVEL%
if not %BUILD_STATUS%==0 goto fail

echo %DATE% %TIME%: Building vJoy (x86)
"%BUILDER%" vjoy.sln /maxcpucount:4 /p:Platform=Win32;Configuration=Release
"%BUILDER%" vJoyAll.sln /maxcpucount:4 /p:Platform=Win32;Configuration=%BuildMode%
set BUILD_STATUS=%ERRORLEVEL%
if not %BUILD_STATUS%==0 goto fail

:build64
echo %DATE% %TIME%: Cleaning vJoy (x64)
"%BUILDER%" vjoy.sln /maxcpucount:1 /t:clean /p:Platform=x64;Configuration=Release
"%BUILDER%" vJoyAll.sln /maxcpucount:1 /t:clean /p:Platform=x64;Configuration=%BuildMode%
set BUILD_STATUS=%ERRORLEVEL%
if not %BUILD_STATUS%==0 goto fail

echo %DATE% %TIME%: Building vJoy (x64)
"%BUILDER%" vjoy.sln /maxcpucount:4 /p:Platform=x64;Configuration=Release
"%BUILDER%" vJoyAll.sln /maxcpucount:4 /p:Platform=x64;Configuration=%BuildMode%
set BUILD_STATUS=%ERRORLEVEL%
if not %BUILD_STATUS%==0 goto fail

:signapps
echo %DATE% %TIME%: Signing the applications
IF NOT EXIST %DigiCertUtil% GOTO NOUTIL
%DigiCertUtil% sign /sha1 "6d 54 71 df 6b bf af a5 d5 90 0c 88 c0 8d f0 e9 c5 13 69 0a" /noInput .\%Target64%\vJoyList.exe*.\%Target32%\vJoyList.exe*.\%Target64%\vJoyConf.exe*.\%Target32%\vJoyConf.exe*.\%Target64%\vJoyFeeder.exe*.\%Target32%\vJoyFeeder.exe
%DigiCertUtil% sign /sha1 "6b 05 e5 cc 0d b8 8a 0d 89 62 48 2e cb 9c d9 59 e1 b0 57 90" /noInput .\%Target64%\vJoyList.exe*.\%Target32%\vJoyList.exe*.\%Target64%\vJoyConf.exe*.\%Target32%\vJoyConf.exe*.\%Target64%\vJoyFeeder.exe*.\%Target32%\vJoyFeeder.exe
set SIGN_STATUS=%ERRORLEVEL%
if not %SIGN_STATUS%==0 goto fail
echo %DATE% %TIME%: Signing the applications - OK
Expand Down
1 change: 1 addition & 0 deletions CodingStyleCPP.vssettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<UserSettings><ApplicationIdentity version="16.0"/><ToolsOptions><ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor"><ToolsOptionsSubCategory name="C/C++" RegisteredName="C/C++" PackageName="Text Management Package"><PropertyValue name="TabSize">4</PropertyValue><PropertyValue name="ShowChanges">true</PropertyValue><PropertyValue name="AutoListMembers">true</PropertyValue><PropertyValue name="ShowPreview">true</PropertyValue><PropertyValue name="ShowMarks">true</PropertyValue><PropertyValue name="IndentStyle">2</PropertyValue><PropertyValue name="ShowCaretPosition">true</PropertyValue><PropertyValue name="HideAdvancedMembers">true</PropertyValue><PropertyValue name="ShowNavigationBar">true</PropertyValue><PropertyValue name="UseMapMode">false</PropertyValue><PropertyValue name="VirtualSpace">false</PropertyValue><PropertyValue name="ShowAnnotations">true</PropertyValue><PropertyValue name="ShowVerticalScrollBar">true</PropertyValue><PropertyValue name="InsertTabs">false</PropertyValue><PropertyValue name="WordWrapGlyphs">true</PropertyValue><PropertyValue name="EnableLeftClickForURLs">true</PropertyValue><PropertyValue name="ShowErrors">true</PropertyValue><PropertyValue name="OverviewWidth">58</PropertyValue><PropertyValue name="ShowLineNumbers">true</PropertyValue><PropertyValue name="WordWrap">false</PropertyValue><PropertyValue name="IndentSize">4</PropertyValue><PropertyValue name="BraceCompletion">true</PropertyValue><PropertyValue name="ShowHorizontalScrollBar">true</PropertyValue><PropertyValue name="CutCopyBlankLines">true</PropertyValue><PropertyValue name="AutoListParams">true</PropertyValue></ToolsOptionsSubCategory></ToolsOptionsCategory></ToolsOptions></UserSettings>
22 changes: 22 additions & 0 deletions CreateSdk.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
REM Automate the creation of an SDK package
set SDK_PATH=SDK
set X64RELEASE_PATH=X64\Release
REM set X86RELEASE_PATH=Win32\Release
set INC_PATH=Inc

REM C#
REM COPY %X86RELEASE_PATH%\vJoyInterface.dll "%SDK_PATH%\c#\x86\vJoyInterface.dll"
REM COPY %X86RELEASE_PATH%\vJoyInterfaceWrap.dll "%SDK_PATH%\c#\x86\vJoyInterfaceWrap.dll"
COPY %X64RELEASE_PATH%\vJoyInterface.dll "%SDK_PATH%\c#\x64\vJoyInterface.dll"
COPY %X64RELEASE_PATH%\vJoyInterfaceWrap.dll "%SDK_PATH%\c#\x64\vJoyInterfaceWrap.dll"

REM Include Files
COPY %INC_PATH%\public.h "%SDK_PATH%\Inc\public.h"
COPY %INC_PATH%\gen-versioninfo.h "%SDK_PATH%\Inc\gen-versioninfo.h"
COPY apps\common\vJoyInterface\vjoyinterface.h "%SDK_PATH%\Inc\vjoyinterface.h"

REM Library Files
REM COPY %X86RELEASE_PATH%\vJoyInterface.dll "%SDK_PATH%\LIB\x86\vJoyInterface.dll"
REM COPY %X86RELEASE_PATH%\vJoyInterface.lib "%SDK_PATH%\LIB\x86\vJoyInterface.lib"
COPY %X64RELEASE_PATH%\vJoyInterface.dll "%SDK_PATH%\LIB\x64\vJoyInterface.dll"
COPY %X64RELEASE_PATH%\vJoyInterface.lib "%SDK_PATH%\LIB\x64\vJoyInterface.lib"
221 changes: 119 additions & 102 deletions CreateVersion/CreateVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,136 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

// When building without git tools, use hardcoded version below
#define ALWAYS_USE_HARD_CODED_VERSION

#define HARD_CODED_VERSION "v2.2.2.0"
#define HARD_CODED_VERSIONSHA "000000"

#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif

static void find_delim(char *s, char **res, int *ix)
static void find_delim(char* s, char** res, int* ix)
{
for (; *ix && s[*ix] != '-'; *ix -= 1);
if (*ix) {
s[*ix] = '\0';
*res = s + *ix + 1;
}
else {
*res = s;
}
for (; *ix && s[*ix] != '-'; *ix -= 1);
if (*ix) {
s[*ix] = '\0';
*res = s + *ix + 1;
} else {
*res = s;
}
}

int main(int argc, char **argv)
int main(int argc, char** argv)
{
unsigned int major = 0, mid = 0, minor = 0, commits = 0;
char vbuf[4096] = { 0 };
char *version="0.0.0", *ncommits="0", *sha="0";
FILE *po;
int buflen;
int outval;

// Open output file
char * filename = argv[1];
if (!filename) {
fprintf(stderr, "Bad output file name\n");
return -5;
}

FILE * f;
errno_t err = fopen_s(&f, filename, "w+");
if (err || !f)
{
fprintf(stderr, "Could not oupen output file name (errno=%d)\n", err);
return -6;
}

fprintf(stderr, "Starting CreateVersion\n");
if (argc != 2) {
fprintf(stderr, "Usage: %s <Outputfile>\n", argv[0]);
outval = -1;
goto FINAL;
}

/** Get the output */
po = popen("git describe --long --match v*", "r");
if (!po) {
perror("git describe");
outval = -2;
goto FINAL;
}

if (!fgets(vbuf, sizeof(vbuf), po)) {
fprintf(stderr, "git describe closed stream\n");
outval = -3;
goto FINAL;
}
pclose(po);
buflen = (int)strlen(vbuf);
vbuf[buflen - 2] = '\0';
buflen -= 1;

// SHA1 (Remove the leading 'g')
find_delim(vbuf, &sha, &buflen);
sha++;

// Commit # - Will be used as build number
find_delim(vbuf, &ncommits, &buflen);


// Version
version = vbuf;

// Break the version number into its components
int nFields = sscanf_s(version, "v%u.%u.%u.%u",&major, &mid, &minor, &commits) ;
if (nFields < 3) {
fprintf(stderr, "Version string corrupt\n");
outval = -4;
goto FINAL;
}

// Case of version of type v2.1.8
if (nFields == 3)
sscanf_s(ncommits, "%u", &commits);
unsigned int major = 0, mid = 0, minor = 0, bugfix = 0, nbcommits = 0;
char vbuf[4096] = { 0 };
// Hardcoded for v221 branch development
char* version = HARD_CODED_VERSION, * build_ncommits = "0", * sha1 = "0";
int outval;

// Open output file
char* filename = argv[1];
if (!filename) {
fprintf(stderr, "Bad output file name\n");
return -5;
}

FILE* f;
errno_t err = fopen_s(&f, filename, "w+");
if (err || !f) {
fprintf(stderr, "Could not oupen output file name (errno=%d)\n", err);
return -6;
}

fprintf(stderr, "Starting CreateVersion\n");
if (argc != 2) {
fprintf(stderr, "Usage: %s <Outputfile>\n", argv[0]);
return -1;
}

#ifdef ALWAYS_USE_HARD_CODED_VERSION
build_ncommits = "0";
sha1 = HARD_CODED_VERSIONSHA;
#else
/** Get the output */
int buflen;
FILE* po = popen("git describe --long --match v*", "r");
if (!po) {
fprintf(stderr, "git describe is missing, please install git for windows. Using default hardcoded version.\n");
outval = -2;
goto PARSE_VERSION;
}

if (!fgets(vbuf, sizeof(vbuf), po)) {
fprintf(stderr, "git describe closed stream is missing, please install git for windows. Using default hardcoded version.\n");
outval = -3;
goto PARSE_VERSION;
}
pclose(po);
buflen = (int)strlen(vbuf);
vbuf[buflen - 2] = '\0';
buflen -= 1;

// SHA1 (Remove the leading 'g')
find_delim(vbuf, &sha1, &buflen);
sha1++;

// Commit # - Will be used as build number
find_delim(vbuf, &build_ncommits, &buflen);

PARSE_VERSION:
// Version
version = vbuf;
#endif

// Break the version number into its components
int nFieldsVersion = sscanf_s(version, "v%u.%u.%u.%u", &major, &mid, &minor, &bugfix);
if (nFieldsVersion < 3) {
fprintf(stderr, "Version string wrongly formatted, value was %s\n", version);
outval = -4;
goto FINAL;
}

// Get number of commits
int nFieldsCommits = sscanf_s(build_ncommits, "%u", &nbcommits);

// Case of version of type v2.1.9, in this case take last 4th number to be nb of commits
if (nFieldsVersion == 3 && nFieldsCommits>0) {
bugfix = nbcommits;
}

// Check intermediate values are a nibble
if (major>0xF ||
mid>0xF ||
minor>0xF ||
bugfix>0xF
) {
fprintf(stderr, "Error invalid version number, one field is greater than 15 (a nibble in 4bits): v%d.%d.%d.%d", major, mid, minor, bugfix);
outval = -5;
goto FINAL;
}


FINAL:
// Put data into file
fprintf(f, "#pragma once\n");
fprintf(f, "#define VER_H_ %u\n", major);
fprintf(f, "#define VER_M_ %u\n", mid);
fprintf(f, "#define VER_L_ %u\n", minor);
fprintf(f, "#define BUILD %u\n", commits);
fprintf(f, "\n");
fprintf(f, "#define FILEVER\t\t\t\t\"%u, %u, %u, %u\"\n", major, mid, minor, commits);
fprintf(f, "#define PRODVER_TAG\t\t\t\"%s\"\n", version);
fprintf(f, "#define PRODVER_SHA1\t\t\"%s\"\n", sha);
fprintf(f, "\n");


return 0;
// Put data into file
fprintf(f, "#pragma once\n");
fprintf(f, "// Version as four nibbles as X.H.M.L\n");
fprintf(f, "#define VER_X_ %u\n", major);
fprintf(f, "#define VER_H_ %u\n", mid);
fprintf(f, "#define VER_M_ %u\n", minor);
fprintf(f, "#define VER_L_ %u\n", bugfix);
fprintf(f, "// Internal use only\n");
fprintf(f, "#define BUILD %u\n", nbcommits);
fprintf(f, "\n");
fprintf(f, "#define FILEVER\t\t\t\t\"%u, %u, %u, %u\"\n", major, mid, minor, bugfix);
fprintf(f, "#define PRODVER_TAG\t\t\t\"%s\"\n", version);
fprintf(f, "#define PRODVER_SHA1\t\t\"%s\"\n", sha1);
fprintf(f, "\n");


return 0;
}

//#include "stdafx.h"
//
//
//int main()
//{
// return 0;
//}
//
Loading