ReactOS 0.4.16-dev-122-g325d74c
main.cpp File Reference
#include "main.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

void PrintLastError (LPCSTR function)
 
BOOL generateTestSignal (double amplitude, int Channels, int SamplesPerSec, SHORT **buffer)
 
BOOL stopTestTone (void)
 
UINT findWaveDeviceID ()
 
BOOL playTestTone ()
 
BOOL CALLBACK DSEnumProc (LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
 
BOOL getCurrentChannelConfig ()
 
BOOL setCurrentChannelConfig ()
 
BOOL getDeviceInfo (const GUID *category, CMIDEV *pDev)
 
BOOL getDeviceInterfaceDetail (const GUID *category, CMIDEV *pDev)
 
BOOL getDriverData (CMIDEV *pDev)
 
BOOL setDriverData (CMIDEV *pDev)
 
void cleanUp ()
 
BOOL openDevice (bool handleError)
 
void updateChannelBoxes (HWND hWnd)
 
BOOL setDlgItems (HWND hWnd)
 
BOOL applySettings ()
 
BOOL initDialog (HWND hWnd)
 
BOOL changeTab (LPNMHDR lpnmhdr)
 
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void openURL (int control)
 
INT_PTR CALLBACK TabDlgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void printUsage ()
 
void deleteDriverFiles ()
 
void performUninstall ()
 
bool checkToken (char *token)
 
int parseArguments (LPSTR szCmdLine)
 
void InitURLControl ()
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
 

Function Documentation

◆ applySettings()

BOOL applySettings ( )

Definition at line 628 of file main.cpp.

629{
636
645
659
661
663}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
BOOL setDriverData(CMIDEV *pDev)
Definition: main.cpp:443
BOOL setCurrentChannelConfig()
Definition: main.cpp:278
CMIDATA cmiData
Definition: main.h:77
int currentChannelCount
Definition: main.h:80
CMIDEV cmiTopologyDev
Definition: main.h:76
HWND hWndChild[NUM_TABS]
Definition: main.h:74
#define IDC_LOOP_SPDF
Definition: resource.h:66
#define IDCB_CHANNELCONFIG
Definition: resource.h:47
#define IDC_EN_SPDI
Definition: resource.h:67
#define IDC_FMT_960_PCM
Definition: resource.h:74
#define IDC_FMT_480_MULTI_PCM
Definition: resource.h:76
#define IDC_FMT_441_DOLBY
Definition: resource.h:79
#define IDC_FMT_882_PCM
Definition: resource.h:73
#define IDC_EN_SPDCOPYRHT
Definition: resource.h:61
#define IDC_EN_CLFE2LINE
Definition: resource.h:43
#define IDC_INV_SPDIFI
Definition: resource.h:64
#define IDC_EN_SPDO
Definition: resource.h:59
#define IDC_EXCH_FB
Definition: resource.h:41
#define IDC_FMT_960_DOLBY
Definition: resource.h:82
#define IDC_EN_REAR2LINE
Definition: resource.h:42
#define IDC_EN_CENTER2MIC
Definition: resource.h:45
#define IDC_SEL_SPDIFI
Definition: resource.h:63
#define IDC_FMT_882_DOLBY
Definition: resource.h:81
#define IDC_EN_SPDO5V
Definition: resource.h:60
#define IDC_EN_SPDIMONITOR
Definition: resource.h:68
#define IDC_FMT_480_DOLBY
Definition: resource.h:80
#define IDC_FMT_480_PCM
Definition: resource.h:72
#define IDC_FMT_960_MULTI_PCM
Definition: resource.h:78
#define IDC_FMT_441_PCM
Definition: resource.h:71
#define IDC_POLVALID
Definition: resource.h:65
#define IDC_FMT_882_MULTI_PCM
Definition: resource.h:77
#define IDC_FMT_441_MULTI_PCM
Definition: resource.h:75
#define FMT_960_MULTI_PCM
Definition: property.h:49
#define FMT_480_PCM
Definition: property.h:43
#define FMT_441_MULTI_PCM
Definition: property.h:46
#define FMT_882_DOLBY
Definition: property.h:52
#define FMT_480_DOLBY
Definition: property.h:51
#define FMT_441_PCM
Definition: property.h:42
#define FMT_960_DOLBY
Definition: property.h:53
#define FMT_480_MULTI_PCM
Definition: property.h:47
#define FMT_882_PCM
Definition: property.h:44
#define FMT_441_DOLBY
Definition: property.h:50
#define FMT_960_PCM
Definition: property.h:45
#define FMT_882_MULTI_PCM
Definition: property.h:48
UInt32 enableBass2Line
Definition: property.h:71
UInt32 loopSPDI
Definition: property.h:81
UInt32 enableSPDO5V
Definition: property.h:76
UInt32 enableCenter2Line
Definition: property.h:72
UInt32 enableSPDIMonitor
Definition: property.h:69
UInt32 enableRear2Line
Definition: property.h:73
UInt32 enableCenter2Mic
Definition: property.h:74
UInt32 select2ndSPDI
Definition: property.h:78
UInt32 invertPhaseSPDI
Definition: property.h:79
UInt32 formatMask
Definition: property.h:82
UInt32 enableSPDI
Definition: property.h:83
UInt32 enableSPDOCopyright
Definition: property.h:77
UInt32 exchangeFrontBack
Definition: property.h:70
UInt32 invertValidBitSPDI
Definition: property.h:80
UInt32 enableSPDO
Definition: property.h:75
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SendMessage
Definition: winuser.h:5855
#define CB_GETCURSEL
Definition: winuser.h:1946
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1921

Referenced by WndProc().

◆ changeTab()

BOOL changeTab ( LPNMHDR  lpnmhdr)

Definition at line 701 of file main.cpp.

702{
703 if (lpnmhdr->code != TCN_SELCHANGE) {
704 return FALSE;
705 }
709 return TRUE;
710}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LRESULT currentTab
Definition: main.h:75
HWND hWndTab
Definition: main.h:73
#define TCM_GETCURSEL
Definition: commctrl.h:4067
#define TCN_SELCHANGE
Definition: commctrl.h:4137
UINT code
Definition: winuser.h:3162
#define SW_HIDE
Definition: winuser.h:771
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SHOWDEFAULT
Definition: winuser.h:783

Referenced by WndProc().

◆ checkToken()

bool checkToken ( char token)

Definition at line 828 of file main.cpp.

828 {
829 if ((strcmp(token, "?")==0) || (strcmp(token, "H")==0)) {
830 printUsage();
831 return TRUE;
832 } else
833 if (strcmp(token, "ENABLE71MODE")==0) {
835 } else
836 if (strcmp(token, "ENABLE51MODE")==0) {
838 } else
839 if ((strcmp(token, "ENABLE40MODE")==0) || (strcmp(token, "ENABLEQUADMODE")==0) || (strcmp(token, "QUAD")==0) ) {
841 } else
842 if ((strcmp(token, "ENABLE20MODE")==0) || (strcmp(token, "ENABLESTEREOMODE")==0) || (strcmp(token, "STEREO")==0) ) {
844 } else
845 if (strcmp(token, "ENABLESPDIFO")==0) {
847 } else
848 if (strcmp(token, "DISABLESPDIFO")==0) {
850 } else
851 if (strcmp(token, "ENABLESPDIFI")==0) {
853 } else
854 if (strcmp(token, "DISABLESPDIFI")==0) {
856 } else
857 if ((strcmp(token, "ENABLELOOPTHRU")==0) || (strcmp(token, "ENABLELOOPTHROUGH")==0) || (strcmp(token, "ENABLELOOP")==0) ) {
859 } else
860 if ((strcmp(token, "DISABLELOOPTHRU")==0) || (strcmp(token, "DISABLELOOPTHROUGH")==0) || (strcmp(token, "DISABLELOOP")==0) ) {
862 } else
863 if (strcmp(token, "UNINSTALL")==0) {
865 }
866 return FALSE;
867}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void performUninstall()
Definition: main.cpp:821
void printUsage()
Definition: main.cpp:782
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210

Referenced by parseArguments().

◆ cleanUp()

void cleanUp ( )

Definition at line 469 of file main.cpp.

470{
471 stopTestTone();
472 if (cmiTopologyDev.Info) {
475 }
479 }
480 if (hURLFont) {
481 DeleteObject(hURLFont); //hm?
482 hURLFont = NULL;
483 }
484}
#define NULL
Definition: types.h:112
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
BOOL stopTestTone(void)
Definition: main.cpp:103
HFONT hURLFont
Definition: main.h:81
pKey DeleteObject()
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
PSP_DEVICE_INTERFACE_DETAIL_DATA InterfaceDetailData
Definition: main.h:66
HDEVINFO Info
Definition: main.h:64

