Skip to content

Commit

Permalink
Minor changes and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shauleiz committed Feb 23, 2016
1 parent 31285f1 commit b0fbca0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
41 changes: 21 additions & 20 deletions SPP4/trunk/Spp/SppConsole/SppControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
// Display the version of vJoy driver
vJoyDevicesVersion(hDialog);

// TODO: Test functions - remove later
// Monitor vJoy Device
if (MonitorOk)
StartPollingDevice(vJoyDevice);

Expand Down Expand Up @@ -1280,7 +1280,7 @@ void SetMonitoring(HWND hDlg)

HINSTANCE FilterPopulate(HWND hDlg)
{
HINSTANCE h;
HINSTANCE h, hTmp;
//LPCTSTR * names;
//long filter_ver;
UINT (CALLBACK * GetDllVersion)(void);
Expand All @@ -1294,7 +1294,7 @@ HINSTANCE FilterPopulate(HWND hDlg)



// TODO: Release former library
hTmp = hDllFilters;

// Get filter file name from config file
wstring wsFileName(Conf->FilterFile());
Expand Down Expand Up @@ -1338,12 +1338,6 @@ HINSTANCE FilterPopulate(HWND hDlg)
return NULL;
};

//filter_ver = GetDllVersion();
//if (filter_ver < 0x30100) // TODO: Newer DLLs support wide characters
//{
// SendMessage(hDlg, FILTER_VER, false, filter_ver);
// return NULL;
//};

//// Build the list in the GUI
// Get the number of filters
Expand All @@ -1366,8 +1360,8 @@ HINSTANCE FilterPopulate(HWND hDlg)
UINT idSel = Conf->GetSelectedFilter();

// Get interface functions
pGetFilterNameByIndexA = (const char * (CALLBACK *)(const int iFilter))GetProcAddress(h,"GetFilterNameByIndex"); // TODO: Add support to WCHAR
pGetFilterNameByIndexW = (LPCWSTR (CALLBACK *)(const int iFilter))GetProcAddress(h,"GetFilterNameByIndexW"); // TODO: Add support to WCHAR
pGetFilterNameByIndexA = (const char * (CALLBACK *)(const int iFilter))GetProcAddress(h,"GetFilterNameByIndex");
pGetFilterNameByIndexW = (LPCWSTR (CALLBACK *)(const int iFilter))GetProcAddress(h,"GetFilterNameByIndexW");
pGetFilterIdByIndex = (const int (CALLBACK *)(const int iFilter))GetProcAddress(h,"GetFilterIdByIndex");
pSelectFilterByIndex = (const int (CALLBACK *)(const int iFilter))GetProcAddress(h,"SelectFilterByIndex");
pGetIndexOfSelectedFilter = (const int (CALLBACK *)(void))GetProcAddress(h,"GetIndexOfSelectedFilter");
Expand Down Expand Up @@ -1409,6 +1403,13 @@ HINSTANCE FilterPopulate(HWND hDlg)
}
};

// Release former library
if (hTmp)
{
FreeLibrary(hTmp);
hTmp = NULL;
}

LogMessage(INFO, IDS_I_FILTERDLLOK);
return h;
}
Expand Down Expand Up @@ -1467,8 +1468,8 @@ void SelectFilter(int FilterId)
pGetFilterIdByIndex = (const int (CALLBACK *)(const int iFilter))GetProcAddress(hDllFilters,"GetFilterIdByIndex");
pSelectFilterByIndex = (const int (WINAPI *)(const int iFilter))GetProcAddress(hDllFilters,"SelectFilterByIndex");
pProcessChannels = (PJS_CHANNELS (WINAPI * )(PJS_CHANNELS, int max, int min))GetProcAddress(hDllFilters,"ProcessChannels");
pGetFilterNameByIndexA = (const char * (CALLBACK *)(const int i))GetProcAddress(hDllFilters,"GetFilterNameByIndex"); // TODO: Add support to WCHAR
pGetFilterNameByIndexW = (LPCWSTR (CALLBACK *)(const int iFilter))GetProcAddress(hDllFilters,"GetFilterNameByIndexW"); // TODO: Add support to WCHAR
pGetFilterNameByIndexA = (const char * (CALLBACK *)(const int i))GetProcAddress(hDllFilters,"GetFilterNameByIndex");
pGetFilterNameByIndexW = (LPCWSTR (CALLBACK *)(const int iFilter))GetProcAddress(hDllFilters,"GetFilterNameByIndexW");


