tried to fix something only to realize it isnt possible
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package native;
|
||||
|
||||
#if windows
|
||||
@:buildXml('
|
||||
<target id="haxe">
|
||||
<lib name="dwmapi.lib" if="windows" />
|
||||
<lib name="shell32.lib" if="windows" />
|
||||
<lib name="gdi32.lib" if="windows" />
|
||||
<lib name="ole32.lib" if="windows" />
|
||||
</target>
|
||||
')
|
||||
|
||||
// majority is taken from microsofts doc
|
||||
@:cppFileCode('
|
||||
#include "mmdeviceapi.h"
|
||||
#include "combaseapi.h"
|
||||
#include <iostream>
|
||||
|
||||
#define SAFE_RELEASE(punk) \\
|
||||
if ((punk) != NULL) \\
|
||||
{ (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
static long lastDefId = 0;
|
||||
|
||||
class AudioFixClient : public IMMNotificationClient {
|
||||
LONG _cRef;
|
||||
IMMDeviceEnumerator *_pEnumerator;
|
||||
|
||||
public:
|
||||
AudioFixClient() :
|
||||
_cRef(1),
|
||||
_pEnumerator(NULL)
|
||||
{
|
||||
HRESULT result = CoCreateInstance(__uuidof(MMDeviceEnumerator),
|
||||
NULL, CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IMMDeviceEnumerator),
|
||||
(void**)&_pEnumerator);
|
||||
if (result == S_OK) {
|
||||
_pEnumerator->RegisterEndpointNotificationCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
~AudioFixClient()
|
||||
{
|
||||
SAFE_RELEASE(_pEnumerator);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
return InterlockedIncrement(&_cRef);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
ULONG ulRef = InterlockedDecrement(&_cRef);
|
||||
if (0 == ulRef)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
return ulRef;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
REFIID riid, VOID **ppvInterface)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId)
|
||||
{
|
||||
return S_OK;
|
||||
};
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(
|
||||
LPCWSTR pwstrDeviceId,
|
||||
DWORD dwNewState)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(
|
||||
LPCWSTR pwstrDeviceId,
|
||||
const PROPERTYKEY key)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(
|
||||
EDataFlow flow, ERole role,
|
||||
LPCWSTR pwstrDeviceId)
|
||||
{
|
||||
std::cout << "fuck";
|
||||
::funkin::_hx_system::Main_obj::audioDisconnected = true;
|
||||
return S_OK;
|
||||
};
|
||||
};
|
||||
|
||||
AudioFixClient *curAudioFix;
|
||||
')
|
||||
@:dox(hide)
|
||||
class WinAPI {
|
||||
|
||||
public static var __audioChangeCallback:Void->Void = function() {
|
||||
trace("test");
|
||||
};
|
||||
|
||||
|
||||
@:functionCode('
|
||||
if (!curAudioFix) curAudioFix = new AudioFixClient();
|
||||
')
|
||||
public static function registerAudio() {
|
||||
funkin.system.Main.audioDisconnected = true;
|
||||
}
|
||||
}
|
||||
#end
|
||||
Reference in New Issue
Block a user