Referenced by AddRightEdges(), GetImageName(), load_mapi_providers(), MCIAVI_OpenAudio(), WAVE_mciPlay(), WAVE_mciRecord(), WinMain(), and WndProc().

◆ deleteDriverFiles()

void deleteDriverFiles ( )

Definition at line 800 of file main.cpp.

800 {
801 TCHAR SysDir[MAX_PATH];
802 size_t len;
803 if (GetSystemDirectory(SysDir, sizeof(SysDir))==0) {
804 PrintLastError("GetSystemDirectory()");
805 return;
806 }
807 len = strlen(SysDir);
808
809 strcat(SysDir, "\\cmicpl.cpl");
810 if (!DeleteFile(SysDir)) {
812 }
813 SysDir[len] = 0;
814
815 strcat(SysDir, "\\cmicontrol.exe");
816 if (!DeleteFile(SysDir)) {
818 }
819}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MAX_PATH
Definition: compat.h:34
void PrintLastError(LPCSTR function)
Definition: main.cpp:31
GLenum GLsizei len
Definition: glext.h:6722
#define GetSystemDirectory
Definition: winbase.h:3842
#define DeleteFile
Definition: winbase.h:3764
#define MoveFileEx
Definition: winbase.h:3878
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:400
char TCHAR
Definition: xmlstorage.h:189

Referenced by performUninstall().

◆ DSEnumProc()

BOOL CALLBACK DSEnumProc ( LPGUID  lpGUID,
LPCTSTR  lpszDesc,
LPCTSTR  lpszDrvName,
LPVOID  lpContext 
)

Definition at line 213 of file main.cpp.

214{
215 LPGUID* pGUID = (LPGUID*)lpContext;
216
217 if (pGUID == NULL) {
218 return FALSE;
219 }
220 if ((*pGUID) != NULL) {
221 return TRUE;
222 }
223
224 if (lpGUID != NULL) {
225 // XP, 2k
228 (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
229 memcpy((*pGUID), lpGUID, sizeof(GUID));
230 return TRUE;
231 }
232 // Vista
233 if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("Speakers (CMI8738/8768 Audio Device)"), -1) == CSTR_EQUAL) {
234 (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
235 memcpy((*pGUID), lpGUID, sizeof(GUID));
236 return TRUE;
237 }
238 }
239 return TRUE;
240}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define TEXT(s)
Definition: k32.h:26
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
GUID * LPGUID
Definition: guiddef.h:81
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
#define LPTR
Definition: winbase.h:381
#define NORM_IGNORECASE
Definition: winnls.h:176
#define CSTR_EQUAL
Definition: winnls.h:456
#define CompareString
Definition: winnls.h:1174

Referenced by getCurrentChannelConfig(), and setCurrentChannelConfig().

