lsteamclient: Move callback function handling to unixlib.cpp.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-10-03 09:23:28 +02:00 committed by Arkadiusz Hiler
parent d8574d35a5
commit bc000612cd
5 changed files with 84 additions and 124 deletions

View file

@ -242,7 +242,6 @@ SOURCES = \
cppISteamUtils_SteamUtils010.cpp \ cppISteamUtils_SteamUtils010.cpp \
cppISteamVideo_STEAMVIDEO_INTERFACE_V001.cpp \ cppISteamVideo_STEAMVIDEO_INTERFACE_V001.cpp \
cppISteamVideo_STEAMVIDEO_INTERFACE_V002.cpp \ cppISteamVideo_STEAMVIDEO_INTERFACE_V002.cpp \
unix_steam_client_manual.cpp \
unix_steam_input_manual.cpp \ unix_steam_input_manual.cpp \
unix_steam_networking_manual.cpp \ unix_steam_networking_manual.cpp \
unix_steam_utils_manual.cpp \ unix_steam_utils_manual.cpp \

View file

@ -305,104 +305,3 @@ struct u_ISteamNetworkingCustomSignalingRecvContext *create_LinuxISteamNetworkin
FIXME( "not implemented!\n" ); FIXME( "not implemented!\n" );
return NULL; return NULL;
} }
/***** FSteamNetworkingSocketsDebugOutput *****/
static w_FSteamNetworkingSocketsDebugOutput stored_FSteamNetworkingSocketsDebugOutput;
static void lin_FSteamNetworkingSocketsDebugOutput( uint32_t nType, const char *pszMsg )
{
queue_sockets_debug_output( stored_FSteamNetworkingSocketsDebugOutput, nType, pszMsg );
}
u_FSteamNetworkingSocketsDebugOutput manual_convert_SetDebugOutputFunction_pfnFunc( w_FSteamNetworkingSocketsDebugOutput win_func )
{
stored_FSteamNetworkingSocketsDebugOutput = win_func;
return &lin_FSteamNetworkingSocketsDebugOutput;
}
static w_SteamAPIWarningMessageHook_t stored_SteamAPIWarningMessageHook_t;
static void lin_SteamAPIWarningMessageHook_t(int severity, const char *msg)
{
queue_warning_message_hook( stored_SteamAPIWarningMessageHook_t, severity, msg );
}
u_SteamAPIWarningMessageHook_t manual_convert_SetWarningMessageHook_pFunction( w_SteamAPIWarningMessageHook_t win_func )
{
TRACE("win_func %p, returning %p.\n", win_func, lin_SteamAPIWarningMessageHook_t);
stored_SteamAPIWarningMessageHook_t = win_func;
return &lin_SteamAPIWarningMessageHook_t;
}
/***** SteamAPI_CheckCallbackRegistered_t *****/
static w_SteamAPI_CheckCallbackRegistered_t stored_SteamAPI_CheckCallbackRegistered_t;
static uint32_t lin_SteamAPI_CheckCallbackRegistered_t( int32_t cb )
{
return stored_SteamAPI_CheckCallbackRegistered_t(cb);
}
u_SteamAPI_CheckCallbackRegistered_t manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func( w_SteamAPI_CheckCallbackRegistered_t win_func )
{
FIXME( "\n" );
if (!(stored_SteamAPI_CheckCallbackRegistered_t = win_func)) return NULL;
return &lin_SteamAPI_CheckCallbackRegistered_t;
}
static w_SteamAPI_CheckCallbackRegistered_t_156 stored_SteamAPI_CheckCallbackRegistered_t_156;
static uint32_t lin_SteamAPI_CheckCallbackRegistered_t_156( int cb )
{
return stored_SteamAPI_CheckCallbackRegistered_t_156( cb );
}
u_SteamAPI_CheckCallbackRegistered_t_156 manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func_156( w_SteamAPI_CheckCallbackRegistered_t_156 win_func )
{
if (!(stored_SteamAPI_CheckCallbackRegistered_t_156 = win_func)) return NULL;
return &lin_SteamAPI_CheckCallbackRegistered_t_156;
}
static w_SteamAPI_PostAPIResultInProcess_t stored_SteamAPI_PostAPIResultInProcess_t;
static void lin_SteamAPI_PostAPIResultInProcess_t( uint64_t a, void *b, uint32_t c, int32_t d )
{
FIXME( "\n" );
}
u_SteamAPI_PostAPIResultInProcess_t manual_convert_Set_SteamAPI_CPostAPIResultInProcess_func( w_SteamAPI_PostAPIResultInProcess_t win_func )
{
FIXME( "\n" );
if (!(stored_SteamAPI_PostAPIResultInProcess_t = win_func)) return NULL;
return &lin_SteamAPI_PostAPIResultInProcess_t;
}
u_SteamAPI_PostAPIResultInProcess_t manual_convert_Remove_SteamAPI_CPostAPIResultInProcess_func( w_SteamAPI_PostAPIResultInProcess_t win_func )
{
FIXME( "\n" );
stored_SteamAPI_PostAPIResultInProcess_t = NULL;
return &lin_SteamAPI_PostAPIResultInProcess_t;
}
static w_void_SteamAPI_PostAPIResultInProcess_t stored_void_SteamAPI_PostAPIResultInProcess_t;
static void lin_void_SteamAPI_PostAPIResultInProcess_t(void)
{
FIXME( "\n" );
}
u_void_SteamAPI_PostAPIResultInProcess_t manual_convert_DEPRECATED_Set_SteamAPI_CPostAPIResultInProcess__a( w_void_SteamAPI_PostAPIResultInProcess_t win_func )
{
FIXME( "\n" );
if (!(stored_void_SteamAPI_PostAPIResultInProcess_t = win_func)) return NULL;
return &lin_void_SteamAPI_PostAPIResultInProcess_t;
}
u_void_SteamAPI_PostAPIResultInProcess_t manual_convert_DEPRECATED_Remove_SteamAPI_CPostAPIResultInProcess__a( w_void_SteamAPI_PostAPIResultInProcess_t win_func )
{
FIXME( "\n" );
stored_void_SteamAPI_PostAPIResultInProcess_t = NULL;
return &lin_void_SteamAPI_PostAPIResultInProcess_t;
}