int nFilters;
Expand Down Expand Up @@ -1711,7 +1712,7 @@ void thMonitor(bool * KeepAlive)


// Compute the state of the Operation state machine and inform GUI
ComputeOperatState(); // TODO: Much tweeking
ComputeOperatState();

// Inform GUI of changes in the Start/Stop conditions
if (OperatStateMachine != oState)
Expand Down Expand Up @@ -2098,11 +2099,12 @@ bool isUnique(void)
else
{
config.pszVerificationText = CN_NO_UNIQUE_CB;
::TaskDialogIndirect(&config, &selectedButtonId, &selectedRadioButtonId, &verificationChecked);
HRESULT hr = ::TaskDialogIndirect(&config, &selectedButtonId, &selectedRadioButtonId, &verificationChecked);
::PostMessage(HWND_BROADCAST, WM_INTERSPPCONSOLE, 0, 0);

// Instuct the existing process to change "Don't show again" option in the configuration file
res = SendMessageTimeout(hOtherWin, WM_INTERSPPAPPSGETUNIQ, 1, verificationChecked, SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT, 100, NULL);
if (hr == S_OK)
res = SendMessageTimeout(hOtherWin, WM_INTERSPPAPPSGETUNIQ, 1, verificationChecked, SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT, 100, NULL);

}
return false;
Expand All @@ -2127,9 +2129,8 @@ bool isUnique(void)
return true;
}

// TODO: Remove pragma and solve problem
#pragma warning( push )
#pragma warning( disable : 4996 )
//#pragma warning( push )
//#pragma warning( disable : 4996 )
bool isAboveVistaSp1()
{

Expand Down Expand Up @@ -2161,7 +2162,7 @@ bool isAboveVistaSp1()
#endif // 0

}
#pragma warning( pop )
//#pragma warning( pop )