◆ findWaveDeviceID()

UINT findWaveDeviceID ( )

Definition at line 122 of file main.cpp.

123{
124 WAVEOUTCAPS woc;
125 UINT i, numDev;
126
127 numDev = waveOutGetNumDevs();
128 for (i=0;i<numDev;i++) {
129 if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))) {
131 (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("Speakers (CMI8738/8768 Audio De"), -1) == CSTR_EQUAL)) {
132 return i;
133 }
134 }
135 }
136 return WAVE_MAPPER;
137}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WAVE_MAPPER
Definition: mmsystem.h:187
#define waveOutGetDevCaps
Definition: mmsystem.h:2843
unsigned int UINT
Definition: ndis.h:50
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1028
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2137

Referenced by playTestTone().

◆ generateTestSignal()

BOOL generateTestSignal ( double  amplitude,
int  Channels,
int  SamplesPerSec,
SHORT **  buffer 
)

Definition at line 41 of file main.cpp.

42{
43 int i, o2, o3, o4, o5;
44 bool Left,Right,BackLeft,BackRight,Center,Sub, CenterLeft, CenterRight;
45 short value;
46 double x = SPEAKER_FREQUENCY*2*3.141592654/SamplesPerSec;
47 double y = BASS_FREQUENCY*2*3.141592654/SamplesPerSec;
48
57
58 if (!(Left || Right || BackLeft || BackRight || Center || Sub || CenterLeft || CenterRight)) {
59 return FALSE;
60 }
61
62 if (currentChannelCount > 4) {
63 o2 = 4; o3 = 5;
64 o4 = 2; o5 = 3;
65 } else {
66 o2 = 2; o3 = 3;
67 o4 = 4; o5 = 5;
68 }
69
70 (*buffer) = (SHORT*)LocalAlloc(LPTR, SamplesPerSec*sizeof(SHORT)*Channels);
71 ZeroMemory((*buffer), SamplesPerSec*sizeof(SHORT)*Channels);
72
73 for (i=0;i<SamplesPerSec;i++) {
74 value = (SHORT)(cos(i*x)*amplitude*32767.0);
75 if (Left) {
76 (*buffer)[(i*Channels)+0] = value;
77 }
78 if (Right) {
79 (*buffer)[(i*Channels)+1] = value;
80 }
81 if (BackLeft) {
82 (*buffer)[(i*Channels)+o2] = value;
83 }
84 if (BackRight) {
85 (*buffer)[(i*Channels)+o3] = value;
86 }
87 if (Center) {
88 (*buffer)[(i*Channels)+o4] = value;
89 }
90 if (Sub) {
91 (*buffer)[(i*Channels)+o5] = (SHORT)(cos(i*y)*amplitude*32767.0);
92 }
93 if (CenterLeft) {
94 (*buffer)[(i*Channels)+6] = value;
95 }
96 if (CenterRight) {
97 (*buffer)[(i*Channels)+7] = value;
98 }
99 }
100 return TRUE;
101}
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define BASS_FREQUENCY
Definition: main.h:55
#define SPEAKER_FREQUENCY
Definition: main.h:58
#define IDC_CENTER
Definition: resource.h:50
#define IDC_SUB
Definition: resource.h:55
#define IDC_BRIGHT
Definition: resource.h:54
#define IDC_BLEFT
Definition: resource.h:53
#define IDC_CLEFT
Definition: resource.h:49
#define IDC_RIGHT
Definition: resource.h:52
#define IDC_CRIGHT
Definition: resource.h:51
#define IDC_LEFT
Definition: resource.h:48
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint buffer
Definition: glext.h:5915
short SHORT
Definition: pedump.c:59
Definition: pdh_main.c:94
#define ZeroMemory
Definition: winbase.h:1712

Referenced by playTestTone().

◆ getCurrentChannelConfig()

BOOL getCurrentChannelConfig ( )

Definition at line 242 of file main.cpp.

243{
244 IDirectSound8* ds;
245 DWORD speakerConfig;
246 LPGUID guid = NULL;
247
248 DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&guid);
249
250 if (DirectSoundCreate8(guid, &ds, NULL) != S_OK) {
251 return FALSE;
252 }
253
254 ds->Initialize(NULL);
255
256 if (ds->GetSpeakerConfig(&speakerConfig) != S_OK) {
257 PrintLastError("GetSpeakerConfig()");
258 return FALSE;
259 }
260
261 if (ds) {
262 ds->Release();
263 }
264 if (guid) {
266 }
267
268 switch (DSSPEAKER_CONFIG(speakerConfig)) {
269 case DSSPEAKER_STEREO: currentChannelCount = 2; return TRUE;
270 case DSSPEAKER_QUAD: currentChannelCount = 4; return TRUE;
273 }
274
275 return FALSE;
276}
HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter)
Definition: directsound.c:504
BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
Definition: main.cpp:213
#define DSSPEAKER_STEREO
Definition: dsound.h:308
#define DSSPEAKER_CONFIG(a)
Definition: dsound.h:323
#define DSSPEAKER_7POINT1
Definition: dsound.h:312
#define DSSPEAKER_QUAD
Definition: dsound.h:307
#define DirectSoundEnumerate
Definition: dsound.h:411
#define DSSPEAKER_5POINT1
Definition: dsound.h:310
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ds
Definition: i386-dis.c:443
#define S_OK
Definition: intsafe.h:52
const GUID * guid

Referenced by setDlgItems().

◆ getDeviceInfo()

BOOL getDeviceInfo ( const GUID category,
CMIDEV pDev 
)

Definition at line 317 of file main.cpp.