View file

@ -57,11 +57,6 @@ void callback_message_utow( const u_CallbackMsg_t *u_msg, w_CallbackMsg_t *w_msg
void *alloc_callback_wtou( int id, void *callback, int *callback_len ); void *alloc_callback_wtou( int id, void *callback, int *callback_len );
void convert_callback_utow( int id, void *u_callback, int u_callback_len, void *w_callback, int w_callback_len ); void convert_callback_utow( int id, void *u_callback, int u_callback_len, void *w_callback, int w_callback_len );
extern void queue_sockets_debug_output( void (*W_STDCALL pfnFunc)( uint32_t, const char * ),
uint32_t type, const char *msg );
extern void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char * ),
int32_t severity, const char *msg );
extern NTSTATUS steamclient_init( void * ); extern NTSTATUS steamclient_init( void * );
extern NTSTATUS steamclient_next_callback( void * ); extern NTSTATUS steamclient_next_callback( void * );
extern NTSTATUS steamclient_CreateInterface( void * ); extern NTSTATUS steamclient_CreateInterface( void * );

View file

@ -1,10 +0,0 @@
#include "unix_private.h"
NTSTATUS ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess( void *args )
{
struct ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess_params *params = (struct ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess_params *)args;
struct u_ISteamClient_SteamClient020 *iface = (struct u_ISteamClient_SteamClient020 *)params->linux_side;
uint32_t (*U_CDECL lin_func)(int32_t) = manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func_156( params->func );
iface->Set_SteamAPI_CCheckCallbackRegisteredInProcess( lin_func );
return 0;
}

View file