#ifdef _DEBUG
const DWORD MS_VC_EXCEPTION=0x406D1388;
Expand Down
19 changes: 10 additions & 9 deletions SPP4/trunk/Spp/SppProcess/SppProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@ SPPMAIN_API int CSppProcess::GetJoystickCommQuality(void)
SPPMAIN_API void CSppProcess::SetDecoderScanning(BOOL Start, BOOL Forever, int Timeout)
{
// It is assumed that PollChannels() is running
if (!m_chMonitor) // TODO: Warning message
if (!m_chMonitor)
{
LogMessage(WARN, IDS_W_NO_MONITOR);
return;
}

// Stop?
if (!Start && m_DecoderStruct.running)
Expand Down Expand Up @@ -404,7 +407,7 @@ inline void CSppProcess::GetEncoding(void)
// Stop if not to run forever
if (res == S_OK)
{
SendMessage(m_hParentWnd, WMSPP_PRCS_DCDR, (WPARAM)Decoder, 0);
SendMessageTimeout(m_hParentWnd, WMSPP_PRCS_DCDR, (WPARAM)Decoder, 0, SMTO_NORMAL, 100, NULL);
if (m_DecoderStruct.forever)
m_DecoderStruct.rstbuf = TRUE;
else
Expand Down Expand Up @@ -728,7 +731,6 @@ void CSppProcess::MonitorCapture(void)
LogMessage(ERR, IDS_E_STREAMFAIL);
else
{
// TODO: ReportChange();
m_tCapture = new thread(CaptureAudioStatic, this);
if (!m_tCapture)
LogMessage(ERR, IDS_E_STREAMTHRDFAIL);
Expand All @@ -749,7 +751,7 @@ void CSppProcess::CaptureAudio(void)
PBYTE buffer=NULL;
UINT bSize=0;
HRESULT hr = S_OK;
UINT bMax = 8000; // TODO: Change to dynamic size
UINT bMax = 8000;

buffer = new BYTE[bMax];

Expand Down Expand Up @@ -1007,8 +1009,7 @@ HRESULT CSppProcess::ProcessWave(BYTE * pWavePacket, UINT32 packetLength)
#endif

// If valid pulse the process the pulse
// TODO (?): Very short pulses are ignored (Glitch)
if (PulseLength/*>3*/)
if (PulseLength)
{
lock_guard<recursive_mutex> lock_Decode(m_mx_Decode);

Expand Down Expand Up @@ -2556,7 +2557,7 @@ _inline double CSppProcess::CalcThreshold(int value)
return(threthold);
}

// TODO: Normalize the calling functions to the range 0-32K

void CSppProcess::Send2vJoy(int nChannels, int * Channel)
{
BOOL writeOk;
Expand Down Expand Up @@ -2594,11 +2595,11 @@ void CSppProcess::Send2vJoy(int nChannels, int * Channel)
continue;
if ((iMapped>MAX_JS_CH)||(ch[iMapped-1]<0)) // Test value - if (-1) value is illegal
return;
writeOk = SetAxisDelayed(32*ch[iMapped-1], HID_USAGE_X+i); // TODO: the normalization to default values should be done in the calling functions
writeOk = SetAxisDelayed(32*ch[iMapped-1], HID_USAGE_X+i); // Normalization to default values
}

for (k=0; k<MAX_BUTTONS;k++)
writeOk = SetBtnDelayed(ch[m_BtnMapping[k]-1]>511,k+1); // TODO: Replace 511 with some constant definition
writeOk = SetBtnDelayed(ch[m_BtnMapping[k]-1]>BUTTON_TRIG_VAL,k+1);

// Feed structure to vJoy device rID
BOOL updated = UpdateVJD(rID, &m_vJoyPosition);
Expand Down
1 change: 1 addition & 0 deletions SPP4/trunk/Spp/SppProcess/SppProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ typedef struct _DECODER_DETECT
#define MAX_JS_CH 12
#define MUTEX_STOP_START _T("WaveIn Stopping and Starting are mutually exclusive")
#define MAX_BUF_SIZE 1000
#define BUTTON_TRIG_VAL 511



Expand Down
1 change: 1 addition & 0 deletions SPP4/trunk/Spp/SppUI/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
#define IDS_I_CONF_CREATED 40212
#define IDS_E_CONF_NOFOLDER 40213
#define IDS_I_CONF_CREATEFOLDER 40214
#define IDS_W_NO_MONITOR 40215

// Next default values for new objects
//
Expand Down
6 changes: 3 additions & 3 deletions SPP4/trunk/Spp/SppUI/SppDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ bool SppDlg::MsgLoop(void)
return false;
}

else if (!IsWindow(m_hDlg))
return true;
//else if (!IsWindow(m_hDlg))
// return true;

else if (!IsDialogMessage(m_hDlg, &msg))
{
Expand Down Expand Up @@ -1912,7 +1912,7 @@ INT_PTR CALLBACK MsgHndlDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPara
case WM_DESTROY:
DestroyWindow(hDlg);
hDlg = NULL;
// PostQuitMessage(0);
PostQuitMessage(0);
return (INT_PTR)TRUE;

case WM_NOTIFY:
Expand Down
1 change: 1 addition & 0 deletions SPP4/trunk/Spp/SppUI/SppUI.rc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ BEGIN
40093 "Audio Input"
40094 "SmartPropoPlus is currently paused - Press to activate"
40095 "SmartPropoPlus is currently active - Press to deactivate"
40215 "Cannot scan input - Channel polling thread is inactive"
END

STRINGTABLE
Expand Down

0 comments on commit b0fbca0

Please sign in to comment.