318{
319 TCHAR szServiceName[128];
320 int nIndex = 0;
321
323 if (pDev->Info == INVALID_HANDLE_VALUE) {
324 PrintLastError("SetupDiGetClassDevs()");
325 return FALSE;
326 }
327
328 pDev->InfoData.cbSize = sizeof(SP_DEVINFO_DATA);
329
330 while (SetupDiEnumDeviceInfo(pDev->Info, nIndex, &(pDev->InfoData))) {
331 if (!SetupDiGetDeviceRegistryProperty(pDev->Info, &(pDev->InfoData), SPDRP_SERVICE, NULL, (PBYTE)szServiceName, sizeof(szServiceName), NULL)) {
332 PrintLastError("SetupDiGetDeviceRegistryProperty()");
334 pDev->Info = NULL;
335 return FALSE;
336 }
337
339 return TRUE;
340 }
341 nIndex++;
342 }
343
345 pDev->Info = NULL;
346 return FALSE;
347}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
BYTE * PBYTE
Definition: pedump.c:66
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2603
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define SetupDiGetClassDevs
Definition: setupapi.h:2593
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define SPDRP_SERVICE
Definition: setupapi.h:511
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
SP_DEVINFO_DATA InfoData
Definition: main.h:65

Referenced by openDevice().

◆ getDeviceInterfaceDetail()

BOOL getDeviceInterfaceDetail ( const GUID category,
CMIDEV pDev 
)

Definition at line 349 of file main.cpp.

350{
351 DWORD dataSize = 0;
352 BOOL result;
353 PTSTR pnpStr = NULL;
354 HDEVINFO hDevInfoWithInterface;
355 SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
356
357 // get the PnP string
360 PrintLastError("SetupDiGetDeviceInstanceId()");
361 return FALSE;
362 }
363 pnpStr = (PTSTR)LocalAlloc(LPTR, dataSize * sizeof(TCHAR));
364 if (!pnpStr) {
365 PrintLastError("LocalAlloc()");
366 return FALSE;
367 }
368 result = SetupDiGetDeviceInstanceId(pDev->Info, &(pDev->InfoData), pnpStr, dataSize, NULL);
369 if (!result) {
370 PrintLastError("SetupDiGetDeviceInstanceId()");
371 LocalFree(pnpStr);
372 return FALSE;
373 }
374 hDevInfoWithInterface = SetupDiGetClassDevs(&KSCATEGORY_TOPOLOGY, pnpStr, NULL, DIGCF_DEVICEINTERFACE);
375 LocalFree(pnpStr);
376 if (hDevInfoWithInterface == INVALID_HANDLE_VALUE) {
377 PrintLastError("SetupDiGetClassDevs()");
378 return FALSE;
379 }
380
381 // get the device interface data
382 DeviceInterfaceData.cbSize = sizeof(DeviceInterfaceData);
383 result = SetupDiEnumDeviceInterfaces(hDevInfoWithInterface, NULL, &KSCATEGORY_TOPOLOGY, 0, &DeviceInterfaceData);
384 if (!result) {
385 PrintLastError("SetupDiEnumDeviceInterfaces()");
386 SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
387 return FALSE;
388 }
389
390 // get the device interface detail data
391 dataSize = 0;
392 SetupDiGetDeviceInterfaceDetail(hDevInfoWithInterface, &DeviceInterfaceData, NULL, 0, &dataSize, NULL);
394 PrintLastError("SetupDiGetDeviceInterfaceDetail()");
395 SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
396 return FALSE;
397 }
399 if (!pDev->InterfaceDetailData) {
400 PrintLastError("LocalAlloc()");
401 SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
402 return FALSE;
403 }
405 result = SetupDiGetDeviceInterfaceDetail(hDevInfoWithInterface, &DeviceInterfaceData, pDev->InterfaceDetailData, dataSize, NULL, NULL);
406 SetupDiDestroyDeviceInfoList(hDevInfoWithInterface);
407 if (!result) {
408 PrintLastError("SetupDiGetDeviceInterfaceDetail()");
411 return FALSE;
412 }
413
414 return TRUE;
415}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2780
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLsizei dataSize
Definition: glext.h:11123
GLuint64EXT * result
Definition: glext.h:11304
#define KSCATEGORY_TOPOLOGY
Definition: ksmedia.h:199
SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_DEVICE_INTERFACE_DETAIL_DATA
Definition: setupapi.h:1149
#define SetupDiGetDeviceInterfaceDetail
Definition: setupapi.h:2601
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2600
SP_DEVICE_INTERFACE_DETAIL_DATA_A * PSP_DEVICE_INTERFACE_DETAIL_DATA
Definition: setupapi.h:1150
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
CHAR * PTSTR
Definition: xmlstorage.h:191

Referenced by openDevice().

◆ getDriverData()

BOOL getDriverData ( CMIDEV pDev)

Definition at line 417 of file main.cpp.

418{
419 BOOL result;
420 HANDLE hDevice;
421 KSPROPERTY KSProp;
423
425 if (hDevice == INVALID_HANDLE_VALUE) {
426 PrintLastError("CreateFile()");
427 return FALSE;
428 }
429 KSProp.Set = KSPROPSETID_CMI;
430 KSProp.Flags = KSPROPERTY_TYPE_GET;
431 KSProp.Id = KSPROPERTY_CMI_GET;
432 result = DeviceIoControl(hDevice, IOCTL_KS_PROPERTY, &KSProp, sizeof(KSProp), &cmiData, sizeof(cmiData), &dataSize, NULL);
433 CloseHandle(hDevice);
434
435 if (!result) {
436 PrintLastError("DeviceIoControl()");
437 return FALSE;
438 }
439
440 return TRUE;
441}
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KSPROPSETID_CMI
Definition: property.h:36
#define KSPROPERTY_CMI_GET
Definition: property.h:39
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
GUID Set
Definition: dmksctrl.h:76
CHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:851
#define CreateFile
Definition: winbase.h:3749

Referenced by parseArguments(), and setDlgItems().

