From 8bb3afc9a2e046041afef5cf85cb33a0ff9f5c1c Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Fri, 2 Oct 2020 12:38:05 -0500 Subject: [PATCH] lsteamclient: Handle callbacks for ISteamNetworking interfaces --- ...etworkingUtils_SteamNetworkingUtils003.cpp | 5 - lsteamclient/gen_wrapper.py | 1 + lsteamclient/steamclient_manual_150.cpp | 154 ++++++++++++++++++ 3 files changed, 155 insertions(+), 5 deletions(-) diff --git a/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils003.cpp b/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils003.cpp index 90d6b924..1abdd856 100644 --- a/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils003.cpp +++ b/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils003.cpp @@ -78,11 +78,6 @@ void cppISteamNetworkingUtils_SteamNetworkingUtils003_SetDebugOutputFunction(voi ((ISteamNetworkingUtils*)linux_side)->SetDebugOutputFunction((ESteamNetworkingSocketsDebugOutputType)eDetailLevel, (FSteamNetworkingSocketsDebugOutput)pfnFunc); } -bool cppISteamNetworkingUtils_SteamNetworkingUtils003_SetConfigValue(void *linux_side, ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj, ESteamNetworkingConfigDataType eDataType, const void * pArg) -{ - return ((ISteamNetworkingUtils*)linux_side)->SetConfigValue((ESteamNetworkingConfigValue)eValue, (ESteamNetworkingConfigScope)eScopeType, (intptr_t)scopeObj, (ESteamNetworkingConfigDataType)eDataType, (const void *)pArg); -} - ESteamNetworkingGetConfigValueResult cppISteamNetworkingUtils_SteamNetworkingUtils003_GetConfigValue(void *linux_side, ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj, ESteamNetworkingConfigDataType * pOutDataType, void * pResult, size_t * cbResult) { return ((ISteamNetworkingUtils*)linux_side)->GetConfigValue((ESteamNetworkingConfigValue)eValue, (ESteamNetworkingConfigScope)eScopeType, (intptr_t)scopeObj, (ESteamNetworkingConfigDataType *)pOutDataType, (void *)pResult, (size_t *)cbResult); diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index e3b6e18d..f441777b 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -212,6 +212,7 @@ manually_handled_methods = { ], "cppISteamNetworkingUtils_SteamNetworkingUtils003": [ "AllocateMessage", + "SetConfigValue", ], "cppISteamNetworkingMessages_SteamNetworkingMessages002": [ "ReceiveMessagesOnChannel" diff --git a/lsteamclient/steamclient_manual_150.cpp b/lsteamclient/steamclient_manual_150.cpp index 154e7155..95633f87 100644 --- a/lsteamclient/steamclient_manual_150.cpp +++ b/lsteamclient/steamclient_manual_150.cpp @@ -21,6 +21,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient); extern "C" { #define SDKVER_150 #include "struct_converters.h" +#include "cb_converters.h" #include "queue.h" @@ -208,4 +209,157 @@ int cppISteamNetworkingMessages_SteamNetworkingMessages002_ReceiveMessagesOnChan return retval; } +#pragma pack( push, 8 ) +struct winSteamNetConnectionStatusChangedCallback_t_712 { + HSteamNetConnection m_hConn; + SteamNetConnectionInfo_t m_info __attribute__((aligned(8))); + ESteamNetworkingConnectionState m_eOldState; +} __attribute__ ((ms_struct)); +#pragma pack( pop ) + +typedef void (*CDECL win_FnSteamNetConnectionStatusChanged)(winSteamNetConnectionStatusChangedCallback_t_712 *); +win_FnSteamNetConnectionStatusChanged win_SteamNetConnectionStatusChanged; + +void lin_SteamNetConnectionStatusChanged(SteamNetConnectionStatusChangedCallback_t *l_dat) +{ + win_FnSteamNetConnectionStatusChanged fn = win_SteamNetConnectionStatusChanged; + if(fn){ + struct winSteamNetConnectionStatusChangedCallback_t_712 w_dat; + cb_SteamNetConnectionStatusChangedCallback_t_712(l_dat, &w_dat); + fn(&w_dat); + } +} + +typedef void (*CDECL win_FnSteamNetAuthenticationStatusChanged)(SteamNetAuthenticationStatus_t *); +win_FnSteamNetAuthenticationStatusChanged win_SteamNetAuthenticationStatusChanged; + +void lin_SteamNetAuthenticationStatusChanged(SteamNetAuthenticationStatus_t *dat) +{ + win_FnSteamNetAuthenticationStatusChanged fn = win_SteamNetAuthenticationStatusChanged; + if(fn) + fn(dat); +} + +typedef void (*CDECL win_FnSteamRelayNetworkStatusChanged)(SteamRelayNetworkStatus_t *); +win_FnSteamRelayNetworkStatusChanged win_SteamRelayNetworkStatusChanged; + +void lin_SteamRelayNetworkStatusChanged(SteamRelayNetworkStatus_t *dat) +{ + win_FnSteamRelayNetworkStatusChanged fn = win_SteamRelayNetworkStatusChanged; + if(fn) + fn(dat); +} + +typedef void (*CDECL win_FnSteamNetworkingMessagesSessionRequest)(SteamNetworkingMessagesSessionRequest_t *); +win_FnSteamNetworkingMessagesSessionRequest win_SteamNetworkingMessagesSessionRequest; + +void lin_SteamNetworkingMessagesSessionRequest(SteamNetworkingMessagesSessionRequest_t *dat) +{ + win_FnSteamNetworkingMessagesSessionRequest fn = win_SteamNetworkingMessagesSessionRequest; + if(fn) + fn(dat); +} + +typedef void (*CDECL win_FnSteamNetworkingMessagesSessionFailed)(SteamNetworkingMessagesSessionFailed_t *); +win_FnSteamNetworkingMessagesSessionFailed win_SteamNetworkingMessagesSessionFailed; + +void lin_SteamNetworkingMessagesSessionFailed(SteamNetworkingMessagesSessionFailed_t *dat) +{ + win_FnSteamNetworkingMessagesSessionFailed fn = win_SteamNetworkingMessagesSessionFailed; + if(fn) + fn(dat); +} + +bool cppISteamNetworkingUtils_SteamNetworkingUtils003_SetConfigValue(void *linux_side, + ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, + intptr_t scopeObj, ESteamNetworkingConfigDataType eDataType, const void *pArg) +{ + bool ret; + void *lin_fn; /* api requires passing pointer-to-pointer */ + switch(eValue){ + case k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged: + if(!pArg){ + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, NULL); + }else{ + if(*(void **)pArg == NULL) + lin_fn = NULL; + else + lin_fn = (void *)&lin_SteamNetConnectionStatusChanged; + + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, &lin_fn); + + if(ret) + win_SteamNetConnectionStatusChanged = *(win_FnSteamNetConnectionStatusChanged*)pArg; + } + return ret; + + case k_ESteamNetworkingConfig_Callback_AuthStatusChanged: + if(!pArg){ + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, NULL); + }else{ + if(*(void **)pArg == NULL) + lin_fn = NULL; + else + lin_fn = (void *)&lin_SteamNetAuthenticationStatusChanged; + + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, &lin_fn); + + if(ret) + win_SteamNetAuthenticationStatusChanged = *(win_FnSteamNetAuthenticationStatusChanged*)pArg; + } + return ret; + + case k_ESteamNetworkingConfig_Callback_RelayNetworkStatusChanged: + if(!pArg){ + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, NULL); + }else{ + if(*(void **)pArg == NULL) + lin_fn = NULL; + else + lin_fn = (void *)&lin_SteamRelayNetworkStatusChanged; + + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, &lin_fn); + + if(ret) + win_SteamRelayNetworkStatusChanged = *(win_FnSteamRelayNetworkStatusChanged*)pArg; + } + return ret; + + case k_ESteamNetworkingConfig_Callback_MessagesSessionRequest: + if(!pArg){ + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, NULL); + }else{ + if(*(void **)pArg == NULL) + lin_fn = NULL; + else + lin_fn = (void *)&lin_SteamNetworkingMessagesSessionRequest; + + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, &lin_fn); + + if(ret) + win_SteamNetworkingMessagesSessionRequest = *(win_FnSteamNetworkingMessagesSessionRequest*)pArg; + } + return ret; + + case k_ESteamNetworkingConfig_Callback_MessagesSessionFailed: + if(!pArg){ + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, NULL); + }else{ + if(*(void **)pArg == NULL) + lin_fn = NULL; + else + lin_fn = (void *)&lin_SteamNetworkingMessagesSessionFailed; + + ret = ((ISteamNetworkingUtils*)linux_side)->SetConfigValue(eValue, eScopeType, scopeObj, eDataType, &lin_fn); + + if(ret) + win_SteamNetworkingMessagesSessionFailed = *(win_FnSteamNetworkingMessagesSessionFailed*)pArg; + } + return ret; + + default: + return ((ISteamNetworkingUtils*)linux_side)->SetConfigValue((ESteamNetworkingConfigValue)eValue, (ESteamNetworkingConfigScope)eScopeType, (intptr_t)scopeObj, (ESteamNetworkingConfigDataType)eDataType, (const void *)pArg); + } +} + }