@ -16,9 +16,10 @@ struct callback_entry
static struct list callbacks = LIST_INIT( callbacks ); static struct list callbacks = LIST_INIT( callbacks );
static pthread_mutex_t callbacks_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t callbacks_lock = PTHREAD_MUTEX_INITIALIZER;
void queue_sockets_debug_output( void (*W_STDCALL pfnFunc)( uint32_t, const char * ), uint32_t type, const char *msg ) static w_FSteamNetworkingSocketsDebugOutput w_steam_networking_socket_debug_output;
static void u_steam_networking_socket_debug_output( uint32_t nType, const char *pszMsg )
{ {
uint32_t msg_size = strlen( msg ) + 1, size = msg_size; uint32_t msg_size = strlen( pszMsg ) + 1, size = msg_size;
struct callback_entry *entry; struct callback_entry *entry;
size += sizeof(struct callback_entry); size += sizeof(struct callback_entry);
@ -28,16 +29,23 @@ void queue_sockets_debug_output( void (*W_STDCALL pfnFunc)( uint32_t, const char
size -= offsetof( struct callback_entry, callback ); size -= offsetof( struct callback_entry, callback );
entry->callback.size = size; entry->callback.size = size;
entry->callback.sockets_debug_output.pfnFunc = pfnFunc; entry->callback.sockets_debug_output.pfnFunc = w_steam_networking_socket_debug_output;
entry->callback.sockets_debug_output.type = type; entry->callback.sockets_debug_output.type = nType;
memcpy( (char *)entry->callback.sockets_debug_output.msg, msg, msg_size ); memcpy( (char *)entry->callback.sockets_debug_output.msg, pszMsg, msg_size );
pthread_mutex_lock( &callbacks_lock ); pthread_mutex_lock( &callbacks_lock );
list_add_tail( &callbacks, &entry->entry ); list_add_tail( &callbacks, &entry->entry );
pthread_mutex_unlock( &callbacks_lock ); pthread_mutex_unlock( &callbacks_lock );
} }
void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char * ), int32_t severity, const char *msg ) u_FSteamNetworkingSocketsDebugOutput manual_convert_SetDebugOutputFunction_pfnFunc( w_FSteamNetworkingSocketsDebugOutput w_func )
{
w_steam_networking_socket_debug_output = w_func;
return &u_steam_networking_socket_debug_output;
}
static w_SteamAPIWarningMessageHook_t w_steam_api_warning_message_hook;
static void u_steam_api_warning_message_hook( int severity, const char *msg )
{ {
uint32_t msg_size = strlen( msg ) + 1, size = msg_size; uint32_t msg_size = strlen( msg ) + 1, size = msg_size;
struct callback_entry *entry; struct callback_entry *entry;
@ -49,7 +57,7 @@ void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char
size -= offsetof( struct callback_entry, callback ); size -= offsetof( struct callback_entry, callback );
entry->callback.size = size; entry->callback.size = size;
entry->callback.warning_message_hook.pFunction = pFunction; entry->callback.warning_message_hook.pFunction = w_steam_api_warning_message_hook;
entry->callback.warning_message_hook.severity = severity; entry->callback.warning_message_hook.severity = severity;
memcpy( (char *)entry->callback.warning_message_hook.msg, msg, msg_size ); memcpy( (char *)entry->callback.warning_message_hook.msg, msg, msg_size );
@ -58,6 +66,75 @@ void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char
pthread_mutex_unlock( &callbacks_lock ); pthread_mutex_unlock( &callbacks_lock );
} }
u_SteamAPIWarningMessageHook_t manual_convert_SetWarningMessageHook_pFunction( w_SteamAPIWarningMessageHook_t w_func )
{
w_steam_api_warning_message_hook = w_func;
return &u_steam_api_warning_message_hook;
}
static uint32_t U_STDCALL u_steam_api_check_callback_registered( int32_t v )
{
return 1;
}
u_SteamAPI_CheckCallbackRegistered_t manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func( w_SteamAPI_CheckCallbackRegistered_t w_func )
{
FIXME("not implemented!\n");
return &u_steam_api_check_callback_registered;
}
static uint32_t U_CDECL u_steam_api_check_callback_registered_156( int32_t v )
{
return 1;
}
u_SteamAPI_CheckCallbackRegistered_t_156 manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func_156( w_SteamAPI_CheckCallbackRegistered_t_156 w_func )
{
FIXME("not implemented!\n");
return &u_steam_api_check_callback_registered_156;
}
static void U_STDCALL u_steam_api_post_api_result_in_process( uint64_t a, void *b, uint32_t c, int d )
{
}
u_SteamAPI_PostAPIResultInProcess_t manual_convert_Set_SteamAPI_CPostAPIResultInProcess_func( w_SteamAPI_PostAPIResultInProcess_t w_func )
{
FIXME("not implemented!\n");
return &u_steam_api_post_api_result_in_process;
}
u_SteamAPI_PostAPIResultInProcess_t manual_convert_Remove_SteamAPI_CPostAPIResultInProcess_func( w_SteamAPI_PostAPIResultInProcess_t w_func )
{
FIXME("not implemented!\n");
return &u_steam_api_post_api_result_in_process;
}
static void U_STDCALL u_void_steam_api_post_api_result_in_process(void)
{
}
u_void_SteamAPI_PostAPIResultInProcess_t manual_convert_DEPRECATED_Set_SteamAPI_CPostAPIResultInProcess__a( w_void_SteamAPI_PostAPIResultInProcess_t w_func )
{
FIXME("not implemented!\n");
return &u_void_steam_api_post_api_result_in_process;
}
u_void_SteamAPI_PostAPIResultInProcess_t manual_convert_DEPRECATED_Remove_SteamAPI_CPostAPIResultInProcess__a( w_void_SteamAPI_PostAPIResultInProcess_t w_func )
{
FIXME("not implemented!\n");
return &u_void_steam_api_post_api_result_in_process;
}
NTSTATUS ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess( void *args )
{
struct ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess_params *params = (struct ISteamClient_SteamClient020_Set_SteamAPI_CCheckCallbackRegisteredInProcess_params *)args;
struct u_ISteamClient_SteamClient020 *iface = (struct u_ISteamClient_SteamClient020 *)params->linux_side;
uint32_t (*U_CDECL lin_func)(int32_t) = manual_convert_Set_SteamAPI_CCheckCallbackRegisteredInProcess_func_156( params->func );
iface->Set_SteamAPI_CCheckCallbackRegisteredInProcess( lin_func );
return 0;
}
NTSTATUS steamclient_next_callback( void *args ) NTSTATUS steamclient_next_callback( void *args )
{ {
struct steamclient_next_callback_params *params = (struct steamclient_next_callback_params *)args; struct steamclient_next_callback_params *params = (struct steamclient_next_callback_params *)args;