◆ initDialog()

BOOL initDialog ( HWND  hWnd)

Definition at line 665 of file main.cpp.

666{
667 HICON hIcon;
668 TC_ITEM tci;
669 int i;
670
672 SendMessage(hWnd, WM_SETICON, (LPARAM) ICON_BIG, (WPARAM) hIcon);
673 hURLFont = 0;
674
676
677 ZeroMemory(&tci, sizeof(TC_ITEM));
678 tci.mask = TCIF_TEXT;
679 for (i=0;i<NUM_TABS;i++) {
680 tci.pszText = tabsName[i];
681 if (TabCtrl_InsertItem(hWndTab, i, &tci) == -1) {
682 PrintLastError("TabCtrl_InsertItem()");
683 return FALSE;
684 }
686 }
687
688 hURLFont = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "MS Shell Dlg");
690
691 currentTab = 0;
693
694 if (!openDevice(TRUE)) {
695 PrintLastError("openDevice()");
696 return FALSE;
697 }
698 return setDlgItems(hWnd);
699}
HWND hWnd
Definition: settings.c:17
#define IDC_TAB
Definition: resource.h:12
#define IDI_APP_ICON
Definition: resource.h:4
BOOL openDevice(bool handleError)
Definition: main.cpp:486
INT_PTR CALLBACK TabDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.cpp:751
BOOL setDlgItems(HWND hWnd)
Definition: main.cpp:545
#define IDC_URL2
Definition: resource.h:91
char * tabsName[]
Definition: resource.h:93
#define NUM_TABS
Definition: resource.h:95
int tabsResource[]
Definition: resource.h:94
HINSTANCE hInst
Definition: dxdiag.c:13
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4056
#define TC_ITEM
Definition: commctrl.h:4012
#define TCIF_TEXT
Definition: commctrl.h:3976
#define ICON_BIG
Definition: tnclass.cpp:51
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define VARIABLE_PITCH
Definition: wingdi.h:445
#define CreateFont
Definition: wingdi.h:4443
#define FF_SWISS
Definition: wingdi.h:452
#define CreateDialogParam
Definition: winuser.h:5764
#define WM_SETFONT
Definition: winuser.h:1653
#define LoadIcon
Definition: winuser.h:5825
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by WndProc().

◆ InitURLControl()

void InitURLControl ( )

Definition at line 911 of file main.cpp.

912{
913 WNDCLASSEX wce;
914
915 ZeroMemory(&wce, sizeof(wce));
916 wce.cbSize = sizeof(WNDCLASSEX);
917 if (GetClassInfoEx(hInst, "Static", &wce)==0) {
918 PrintLastError("GetClassInfoEx()");
919 return;
920 }
921
923 wce.hInstance = hInst;
924 wce.lpszClassName = "URLLink";
925 if (RegisterClassEx(&wce) == 0) {
926 PrintLastError("RegisterClassEx()");
927 }
928}
HINSTANCE hInstance
Definition: winuser.h:3209
HCURSOR hCursor
Definition: winuser.h:3211
UINT cbSize
Definition: winuser.h:3204
LPCSTR lpszClassName
Definition: winuser.h:3214
#define RegisterClassEx
Definition: winuser.h:5849
#define GetClassInfoEx
Definition: winuser.h:5792
#define LoadCursor
Definition: winuser.h:5824
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5731
#define IDC_HAND
Definition: winuser.h:698

Referenced by WinMain().

◆ openDevice()

BOOL openDevice ( bool  handleError)

Definition at line 486 of file main.cpp.

487{
489 if (handleError)
490 PrintLastError("getDeviceInfo()");
491 return FALSE;
492 }
493
495 if (handleError)
496 PrintLastError("getDeviceInterfaceDetail()");
497 return FALSE;
498 }
499
500 return TRUE;
501}
BOOL getDeviceInfo(const GUID *category, CMIDEV *pDev)
Definition: main.cpp:317
BOOL getDeviceInterfaceDetail(const GUID *category, CMIDEV *pDev)
Definition: main.cpp:349

Referenced by initDialog(), and parseArguments().

◆ openURL()

void openURL ( int  control)

Definition at line 744 of file main.cpp.

745{
746 char buffer[127];
749}
#define ShellExecute
Definition: shellapi.h:693
Definition: dialog.c:52
HWND hWndMain
Definition: welcome.c:60
#define SW_SHOWNORMAL
Definition: winuser.h:773
#define GetWindowText
Definition: winuser.h:5810

Referenced by TabDlgProc().

◆ parseArguments()

int parseArguments ( LPSTR  szCmdLine)

Definition at line 869 of file main.cpp.

869 {
870 BOOL inToken = false, result;
871 int i = 0, j=0;
872 char token[MAX_TOKEN_SIZE];
873
874 if (openDevice(FALSE)) {
877 }
878
879 while (szCmdLine[i]) {
880 if (inToken) {
881 if (szCmdLine[i] == ' ') {
882 inToken = false;
883 token[j] = 0;
884 if (checkToken(token)) {
885 return TRUE;
886 }
887 } else {
888 token[j] = (char)toupper(szCmdLine[i]);
889 if (j < MAX_TOKEN_SIZE-1) {
890 j++;
891 }
892 }
893 } else {
894 if ((szCmdLine[i] == '-') || (szCmdLine[i] == '/')) {
895 j = 0;
896 inToken = true;
897 }
898 }
899
900 i++;
901 }
902 token[j] = 0;
904
906 if (currentChannelCount != -1)
908 return result;
909}
int toupper(int c)
Definition: utclib.c:881
unsigned char
Definition: typeof.h:29
bool checkToken(char *token)
Definition: main.cpp:828
BOOL getDriverData(CMIDEV *pDev)
Definition: main.cpp:417
#define MAX_TOKEN_SIZE
Definition: main.h:61
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by WinMain().

