Browse Source

Addes OSC sending functions with two arguments

tags/1.0
Ludwig Frühschütz 3 years ago
parent
commit
406baef516
3 changed files with 72 additions and 5 deletions
  1. +30
    -0
      OSC2AHK/dllmain.cpp
  2. +3
    -0
      OSC2AHK/dllmain.h
  3. +39
    -5
      msgtest.ahk

+ 30
- 0
OSC2AHK/dllmain.cpp View File

@ -199,6 +199,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));
@ -209,6 +219,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));
@ -219,6 +239,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++)


+ 3
- 0
OSC2AHK/dllmain.h 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 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);


+ 39
- 5
msgtest.ahk View File

@ -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…
Cancel
Save