Compare commits
4 Commits
c0f962d2be
...
ee649473c3
Author | SHA1 | Date | |
---|---|---|---|
ee649473c3 | |||
1841ebb220 | |||
406baef516 | |||
6bd8687a45 |
@ -51,8 +51,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,3,0,0
|
||||
PRODUCTVERSION 0,3,0,0
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -69,12 +69,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Eleton Audio"
|
||||
VALUE "FileDescription", "AutoHotkey OSC integration"
|
||||
VALUE "FileVersion", "0.3.0.0"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "InternalName", "OSC2AHK.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2021"
|
||||
VALUE "OriginalFilename", "OSC2AHK.dll"
|
||||
VALUE "ProductName", "OSC2AHK"
|
||||
VALUE "ProductVersion", "0.3.0.0"
|
||||
VALUE "ProductVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -22,6 +22,7 @@ protected:
|
||||
handleOscMsg(m);
|
||||
}
|
||||
catch (osc::Exception& e) {
|
||||
(void)e;
|
||||
// any parsing errors such as unexpected argument types, or
|
||||
// missing arguments get thrown as exceptions.
|
||||
OutputDebugString(L"ProcessMessage: Error while parsing message: ...");
|
||||
@ -84,12 +85,16 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
OutputDebugString(L"DLL_PROCESS_ATTACH\r\n");
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
OutputDebugString(L"DLL_THREAD_ATTACH\r\n");
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
OutputDebugString(L"DLL_THREAD_DETACH\r\n");
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
OutputDebugString(L"DLL_THREAD_DETACH\r\n");
|
||||
close();
|
||||
break;
|
||||
}
|
||||
@ -104,6 +109,20 @@ DLLEXPORT int open(HWND targetWindowHandle, unsigned int port)
|
||||
if (!port) OutputDebugString(L"open: port!!\r\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Check if sock is currently free to use
|
||||
if (sock)
|
||||
{
|
||||
if (sock->IsBound()) //Sock is currently opened. User should call close() first!
|
||||
{
|
||||
OutputDebugString(L"open: seems to be opened already!\r\n");
|
||||
return 3;
|
||||
}
|
||||
else //Probably something went wrong in UDP socket, just try closing and reopening it...
|
||||
{
|
||||
close(0);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int timeout = 500; //timout for port opening, in ms
|
||||
|
||||
@ -133,7 +152,9 @@ DLLEXPORT int close(unsigned int clearListeners)
|
||||
{
|
||||
sock->AsynchronousBreak();
|
||||
}
|
||||
oscThread->join();
|
||||
if(oscThread) oscThread->join();
|
||||
delete sock;
|
||||
sock = nullptr;
|
||||
oscThread = NULL;
|
||||
hwnd = NULL;
|
||||
if (clearListeners) listeners.clear();
|
||||
@ -198,6 +219,16 @@ DLLEXPORT void sendOscMessageInt(char* ip, unsigned int port, char* address, int
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
DLLEXPORT void sendOscMessageInt2(char* ip, unsigned int port, char* address, int payload1, int payload2)
|
||||
{
|
||||
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
|
||||
char buffer[1024];
|
||||
osc::OutboundPacketStream p(buffer, 1024);
|
||||
p << osc::BeginMessage(address) << payload1 << payload2 << osc::EndMessage;
|
||||
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
DLLEXPORT void sendOscMessageFloat(char* ip, unsigned int port, char* address, float payload)
|
||||
{
|
||||
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
|
||||
@ -208,6 +239,16 @@ DLLEXPORT void sendOscMessageFloat(char* ip, unsigned int port, char* address, f
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
DLLEXPORT void sendOscMessageFloat2(char* ip, unsigned int port, char* address, float payload1, float payload2)
|
||||
{
|
||||
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
|
||||
char buffer[1024];
|
||||
osc::OutboundPacketStream p(buffer, 1024);
|
||||
p << osc::BeginMessage(address) << payload1 << payload2 << osc::EndMessage;
|
||||
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
DLLEXPORT void sendOscMessageString(char* ip, unsigned int port, char* address, char* payload)
|
||||
{
|
||||
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
|
||||
@ -218,6 +259,16 @@ DLLEXPORT void sendOscMessageString(char* ip, unsigned int port, char* address,
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
DLLEXPORT void sendOscMessageString2(char* ip, unsigned int port, char* address, char* payload1, char* payload2)
|
||||
{
|
||||
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
|
||||
char buffer[1024];
|
||||
osc::OutboundPacketStream p(buffer, 1024);
|
||||
p << osc::BeginMessage(address) << payload1 << payload2 << osc::EndMessage;
|
||||
|
||||
transmitSocket.Send(p.Data(), p.Size());
|
||||
}
|
||||
|
||||
void removeStoredString(int stringId)
|
||||
{
|
||||
for (UINT i = 0; i < storedStrings.size(); i++)
|
||||
@ -497,7 +548,7 @@ int handleOscMsg(const osc::ReceivedMessage& m)
|
||||
/* Debugging function to test messaging. Probably will be removed later. */
|
||||
DLLEXPORT int testMsg(HWND windowHandle, unsigned int messageID)
|
||||
{
|
||||
float theFloat = 1.01;
|
||||
float theFloat = (float)1.01;
|
||||
int lParam = reinterpret_cast<int&>(theFloat);
|
||||
|
||||
PostMessage(hwnd, 0x1002, 0, lParam); //post to message queue
|
||||
|
@ -25,8 +25,11 @@ extern "C" DLLEXPORT int addListener(LPCSTR address, unsigned int messageID, uns
|
||||
extern "C" DLLEXPORT int removeListener(LPCSTR address);
|
||||
extern "C" DLLEXPORT char* getStringData(char* targetString, unsigned int targetSize, unsigned int StringID);
|
||||
extern "C" DLLEXPORT void sendOscMessageInt(char* ip, unsigned int port, char* address, int payload);
|
||||
extern "C" DLLEXPORT void sendOscMessageInt2(char* ip, unsigned int port, char* address, int payload1, int payload2);
|
||||
extern "C" DLLEXPORT void sendOscMessageFloat(char* ip, unsigned int port, char* address, float payload);
|
||||
extern "C" DLLEXPORT void sendOscMessageFloat2(char* ip, unsigned int port, char* address, float payload1, float payload2);
|
||||
extern "C" DLLEXPORT void sendOscMessageString(char* ip, unsigned int port, char* address, char* payload);
|
||||
extern "C" DLLEXPORT void sendOscMessageString2(char* ip, unsigned int port, char* address, char* payload1, char* payload2);
|
||||
int handleOscMsg(const osc::ReceivedMessage& m);
|
||||
bool isMatchingOscType(unsigned int msgType, unsigned int listenerTypeField);
|
||||
bool isMatchingOSCAddress(const char* address, const char* pattern);
|
||||
|
44
msgtest.ahk
44
msgtest.ahk
@ -21,7 +21,9 @@ DllCall("LoadLibrary", "Str", "x64\Debug\OSC2AHK.dll", "Ptr")
|
||||
|
||||
OnMessage(0x1002, "msghandlerFloat")
|
||||
|
||||
DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7002)
|
||||
success := DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7003)
|
||||
if (success != 0)
|
||||
msgbox, Failed to open port!
|
||||
|
||||
DllCall("OSC2AHK.dll\addListener", AStr, "/test1", UInt, 0x1001, UInt, oscTypeInt)
|
||||
OnMessage(0x1001, "msghandlerInt")
|
||||
@ -122,10 +124,42 @@ do_exit:
|
||||
Esc::
|
||||
ExitApp
|
||||
|
||||
^a::
|
||||
VarSetCapacity(theStr, 10)
|
||||
theStr := DllCall("OSC2AHK.dll\getStringData", AStr, theStr, UInt, 10, UInt, 0, "Cdecl AStr")
|
||||
msgbox,%theStr%
|
||||
+a::
|
||||
;ret := DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7002)
|
||||
;MsgBox, %ret%
|
||||
ip := "127.0.0.1"
|
||||
port := 8002
|
||||
addr := "/testmsg"
|
||||
data := 42
|
||||
data2 := 43
|
||||
DllCall("OSC2AHK.dll\sendOscMessageInt", AStr, ip, UInt, port, AStr, addr, Int, data)
|
||||
return
|
||||
|
||||
+s::
|
||||
ip := "127.0.0.1"
|
||||
port := 8002
|
||||
addr := "/float/msg"
|
||||
data := 42.3
|
||||
data2 := 54.4
|
||||
DllCall("OSC2AHK.dll\sendOscMessageFloat2", AStr, ip, UInt, port, AStr, addr, Float, data, Float, data2)
|
||||
return
|
||||
|
||||
+d::
|
||||
ip := "127.0.0.1"
|
||||
port := 8002
|
||||
addr := "/msg/string"
|
||||
data := "This is the string"
|
||||
data2:= "Second string"
|
||||
DllCall("OSC2AHK.dll\sendOscMessageString2", AStr, ip, UInt, port, AStr, addr, AStr, data, AStr, data2)
|
||||
return
|
||||
|
||||
+f::
|
||||
ip := "127.0.0.1"
|
||||
port := 8002
|
||||
addr := "/msg/string"
|
||||
data := "This is the string"
|
||||
DllCall("OSC2AHK.dll\sendOscMessageString", AStr, ip, UInt, port, AStr, addr, AStr, data)
|
||||
return
|
||||
; DllCall("OSC2AHK.dll\close", UInt, 0)
|
||||
;msgbox,esc
|
||||
; DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7001)
|
Loading…
x
Reference in New Issue
Block a user