◆ performUninstall()

void performUninstall ( )

Definition at line 821 of file main.cpp.

821 {
823 RegDeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\CMIDriver");
824 MessageBox(NULL, "The CMI driver applications have been successfully removed from your computer!", "CMIDriver", MB_ICONINFORMATION);
825 ExitProcess(0);
826}
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
void deleteDriverFiles()
Definition: main.cpp:800
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegDeleteKey
Definition: winreg.h:502
#define MessageBox
Definition: winuser.h:5834
#define MB_ICONINFORMATION
Definition: winuser.h:805

Referenced by checkToken().

◆ playTestTone()

BOOL playTestTone ( )

Definition at line 139 of file main.cpp.

140{
141 SHORT* buffer;
142 BOOL isChannelChecked;
143#if 1
145
146 ZeroMemory(&wfx, sizeof(WAVEFORMATEXTENSIBLE));
150 wfx.Format.wBitsPerSample = 16;
153 wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
156#else
157 WAVEFORMATEX wfx;
159 wfx.wBitsPerSample = 16;
162 wfx.nAvgBytesPerSec = SAMPLE_RATE * (wfx.wBitsPerSample >> 3) * wfx.nChannels;
163 wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels;
164 wfx.cbSize = 0;
165#endif
166
167 isChannelChecked = (SendMessage(GetDlgItem(hWndChild[0], IDC_LEFT), BM_GETCHECK, 0, 0) == BST_CHECKED);
168 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_RIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED);
169 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_BLEFT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 2);
170 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_BRIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 2);
171 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CENTER), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 4);
172 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_SUB), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 4);
173 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CLEFT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 6);
174 isChannelChecked |= (SendMessage(GetDlgItem(hWndChild[0], IDC_CRIGHT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (currentChannelCount > 6);
175
176 if (!isChannelChecked)
177 return FALSE;
178
180 PrintLastError("waveOutOpen()");
181 return FALSE;
182 }
183
185 return FALSE;
186 }
187
188 ZeroMemory(&pwh, sizeof(pwh));
192 pwh.dwLoops = 0xFFFFFFFF;
195 PrintLastError("waveOutPrepareHeader()");
196 return FALSE;
197 }
198
201 PrintLastError("waveOutReset()");
202 return FALSE;
203 }
204 if (waveOutWrite(hWave, &pwh, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {
206 PrintLastError("waveOutWrite()");
207 return FALSE;
208 }
209
210 return TRUE;
211}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
BOOL generateTestSignal(double amplitude, int Channels, int SamplesPerSec, SHORT **buffer)
Definition: main.cpp:41
UINT findWaveDeviceID()
Definition: main.cpp:122
#define SPEAKER_AMPLITUDE
Definition: main.h:59
#define SAMPLE_RATE
Definition: main.h:53
HWAVEOUT hWave
Definition: main.h:78
WAVEHDR pwh
Definition: main.h:79
unsigned short WORD
Definition: ntddk_ex.h:93
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:651
#define WHDR_ENDLOOP
Definition: mmsystem.h:196
#define WHDR_BEGINLOOP
Definition: mmsystem.h:195
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define CALLBACK_NULL
Definition: mmsystem.h:147
WAVEFORMATEX Format
Definition: ksmedia.h:638
WORD wValidBitsPerSample
Definition: ksmedia.h:641
union WAVEFORMATEXTENSIBLE::@3019 Samples
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42
DWORD dwBufferLength
Definition: mmsystem.h:1015
DWORD dwLoops
Definition: mmsystem.h:1019
DWORD dwFlags
Definition: mmsystem.h:1018
LPSTR lpData
Definition: mmsystem.h:1014
UINT WINAPI waveOutReset(HWAVEOUT hWaveOut)
Definition: winmm.c:2385
UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, LPWAVEHDR lpWaveOutHdr, UINT uSize)
Definition: winmm.c:2341
MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID, LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
Definition: winmm.c:2246
UINT WINAPI waveOutPrepareHeader(HWAVEOUT hWaveOut, WAVEHDR *lpWaveOutHdr, UINT uSize)
Definition: winmm.c:2277
char * LPSTR
Definition: xmlstorage.h:182

Referenced by TabDlgProc().

◆ PrintLastError()

void PrintLastError ( LPCSTR  function)

Definition at line 31 of file main.cpp.

32{
33 LPVOID lpMsgBuf;
34 DWORD errorid = GetLastError();
35
37 MessageBox(NULL, (LPCSTR)lpMsgBuf, function, MB_ICONEXCLAMATION | MB_OK);
38 LocalFree(lpMsgBuf);
39}
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define FormatMessage
Definition: winbase.h:3795
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
#define MB_ICONEXCLAMATION
Definition: winuser.h:788
#define MB_OK
Definition: winuser.h:793
const char * LPCSTR
Definition: xmlstorage.h:183
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by deleteDriverFiles(), getCurrentChannelConfig(), getDeviceInfo(), getDeviceInterfaceDetail(), getDriverData(), initDialog(), InitURLControl(), openDevice(), playTestTone(), setCurrentChannelConfig(), setDlgItems(), setDriverData(), stopTestTone(), and WinMain().

◆ printUsage()

void printUsage ( )

Definition at line 782 of file main.cpp.

783{
784 unsigned char usage[] = "/h - print this help message\r\n" \
785 "/enable71Mode - change channel configuration to 7.1\r\n" \
786 "/enable51Mode - change channel configuration to 5.1\r\n" \
787 "/enable40Mode - change channel configuration to 4.0 (Quad)\r\n" \
788 "/enable20Mode - change channel configuration to 2.0 (Stereo)\r\n" \
789 "/enableSPDIFo - enable SPDIF-out\r\n" \
790 "/disableSPDIFo - disable SPDIF-out\r\n"\
791 "/enableSPDIFi - enable SPDIF-in recording\r\n" \
792 "/disableSPDIFi - disable SPDIF-in recording\r\n" \
793 "/enableLoopThru - enable loop-through from SPDIF-in to SPDIF-out\r\n" \
794 "/disableLoopThru - disable loop-through from SPDIF-in to SPDIF-out\r\n";
795
797 return;
798}
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919

