diff --git a/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils001.cpp b/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils001.cpp index db454164..42161893 100644 --- a/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils001.cpp +++ b/lsteamclient/cppISteamNetworkingUtils_SteamNetworkingUtils001.cpp @@ -71,6 +71,7 @@ SteamNetworkingMicroseconds cppISteamNetworkingUtils_SteamNetworkingUtils001_Get void cppISteamNetworkingUtils_SteamNetworkingUtils001_SetDebugOutputFunction(void *linux_side, ESteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc) { + pfnFunc = (FSteamNetworkingSocketsDebugOutput)manual_convert_FSteamNetworkingSocketsDebugOutput((void*)pfnFunc); ((ISteamNetworkingUtils*)linux_side)->SetDebugOutputFunction((ESteamNetworkingSocketsDebugOutputType)eDetailLevel, (FSteamNetworkingSocketsDebugOutput)pfnFunc); } diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index a6551049..ecafd9eb 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -169,6 +169,11 @@ manually_handled_structs = [ "SteamNetworkingMessage_t" ] +# manual converters for simple types (function pointers) +manual_type_converters = [ + "FSteamNetworkingSocketsDebugOutput" +] + #struct_conversion_cache = { # '142': { # 'SteamUGCDetails_t': True, @@ -467,6 +472,7 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e cfile.write(", %s *_r" % method.result_type.spelling) unnamed = 'a' need_convert = [] + manual_convert = [] for param in list(method.get_children()): if param.kind == clang.cindex.CursorKind.PARM_DECL: if param.type.kind == clang.cindex.TypeKind.POINTER and \ @@ -486,6 +492,8 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e need_convert.append(param) #preserve pointers win_name = typename.replace(real_type.spelling, "win%s_%s" % (real_type.spelling, sdkver)) + elif real_type.spelling in manual_type_converters: + manual_convert.append(param) if param.spelling == "": cfile.write(", %s _%s" % (win_name, unnamed)) @@ -532,6 +540,8 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e #raw structs cpp.write(" %s lin_%s;\n" % (param.type.spelling, param.spelling)) cpp.write(" win_to_lin_struct_%s_%s(&%s, &lin_%s);\n" % (param.type.spelling, sdkver, param.spelling, param.spelling)) + for param in manual_convert: + cpp.write(" %s = (%s)manual_convert_%s((void*)%s);\n" % (param.spelling, param.type.spelling, param.type.spelling, param.spelling)) cfile.write(" TRACE(\"%p\\n\", _this);\n") diff --git a/lsteamclient/steam_defs.h b/lsteamclient/steam_defs.h index 05d96a2f..f9bcc12a 100644 --- a/lsteamclient/steam_defs.h +++ b/lsteamclient/steam_defs.h @@ -209,7 +209,8 @@ typedef struct SteamDatagramHostedAddress SteamDatagramHostedAddress; typedef void *SteamAPI_CheckCallbackRegistered_t; typedef void *SteamAPIWarningMessageHook_t; typedef void *SteamAPI_PostAPIResultInProcess_t; -typedef void *FSteamNetworkingSocketsDebugOutput; /* XXX */ + +typedef void (*FSteamNetworkingSocketsDebugOutput)(ESteamNetworkingSocketsDebugOutputType nType, const char *pszMsg); typedef uint8 Salt_t[8]; typedef uint64 GID_t; diff --git a/lsteamclient/steamclient_private.h b/lsteamclient/steamclient_private.h index c92f5a27..ac1101b6 100644 --- a/lsteamclient/steamclient_private.h +++ b/lsteamclient/steamclient_private.h @@ -46,6 +46,7 @@ void *create_LinuxISteamMatchmakingServerListResponse(void *win, const char *ver void *create_LinuxISteamMatchmakingPingResponse(void *win, const char *version); void *create_LinuxISteamMatchmakingPlayersResponse(void *win, const char *version); void *create_LinuxISteamMatchmakingRulesResponse(void *win, const char *version); +void *manual_convert_FSteamNetworkingSocketsDebugOutput(void *win_func); extern char g_tmppath[PATH_MAX]; diff --git a/lsteamclient/steamclient_wrappers.c b/lsteamclient/steamclient_wrappers.c index adede0b2..34c463b5 100644 --- a/lsteamclient/steamclient_wrappers.c +++ b/lsteamclient/steamclient_wrappers.c @@ -280,3 +280,18 @@ void *create_LinuxISteamMatchmakingRulesResponse(void *win, const char *version) return ret; } + + +/***** FSteamNetworkingSocketsDebugOutput *****/ +static void (CDECL *stored_FSteamNetworkingSocketsDebugOutput)(ESteamNetworkingSocketsDebugOutputType nType, const char *pszMsg); + +static void lin_FSteamNetworkingSocketsDebugOutput(ESteamNetworkingSocketsDebugOutputType nType, const char *pszMsg) +{ + stored_FSteamNetworkingSocketsDebugOutput(nType, pszMsg); +} + +void *manual_convert_FSteamNetworkingSocketsDebugOutput(void *win_func) +{ + stored_FSteamNetworkingSocketsDebugOutput = (void*)win_func; + return &lin_FSteamNetworkingSocketsDebugOutput; +}