Squashed 'external/gainput/' content from commit 2be0a50

git-subtree-dir: external/gainput
git-subtree-split: 2be0a50089eafcc6fccb66142180082e48f27f4c
This commit is contained in:
Simone
2024-01-22 08:51:55 +01:00
commit 4e42229bdd
170 changed files with 31921 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
#include <gainput/gainput.h>
#ifdef GAINPUT_DEV
#include "GainputNetAddress.h"
#if defined(GAINPUT_PLATFORM_LINUX) || defined(GAINPUT_PLATFORM_ANDROID) || defined(GAINPUT_PLATFORM_WIN) || defined(GAINPUT_PLATFORM_IOS) || defined(GAINPUT_PLATFORM_MAC) || defined(GAINPUT_PLATFORM_TVOS)
#if defined(GAINPUT_PLATFORM_LINUX) || defined(GAINPUT_PLATFORM_ANDROID) || defined(GAINPUT_PLATFORM_IOS) || defined(GAINPUT_PLATFORM_MAC) || defined(GAINPUT_PLATFORM_TVOS)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
namespace gainput {
NetAddress::NetAddress(const char* ip, unsigned port)
{
#if defined(GAINPUT_PLATFORM_LINUX) || defined(GAINPUT_PLATFORM_ANDROID) || defined(GAINPUT_PLATFORM_IOS) || defined(GAINPUT_PLATFORM_MAC) || defined(GAINPUT_PLATFORM_TVOS)
struct in_addr inp;
if (!inet_aton(ip, &inp))
{
assert(false);
return;
}
addr.sin_addr.s_addr = inp.s_addr;
#elif defined(GAINPUT_PLATFORM_WIN)
addr.sin_addr.s_addr = inet_addr(ip);
#endif
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
}
NetAddress::NetAddress(const struct sockaddr_in& rhs)
{
addr.sin_family = rhs.sin_family;
addr.sin_addr.s_addr = rhs.sin_addr.s_addr;
addr.sin_port = rhs.sin_port;
}
}
#endif
#endif