Referenced by checkToken(), printUsage(), and tokenizeCommand().

◆ setCurrentChannelConfig()

BOOL setCurrentChannelConfig ( )

Definition at line 278 of file main.cpp.

279{
280 IDirectSound8* ds;
281 DWORD speakerConfig;
282 LPGUID guid = NULL;
283
284 DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&guid);
285
286 if (DirectSoundCreate8(guid, &ds, NULL) != S_OK) {
287 PrintLastError("DirectSoundCreate8()");
288 return FALSE;
289 }
290
291
292 ds->Initialize(NULL);
293
294 switch (currentChannelCount) {
295 case 2: speakerConfig = DSSPEAKER_STEREO; break;
296 case 4: speakerConfig = DSSPEAKER_QUAD; break;
297 case 6: speakerConfig = DSSPEAKER_5POINT1; break;
298 case 8: speakerConfig = DSSPEAKER_7POINT1; break;
299 default: speakerConfig = DSSPEAKER_STEREO; break;
300 }
301
302 if (ds->SetSpeakerConfig(speakerConfig) != S_OK) {
303 PrintLastError("SetSpeakerConfig()");
304 return FALSE;
305 }
306
307 if (ds) {
308 ds->Release();
309 }
310 if (guid) {
312 }
313
314 return FALSE;
315}

Referenced by applySettings(), and parseArguments().

◆ setDlgItems()

BOOL setDlgItems ( HWND  hWnd)

Definition at line 545 of file main.cpp.

546{
547 HWND hWndItem;
548 char buffer[127];
549
551 PrintLastError("getDriverData()");
552 return FALSE;
553 }
554
555 // 'About' tab
561 wsprintf(buffer, "%04X", cmiData.IOBase);
563 wsprintf(buffer, "%04X", cmiData.MPUBase);
565
566 // channel config combobox
568 SendMessage(hWndItem, CB_RESETCONTENT, 0, 0);
569 if (cmiData.maxChannels >= 2) {
570 SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"Stereo (2.0)");
571 }
572 if (cmiData.maxChannels >= 4) {
573 SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"Quadrophonic (4.0)");
574 }
575 if (cmiData.maxChannels >= 6) {
576 SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"5.1 Surround");
577 }
578 if (cmiData.maxChannels >= 8) {
579 SendMessage(hWndItem, CB_ADDSTRING, 0, (LPARAM)"7.1 Surround");
580 }
584 SendMessage(hWndItem, CB_SETCURSEL, (currentChannelCount/2)-1, 0);
586 } else {
589 }
590
591 // checkboxes
594
603
616
617 // radioboxes
621
624
625 return TRUE;
626}
#define IDC_VERSION
Definition: resource.h:270
void updateChannelBoxes(HWND hWnd)
Definition: main.cpp:503
BOOL getCurrentChannelConfig()
Definition: main.cpp:242
#define IDB_STARTSTOP
Definition: resource.h:56
#define IDC_HWREV
Definition: resource.h:86
#define IDC_MPUADR
Definition: resource.h:89
#define IDC_BASEADR
Definition: resource.h:88
#define IDC_MAXCHAN
Definition: resource.h:87
#define IDC_NOROUTE_LINE
Definition: resource.h:44
#define IDC_NOROUTE_MIC
Definition: resource.h:46
int hardwareRevision
Definition: property.h:65
UInt16 IOBase
Definition: property.h:66
char driverVersion[32]
Definition: property.h:64
UInt16 MPUBase
Definition: property.h:67
UInt32 maxChannels
Definition: property.h:68
#define BST_UNCHECKED
Definition: winuser.h:199
#define CB_SETCURSEL
Definition: winuser.h:1964
#define CB_RESETCONTENT
Definition: winuser.h:1962
#define BM_SETCHECK
Definition: winuser.h:1924
#define CB_ADDSTRING
Definition: winuser.h:1939
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define wsprintf
Definition: winuser.h:5877
#define SetWindowText
Definition: winuser.h:5869

Referenced by initDialog(), and WndProc().

◆ setDriverData()

BOOL setDriverData ( CMIDEV pDev)

Definition at line 443 of file main.cpp.

444{
445 BOOL result;
446 HANDLE hDevice;
447 KSPROPERTY KSProp;
449
451 if (hDevice == INVALID_HANDLE_VALUE) {
452 PrintLastError("CreateFile()");
453 return FALSE;
454 }
455 KSProp.Set = KSPROPSETID_CMI;
456 KSProp.Flags = KSPROPERTY_TYPE_SET;
457 KSProp.Id = KSPROPERTY_CMI_SET;
458 result = DeviceIoControl(hDevice, IOCTL_KS_PROPERTY, &KSProp, sizeof(KSProp), &cmiData, sizeof(cmiData), &dataSize, NULL);
459 CloseHandle(hDevice);
460
461 if (!result) {
462 PrintLastError("DeviceIoControl()");
463 return FALSE;
464 }
465
466 return TRUE;
467}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define KSPROPERTY_CMI_SET
Definition: property.h:40

Referenced by applySettings(), and parseArguments().

◆ stopTestTone()

BOOL stopTestTone ( void  )

Definition at line 103 of file main.cpp.

