aboutsummaryrefslogtreecommitdiff
path: root/utils/winmm_drv/test/test.c
diff options
context:
space:
mode:
authorVitaly Novichkov <Wohlstand@users.noreply.github.com>2020-09-21 00:43:58 +0300
committerGitHub <noreply@github.com>2020-09-21 00:43:58 +0300
commit9b51dd7d667e97338a92711543fc3e942faae52f (patch)
tree63539cbf427912686565dab81b3aa820346967b5 /utils/winmm_drv/test/test.c
parente082315b04cbc75b4cfce744e9274bb8c5cedd38 (diff)
downloadlibADLMIDI-9b51dd7d667e97338a92711543fc3e942faae52f.tar.gz
libADLMIDI-9b51dd7d667e97338a92711543fc3e942faae52f.tar.bz2
libADLMIDI-9b51dd7d667e97338a92711543fc3e942faae52f.zip
Added WinMM driver for windows (#236)
* ADLMIDI2: Fixed an MSVC build However, it may work glitchy! * Experimental WinMM MIDI driver TODO: Make a control panel to configure the driver * WinMM-DRV: A workaround for older MinGW * WinMM-DRV: WIP control panel appled / tool * WinMM-DRV: Better test a driver's work * WinMM-DRV: More progress on a control panel * WinMM-DRV: And more progress on this control panel It's almost completed, I need to make the working setup through a registry. * WinMM-DRV: Driver is almost ready However, control panel can't ping a driver to reload settings yet * WinMM-DRV: Fix the missing volume model setup * WinMM-DRV: Setup reload on the fly now work! * WinMM-DRV: Stabilize the thing * WinMM-DRV: Stabilizing * WinMM-DRV: Avoid all "setup" in names to avoid a stupid PCA thing: https://stackoverflow.com/questions/17660404/how-to-programmatically-disable-program-compatibility-assistant-in-windows-7-and * A small warning fix at the WOPL module * WinMM-DRV: Fixed some warnings * WinMM-DRV: Avoid PCA dialog on the installer * WiNMM-DRV: Make the linking of pthread being optional Required to use MinGW-w64 toolchain with the "win32" threading mode * WinMM-DRV: Receive the MODM_RESET to reset the MIDI state * WinMM-DRV: Attempt to fix a sound distorsion on song song * WinMM-Drv: Fixed a build on some older MinGW toolchains * WinMM-Drv: Fixed default settings not being loaded
Diffstat (limited to 'utils/winmm_drv/test/test.c')
-rw-r--r--utils/winmm_drv/test/test.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/utils/winmm_drv/test/test.c b/utils/winmm_drv/test/test.c
new file mode 100644
index 0000000..f6fd2e9
--- /dev/null
+++ b/utils/winmm_drv/test/test.c
@@ -0,0 +1,105 @@
+#include <windows.h>
+#include <stdio.h>
+#include <mmsystem.h>
+
+typedef DWORD (WINAPI * MessagePtr)(UINT, UINT, DWORD, DWORD, DWORD);
+
+#ifndef MODM_GETDEVCAPS
+#define MODM_GETDEVCAPS 2
+#endif
+
+LONG testDriver()
+{
+ HDRVR hdrvr;
+ DRVCONFIGINFO dci;
+ LONG lRes;
+ HMODULE lib;
+ DWORD modRet;
+ MIDIOUTCAPSA myCapsA;
+ MessagePtr modMessagePtr;
+
+ printf("Open...\n");
+ // Open the driver (no additional parameters needed this time).
+ if((hdrvr = OpenDriver(L"adlmididrv.dll", 0, 0)) == 0)
+ {
+ printf("!!! Can't open the driver\n");
+ return -1;
+ }
+
+ printf("Send DRV_QUERYCONFIGURE...\n");
+ // Make sure driver has a configuration dialog box.
+ if(SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0)
+ {
+ // Set the DRVCONFIGINFO structure and send the message
+ dci.dwDCISize = sizeof (dci);
+ dci.lpszDCISectionName = (LPWSTR)0;
+ dci.lpszDCIAliasName = (LPWSTR)0;
+ printf("Send DRV_CONFIGURE...\n");
+ lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LPARAM)&dci);
+ printf("<-- Got answer: %ld)\n", lRes);
+ }
+ else
+ {
+ printf("<-- No configure\n");
+ lRes = DRVCNF_OK;
+ }
+
+
+ printf("Getting library pointer\n");
+ if((lib = GetDriverModuleHandle(hdrvr)))
+ {
+ printf("Getting modMessage call\n");
+ modMessagePtr = (MessagePtr)GetProcAddress(lib, "modMessage");
+ if(!modMessagePtr)
+ {
+ CloseDriver(hdrvr, 0, 0);
+ printf("!!! modMessage not found!\n");
+ return -1;
+ }
+
+ printf("Getting capabilities...\n");
+ modRet = modMessagePtr(0, MODM_GETDEVCAPS, (DWORD_PTR)NULL, (DWORD_PTR)&myCapsA, sizeof(myCapsA));
+ if(modRet != MMSYSERR_NOERROR)
+ {
+ CloseDriver(hdrvr, 0, 0);
+ printf("!!! modMessage returned an error!\n");
+ return -1;
+ }
+
+ printf("<-- %s\n", myCapsA.szPname);
+ }
+ else
+ {
+ CloseDriver(hdrvr, 0, 0);
+ printf("!!! Error when getting module handler!\n");
+ return -1;
+ }
+
+ printf("Close...\n");
+ // Close the driver (no additional parameters needed this time).
+ if(FAILED(CloseDriver(hdrvr, 0, 0)))
+ {
+ printf("!!! Error when closing\n");
+ return -1;
+ }
+
+ printf("Return...\n");
+
+ return 0;
+}
+
+int main()
+{
+ LONG d = testDriver();
+
+ if(d == 0)
+ {
+ printf("TEST = OK\n");
+ return 0;
+ }
+ else
+ {
+ printf("TEST = FAILED\n");
+ return 1;
+ }
+}