Skip to content

Commit

Permalink
Pad remapping, saving and loading Xidi config, error handling improve…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
spitfirex86 committed Feb 18, 2023
1 parent 724ee00 commit 7d8abde
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 113 deletions.
1 change: 1 addition & 0 deletions R2FixCfg/R2FixCfg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClCompile Include="display.c" />
<ClCompile Include="generaldlg.c" />
<ClCompile Include="main.c" />
<ClCompile Include="pad.c" />
<ClCompile Include="paddlg.c" />
<ClCompile Include="tweaksdlg.c" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions R2FixCfg/R2FixCfg.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ClCompile Include="paddlg.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pad.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand Down
71 changes: 40 additions & 31 deletions R2FixCfg/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Status",IDC_STATIC,6,6,242,68
EDITTEXT IDC_STATUSLINE,14,18,226,32,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
CONTROL "Enable Ray2Fix",IDC_MAINTOGGLE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,14,56,65,10
EDITTEXT IDC_STATUSLINE,14,18,226,34,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
CONTROL "Enable Ray2Fix",IDC_MAINTOGGLE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,14,58,65,10
GROUPBOX "Resolution / Window Size",IDC_STATIC,6,78,126,46
COMBOBOX IDC_RESOLUTION,14,90,110,74,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_RESX,14,90,46,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
Expand Down Expand Up @@ -125,44 +125,44 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "L Stick:",IDC_STATIC,6,11,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_LS,42,9,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_LS,42,9,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "LS Click:",IDC_STATIC,6,29,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_LSCLICK,42,27,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_LSCLICK,42,27,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "R Stick:",IDC_STATIC,126,11,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_RS,162,9,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_RS,162,9,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "RS Click:",IDC_STATIC,126,29,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_RSCLICK,162,27,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,45,239,1
COMBOBOX IDC_RSCLICK,162,27,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,45,246,1
LTEXT "Up:",IDC_STATIC,6,53,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_DUP,42,51,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DUP,42,51,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Down:",IDC_STATIC,6,71,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_DDOWN,42,69,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DDOWN,42,69,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Left:",IDC_STATIC,6,89,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_DLEFT,42,87,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DLEFT,42,87,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Right:",IDC_STATIC,6,107,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_DRIGHT,42,105,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DRIGHT,42,105,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "A:",IDC_STATIC,126,53,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_AA,162,51,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_AA,162,51,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "B:",IDC_STATIC,126,71,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_BB,162,69,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_BB,162,69,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "X:",IDC_STATIC,126,89,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_XX,162,87,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_XX,162,87,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Y:",IDC_STATIC,126,107,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_YY,162,105,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,123,240,1
COMBOBOX IDC_YY,162,105,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,123,246,1
LTEXT "LT:",IDC_STATIC,6,131,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_LT,42,129,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_LT,42,129,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "LB:",IDC_STATIC,6,149,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_LB,42,147,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_LB,42,147,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "RT:",IDC_STATIC,126,131,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_RT,162,129,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_RT,162,129,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "RB:",IDC_STATIC,126,149,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_RB,162,147,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,165,240,1
COMBOBOX IDC_RB,162,147,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,165,246,1
LTEXT "Back:",IDC_STATIC,6,173,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_BBACK,42,171,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_BBACK,42,171,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Start:",IDC_STATIC,126,173,30,8,0,WS_EX_RIGHT
COMBOBOX IDC_BSTART,162,171,72,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_BSTART,162,171,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END


Expand All @@ -172,8 +172,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,1,0
PRODUCTVERSION 1,2,1,0
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -190,12 +190,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Spitfire_x86"
VALUE "FileDescription", "Ray2Fix Settings"
VALUE "FileVersion", "1.2.1.0"
VALUE "FileVersion", "1.3.0.0"
VALUE "InternalName", "R2FixCfg.exe"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "R2FixCfg.exe"
VALUE "ProductName", "R2FixCfg"
VALUE "ProductVersion", "1.2.1.0"
VALUE "ProductVersion", "1.3.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down Expand Up @@ -244,9 +244,8 @@ BEGIN
TOPMARGIN, 6
BOTTOMMARGIN, 188
HORZGUIDE, 18
HORZGUIDE, 50
HORZGUIDE, 56
HORZGUIDE, 66
HORZGUIDE, 52
HORZGUIDE, 58
HORZGUIDE, 74
HORZGUIDE, 78
HORZGUIDE, 90
Expand Down Expand Up @@ -367,6 +366,16 @@ BEGIN
IDS_VE_GLIDE "GliVd1Vf.dll "
IDS_VE_FIX "GliFixVf.dll "
IDS_VE_DINPUT "dinput.dll "
IDS_VE_XIDI "Xidi.ini"
IDS_VE_SETPAD "\r\nTo use a controller, choose a new layout in the Gamepad tab."
IDS_VE_XIDICHANGED "\r\nGamepad config has been manually edited."
IDS_WARNING "Warning:"
END