104{
105 if (hWave == NULL) {
106 return FALSE;
107 }
108
110 PrintLastError("waveOutReset()");
111 return FALSE;
112 }
114 PrintLastError("waveOutClose()");
115 return FALSE;
116 }
117 hWave = NULL;
119 return TRUE;
120}
UINT WINAPI waveOutClose(HWAVEOUT hWaveOut)
Definition: winmm.c:2257

Referenced by cleanUp(), and TabDlgProc().

◆ TabDlgProc()

INT_PTR CALLBACK TabDlgProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 751 of file main.cpp.

752{
753 switch(msg) {
754 case WM_COMMAND:
755 switch (LOWORD(wParam)) {
756 case IDB_STARTSTOP:
757 if (stopTestTone()) {
758 SetDlgItemText(hWndChild[0], IDB_STARTSTOP, "&Play test tone");
759 return TRUE;
760 }
761 if (playTestTone()) {
763 return TRUE;
764 }
765 break;
766 case IDC_URL1:
767 case IDC_URL2:
769 break;
770 }
773 SetTextColor((HDC)wParam, 0xFF0000);
776 }
777 }
778
779 return 0;
780}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL playTestTone()
Definition: main.cpp:139
void openURL(int control)
Definition: main.cpp:744
#define IDC_URL1
Definition: resource.h:90
static HDC
Definition: imagelist.c:88
#define LOWORD(l)
Definition: pedump.c:82
int32_t INT_PTR
Definition: typedefs.h:64
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1743
#define SetDlgItemText
Definition: winuser.h:5861
#define COLOR_BTNFACE
Definition: winuser.h:931

Referenced by initDialog().

◆ updateChannelBoxes()

void updateChannelBoxes ( HWND  hWnd)

Definition at line 503 of file main.cpp.

504{
506 case 0: // stereo
514 break;
515 case 1: // quad
523 break;
524 case 2: // 5.1
531 SetDlgItemText(hWnd, IDT_SWAPJACKS, "BL/BR and C/LFE jacks are swapped!");
532 break;
533 case 3: // 7.1
540 SetDlgItemText(hWnd, IDT_SWAPJACKS, "BL/BR and C/LFE jacks are swapped!");
541 break;
542 }
543}
#define IDT_SWAPJACKS
Definition: resource.h:38
#define SW_SHOW
Definition: winuser.h:778

Referenced by setDlgItems().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
PSTR  szCmdLine,
int  iCmdShow 
)

Definition at line 930 of file main.cpp.

931{
932 WNDCLASSEX wce;
933 MSG msg;
934
935 ZeroMemory(&cmiData, sizeof(CMIDATA));
937 hWave = NULL;
938
939 if (szCmdLine && szCmdLine[0] != 0) {
940 int result = parseArguments(szCmdLine);
941 cleanUp();
942 return result;
943 }
944
945 if ((hWndMain = FindWindow("cmiControlPanel", NULL))) {
947 return FALSE;
948 }
949
953
954 ZeroMemory(&wce, sizeof(WNDCLASSEX));
955 wce.cbSize = sizeof(WNDCLASSEX);
957 wce.style = 0;
959 wce.hInstance = hInstance;
961 wce.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
962 wce.lpszClassName = "cmiControlPanel";
963 wce.lpszMenuName = NULL;
966 if(!RegisterClassEx(&wce)) {
967 PrintLastError("RegisterClassEx()");
968 return -1;
969 }
971
973 if (!hWndMain) {
974 PrintLastError("CreateDialogParam()");
975 return -1;
976 }
977
978 while (GetMessage(&msg, (HWND) NULL, 0, 0)) {
981 }
982 return 0;
983}
#define IDD_MAIN
Definition: resource.h:106
HINSTANCE hInstance
Definition: charmap.c:19
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
#define DLGPROC
Definition: maze.c:62
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
int parseArguments(LPSTR szCmdLine)
Definition: main.cpp:869
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.cpp:712
void InitURLControl()
Definition: main.cpp:911
void cleanUp()
Definition: main.cpp:469
#define DefDlgProc
Definition: ros2win.h:34
Definition: main.h:63
LPCSTR lpszMenuName
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3215
UINT style
Definition: winuser.h:3205
int cbWndExtra
Definition: winuser.h:3208
WNDPROC lpfnWndProc
Definition: winuser.h:3206
HICON hIcon
Definition: winuser.h:3210
HBRUSH hbrBackground
Definition: winuser.h:3212
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define DLGWINDOWEXTRA
Definition: winuser.h:2568
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:921
#define FindWindow
Definition: winuser.h:5789
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define IDC_ARROW
Definition: winuser.h:687
#define GetMessage
Definition: winuser.h:5802
#define DispatchMessage
Definition: winuser.h:5777

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 712 of file main.cpp.

713{
714 switch(msg) {
715 case WM_INITDIALOG:
716 if (!initDialog(hWnd)) {
718 }
719 return TRUE;
720 case WM_CLOSE:
722 return TRUE;
723 case WM_NOTIFY:
724 return changeTab((LPNMHDR)lParam);
725 case WM_DESTROY:
726 cleanUp();
728 return TRUE;
729 case WM_COMMAND:
730 if (LOWORD(wParam) == IDB_CLOSE) {
732 return TRUE;
733 }
734 if (LOWORD(wParam) == IDB_APPLY) {
737 return TRUE;
738 }
739 break;
740 }
741 return 0;
742}
BOOL initDialog(HWND hWnd)
Definition: main.cpp:665
BOOL changeTab(LPNMHDR lpnmhdr)
Definition: main.cpp:701
BOOL applySettings()
Definition: main.cpp:628
#define IDB_CLOSE
Definition: resource.h:35
#define IDB_APPLY
Definition: resource.h:36
#define WM_NOTIFY
Definition: richedit.h:61
#define WM_CLOSE
Definition: winuser.h:1624
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_DESTROY
Definition: winuser.h:1612
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by WinMain().