Addes OSC sending functions with two arguments

This commit is contained in:
Ludwig Frühschütz 2021-11-06 18:49:43 +01:00
parent 6bd8687a45
commit 406baef516
3 changed files with 72 additions and 5 deletions

View File

@ -199,6 +199,16 @@ DLLEXPORT void sendOscMessageInt(char* ip, unsigned int port, char* address, int
transmitSocket.Send(p.Data(), p.Size()); 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) DLLEXPORT void sendOscMessageFloat(char* ip, unsigned int port, char* address, float payload)
{ {
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port)); UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
@ -209,6 +219,16 @@ DLLEXPORT void sendOscMessageFloat(char* ip, unsigned int port, char* address, f
transmitSocket.Send(p.Data(), p.Size()); 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) DLLEXPORT void sendOscMessageString(char* ip, unsigned int port, char* address, char* payload)
{ {
UdpTransmitSocket transmitSocket(IpEndpointName(ip, port)); UdpTransmitSocket transmitSocket(IpEndpointName(ip, port));
@ -219,6 +239,16 @@ DLLEXPORT void sendOscMessageString(char* ip, unsigned int port, char* address,
transmitSocket.Send(p.Data(), p.Size()); 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) void removeStoredString(int stringId)
{ {
for (UINT i = 0; i < storedStrings.size(); i++) for (UINT i = 0; i < storedStrings.size(); i++)

View File

@ -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 int removeListener(LPCSTR address);
extern "C" DLLEXPORT char* getStringData(char* targetString, unsigned int targetSize, unsigned int StringID); 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 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 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 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); int handleOscMsg(const osc::ReceivedMessage& m);
bool isMatchingOscType(unsigned int msgType, unsigned int listenerTypeField); bool isMatchingOscType(unsigned int msgType, unsigned int listenerTypeField);
bool isMatchingOSCAddress(const char* address, const char* pattern); bool isMatchingOSCAddress(const char* address, const char* pattern);

View File

@ -21,7 +21,9 @@ DllCall("LoadLibrary", "Str", "x64\Debug\OSC2AHK.dll", "Ptr")
OnMessage(0x1002, "msghandlerFloat") 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) DllCall("OSC2AHK.dll\addListener", AStr, "/test1", UInt, 0x1001, UInt, oscTypeInt)
OnMessage(0x1001, "msghandlerInt") OnMessage(0x1001, "msghandlerInt")
@ -122,10 +124,42 @@ do_exit:
Esc:: Esc::
ExitApp ExitApp
^a:: +a::
VarSetCapacity(theStr, 10) ;ret := DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7002)
theStr := DllCall("OSC2AHK.dll\getStringData", AStr, theStr, UInt, 10, UInt, 0, "Cdecl AStr") ;MsgBox, %ret%
msgbox,%theStr% 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) ; DllCall("OSC2AHK.dll\close", UInt, 0)
;msgbox,esc ;msgbox,esc
; DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7001) ; DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7001)