STRINGTABLE
BEGIN
IDS_VE_OKWARN "File verification completed with warnings."
IDS_NEWLINE "\r\n"
END

#endif // English (United States) resources
Expand Down
59 changes: 40 additions & 19 deletions R2FixCfg/config.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "framework.h"
#include "config.h"
#include "pad.h"


/*
Expand All @@ -16,7 +17,8 @@ tdeRefRate g_eRefRate = e_RR_Full;
BOOL g_bForceVsync = FALSE;
BOOL g_bFullscreen = FALSE;

tdeVerifyErr g_eMissingFiles = e_VE_Ok;
tdeErrorState g_eError = e_ES_Ok;
tdeVerifyErr g_eErrorDetails = e_VE_Ok;


/*
Expand All @@ -26,9 +28,6 @@ tdeVerifyErr g_eMissingFiles = e_VE_Ok;
char const *szDegePath = ".\\dgVoodoo.conf";
char const *szUbiPath = ".\\Ubi.ini";

char const *szUbiR2 = "Rayman2";
char const *szUbiFix = "Ray2Fix";

char const *szTrue = "true";
char const *szFalse = "false";

Expand Down Expand Up @@ -59,7 +58,7 @@ void fn_vReadUbiIni( void )
char szBuffer[128];

// GLI library
GetPrivateProfileString(szUbiR2, "GLI_Dll", NULL, szBuffer, sizeof(szBuffer), szUbiPath);
GetPrivateProfileString("Rayman2", "GLI_Dll", NULL, szBuffer, sizeof(szBuffer), szUbiPath);
if ( !strcmp(szBuffer, "Ray2Fix") )
{
g_bFixState = g_bFixPrevState = TRUE;
Expand All @@ -69,7 +68,7 @@ void fn_vReadUbiIni( void )
DWORD dwHeight = 0;

// Display mode
GetPrivateProfileString(szUbiR2, "GLI_Mode", NULL, szBuffer, sizeof(szBuffer), szUbiPath);
GetPrivateProfileString("Rayman2", "GLI_Mode", NULL, szBuffer, sizeof(szBuffer), szUbiPath);
int nParsed = sscanf_s(szBuffer, "1 - %d x %d", &dwWidth, &dwHeight);

if ( nParsed == 2 && dwWidth > 0 && dwHeight > 0 )
Expand All @@ -79,7 +78,7 @@ void fn_vReadUbiIni( void )
}

// Tweaks
g_eTweaks = GetPrivateProfileInt(szUbiFix, "Tweaks", 0, szUbiPath);
g_eTweaks = GetPrivateProfileInt("Ray2Fix", "Tweaks", 0, szUbiPath);
}

void fn_vReadDegeIni( void )
Expand Down Expand Up @@ -117,27 +116,27 @@ void fn_vWriteUbiIni( void )

// GLI library path & name
char *szDllFile = g_bFixState ? "GliFix" : "GliVd1";
WritePrivateProfileString(szUbiR2, "GLI_DllFile", szDllFile, szUbiPath);
WritePrivateProfileString("Rayman2", "GLI_DllFile", szDllFile, szUbiPath);

char *szDll = g_bFixState ? "Ray2Fix" : "Glide2";
WritePrivateProfileString(szUbiR2, "GLI_Dll", szDll, szUbiPath);
WritePrivateProfileString("Rayman2", "GLI_Dll", szDll, szUbiPath);

// Doesn't really matter but write "Default" anyway
char *szDevice = "Default";
WritePrivateProfileString(szUbiR2, "GLI_Driver", szDevice, szUbiPath);
WritePrivateProfileString(szUbiR2, "GLI_Device", szDevice, szUbiPath);
WritePrivateProfileString("Rayman2", "GLI_Driver", szDevice, szUbiPath);
WritePrivateProfileString("Rayman2", "GLI_Device", szDevice, szUbiPath);

// Display mode
sprintf_s(szBuffer, sizeof(szBuffer), "1 - %i x %i x 16", g_stCurrentMode.dwWidth, g_stCurrentMode.dwHeight);
WritePrivateProfileString(szUbiR2, "GLI_Mode", szBuffer, szUbiPath);
WritePrivateProfileString("Rayman2", "GLI_Mode", szBuffer, szUbiPath);

// Tweaks
sprintf_s(szBuffer, sizeof(szBuffer), "%i", g_eTweaks);
WritePrivateProfileString(szUbiFix, "Tweaks", szBuffer, szUbiPath);
WritePrivateProfileString("Ray2Fix", "Tweaks", szBuffer, szUbiPath);

// Refresh rate
sprintf_s(szBuffer, sizeof(szBuffer), "%i", (g_eRefRate == e_RR_Half));
WritePrivateProfileString(szUbiFix, "HalfRefRate", szBuffer, szUbiPath);
WritePrivateProfileString("Ray2Fix", "HalfRefRate", szBuffer, szUbiPath);
}

void fn_vWriteDegeIni( void )
Expand Down Expand Up @@ -185,12 +184,14 @@ void CFG_fn_vRead( void )
{
fn_vReadUbiIni();
fn_vReadDegeIni();
PAD_fn_vRead();
}

void CFG_fn_vWrite( void )
{
fn_vWriteUbiIni();
fn_vWriteDegeIni();
PAD_fn_vWrite();
}

void CFG_fn_vVerify( void )
Expand All @@ -202,17 +203,37 @@ void CFG_fn_vVerify( void )
}

if ( GetFileAttributes(szUbiPath) == INVALID_FILE_ATTRIBUTES )
g_eMissingFiles |= e_VE_UbiMissing;
{
g_eErrorDetails |= e_VE_FilesMissing | e_VE_UbiMissing;
}

if ( GetFileAttributes(szDegePath) == INVALID_FILE_ATTRIBUTES )
g_eMissingFiles |= e_VE_DegeMissing | e_VE_FixError;
{
g_eError |= e_ES_FixError;
g_eErrorDetails |= e_VE_FilesMissing | e_VE_DegeMissing;
}

if ( GetFileAttributes(".\\DLL\\GliVd1Vf.dll") == INVALID_FILE_ATTRIBUTES )
g_eMissingFiles |= e_VE_GlideMissing | e_VE_GameError;
{
g_eError |= e_ES_GameError;
g_eErrorDetails |= e_VE_FilesMissing | e_VE_GlideMissing;
}

if ( GetFileAttributes(".\\DLL\\GliFixVf.dll") == INVALID_FILE_ATTRIBUTES )
g_eMissingFiles |= e_VE_FixMissing | e_VE_FixError;
{
g_eError |= e_ES_FixError;
g_eErrorDetails |= e_VE_FilesMissing | e_VE_FixMissing;
}

if ( GetFileAttributes(".\\dinput.dll") == INVALID_FILE_ATTRIBUTES )
g_eMissingFiles |= e_VE_DinputMissing | e_VE_FixError;
{
g_eError |= e_ES_FixError;
g_eErrorDetails |= e_VE_FilesMissing | e_VE_DinputMissing;
}

if ( GetFileAttributes(g_szXidiPath) == INVALID_FILE_ATTRIBUTES )
{
g_eError |= e_ES_Warning;
g_eErrorDetails |= e_VE_FilesMissing | e_VE_XidiMissing;
}
}
29 changes: 20 additions & 9 deletions R2FixCfg/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@
#include "display.h"


typedef enum tdeErrorState_
{
e_ES_Ok = 0,
e_ES_Warning = 1 << 0,
e_ES_GameError = 1 << 1,
e_ES_FixError = 1 << 2,
}
tdeErrorState;

typedef enum tdeVerifyErr_
{
e_VE_Ok = 0,
e_VE_GameError = 1 << 0,
e_VE_FixError = 1 << 1,
e_VE_UbiMissing = 1 << 2,
e_VE_DegeMissing = 1 << 3,
e_VE_GlideMissing = 1 << 4,
e_VE_FixMissing = 1 << 5,
e_VE_DinputMissing = 1 << 6
e_VE_Ok = 0,
e_VE_FilesMissing = 1 << 0,
e_VE_UbiMissing = 1 << 1,
e_VE_DegeMissing = 1 << 2,
e_VE_GlideMissing = 1 << 3,
e_VE_FixMissing = 1 << 4,
e_VE_DinputMissing = 1 << 5,
e_VE_XidiMissing = 1 << 6,
e_VE_XidiModified = 1 << 7,
}
tdeVerifyErr;

Expand All @@ -33,7 +43,8 @@ extern tdeRefRate g_eRefRate;
extern BOOL g_bForceVsync;
extern BOOL g_bFullscreen;

extern tdeVerifyErr g_eMissingFiles;
extern tdeErrorState g_eError;
extern tdeVerifyErr g_eErrorDetails;


/*
Expand Down
5 changes: 5 additions & 0 deletions R2FixCfg/def_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@

M_DefineAction( E_BAc_Think, "Think (F1)", "Keyboard(F1)" )
M_DefineAction( E_BAc_HUD, "HUD (J)", "Button(6)" )
M_DefineAction( E_BAc_HUD_Accept, "HUD / Accept", "Compound(Button(6),Keyboard(Enter))" )
M_DefineAction( E_BAc_ScreenShot, "Screenshot", "Keyboard(F8)" )
M_DefineAction( E_BAc_Pause, "Pause", "Keyboard(Esc)" )

M_DefineAction( E_BAc_Accept, "Accept (Enter)", "Keyboard(Enter)" )
M_DefineAction( E_BAc_Cancel, "Cancel (Backspace)", "Keyboard(Backspace)" )


/********************************************************************************************************************/


Expand Down
Loading

0 comments on commit 7d8abde

Please sign in to comment.