2018-01-18 22:29:49 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2022-12-13 21:55:47 +03:00
|
|
|
#include "winternl.h"
|
2018-01-18 22:29:49 +03:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2018-04-04 18:20:44 +03:00
|
|
|
#include "initguid.h"
|
2021-02-02 21:32:10 +03:00
|
|
|
#define COBJMACROS
|
|
|
|
#include "d3d11_4.h"
|
2018-05-11 03:18:06 +03:00
|
|
|
#include "dxvk-interop.h"
|
2018-04-04 18:20:44 +03:00
|
|
|
|
2023-09-27 00:56:43 +03:00
|
|
|
#include "vrclient_private.h"
|
|
|
|
|
2018-06-04 18:45:00 +03:00
|
|
|
#include "flatapi.h"
|
|
|
|
|
2022-12-13 21:55:47 +03:00
|
|
|
#include "wine/unixlib.h"
|
|
|
|
|
2018-01-18 22:29:49 +03:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
|
|
|
|
2023-10-02 21:00:22 +03:00
|
|
|
CREATE_TYPE_INFO_VTABLE;
|
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
struct compositor_data compositor_data = {0};
|
2021-01-26 13:05:00 +03:00
|
|
|
|
2018-01-18 22:29:49 +03:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %u, %p)\n", instance, reason, reserved);
|
|
|
|
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(instance);
|
2023-10-02 21:00:22 +03:00
|
|
|
#ifdef __x86_64__
|
|
|
|
init_type_info_rtti( (char *)instance );
|
|
|
|
init_rtti( (char *)instance );
|
|
|
|
#endif /* __x86_64__ */
|
2018-01-18 22:29:49 +03:00
|
|
|
break;
|
2021-01-26 13:05:00 +03:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2023-10-19 13:38:31 +03:00
|
|
|
if (compositor_data.client_core_linux_side)
|
2021-01-26 13:05:00 +03:00
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Cleanup_params params =
|
2021-03-30 20:27:10 +03:00
|
|
|
{
|
2023-10-19 13:38:31 +03:00
|
|
|
.linux_side = compositor_data.client_core_linux_side,
|
|
|
|
};
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Cleanup, ¶ms );
|
2023-10-19 13:38:31 +03:00
|
|
|
compositor_data.client_core_linux_side = NULL;
|
2021-01-26 13:05:00 +03:00
|
|
|
}
|
|
|
|
break;
|
2018-01-18 22:29:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-04-19 16:50:32 +03:00
|
|
|
static BOOL array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
|
|
|
|
{
|
|
|
|
SIZE_T max_capacity, new_capacity;
|
|
|
|
void *new_elements;
|
|
|
|
|
|
|
|
if (count <= *capacity)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
max_capacity = ~(SIZE_T)0 / size;
|
|
|
|
if (count > max_capacity)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
new_capacity = max(1, *capacity);
|
|
|
|
while (new_capacity < count && new_capacity <= max_capacity / 2)
|
|
|
|
new_capacity *= 2;
|
|
|
|
if (new_capacity < count)
|
|
|
|
new_capacity = count;
|
|
|
|
|
|
|
|
if (!*elements)
|
|
|
|
new_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_capacity * size);
|
|
|
|
else
|
|
|
|
new_elements = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *elements, new_capacity * size);
|
|
|
|
if (!new_elements)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*elements = new_elements;
|
|
|
|
*capacity = new_capacity;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-24 15:50:45 +03:00
|
|
|
struct w_steam_iface *create_win_interface(const char *name, void *linux_side)
|
2018-01-18 22:29:49 +03:00
|
|
|
{
|
2023-09-30 13:02:30 +03:00
|
|
|
iface_constructor constructor;
|
2018-01-18 22:29:49 +03:00
|
|
|
|
|
|
|
TRACE("trying to create %s\n", name);
|
|
|
|
|
2023-09-30 13:02:30 +03:00
|
|
|
if (!linux_side) return NULL;
|
|
|
|
if ((constructor = find_iface_constructor( name ))) return constructor( linux_side );
|
2018-01-18 22:29:49 +03:00
|
|
|
|
|
|
|
ERR("Don't recognize interface name: %s\n", name);
|
2018-04-19 16:50:32 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-01-18 22:29:49 +03:00
|
|
|
static int load_vrclient(void)
|
|
|
|
{
|
2023-09-20 10:36:01 +03:00
|
|
|
static const WCHAR PROTON_VR_RUNTIME_W[] = {'P','R','O','T','O','N','_','V','R','_','R','U','N','T','I','M','E',0};
|
2023-10-02 20:57:26 +03:00
|
|
|
static const WCHAR winevulkanW[] = {'w','i','n','e','v','u','l','k','a','n','.','d','l','l',0};
|
2023-10-19 13:38:31 +03:00
|
|
|
static BOOL loaded;
|
|
|
|
|
2023-10-02 20:57:26 +03:00
|
|
|
struct vrclient_init_params params = {.winevulkan = LoadLibraryW( winevulkanW )};
|
2020-02-26 19:50:10 +03:00
|
|
|
WCHAR pathW[PATH_MAX];
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
static const char append_path[] = "/bin/linux64/vrclient.so";
|
|
|
|
#else
|
|
|
|
static const char append_path[] = "/bin/vrclient.so";
|
|
|
|
#endif
|
2018-01-18 22:29:49 +03:00
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
if (loaded) return 1;
|
2018-01-18 22:29:49 +03:00
|
|
|
|
|
|
|
/* PROTON_VR_RUNTIME is provided by the proton setup script */
|
2023-09-20 10:36:01 +03:00
|
|
|
if(!GetEnvironmentVariableW(PROTON_VR_RUNTIME_W, pathW, ARRAY_SIZE(pathW)))
|
2020-02-26 19:50:10 +03:00
|
|
|
{
|
2022-07-28 20:22:30 +03:00
|
|
|
DWORD type, size;
|
|
|
|
LSTATUS status;
|
|
|
|
HKEY vr_key;
|
|
|
|
|
|
|
|
if ((status = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, KEY_READ, &vr_key)))
|
|
|
|
{
|
|
|
|
WINE_WARN("Could not create key, status %#x.\n", status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(pathW);
|
2023-09-20 10:36:01 +03:00
|
|
|
if ((status = RegQueryValueExW(vr_key, PROTON_VR_RUNTIME_W, NULL, &type, (BYTE *)pathW, &size)))
|
2022-07-28 20:22:30 +03:00
|
|
|
{
|
|
|
|
WINE_WARN("Could not query value, status %#x.\n", status);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (type != REG_SZ)
|
|
|
|
{
|
|
|
|
WINE_ERR("Unexpected value type %#x.\n", type);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RegCloseKey(vr_key);
|
2018-01-18 22:29:49 +03:00
|
|
|
}
|
|
|
|
|
2020-02-26 19:50:10 +03:00
|
|
|
sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL);
|
|
|
|
if(!sz)
|
|
|
|
{
|
|
|
|
ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
params.unix_path = HeapAlloc( GetProcessHeap(), 0, sz + sizeof(append_path) );
|
2020-02-26 19:50:10 +03:00
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
sz = WideCharToMultiByte( CP_UNIXCP, 0, pathW, -1, params.unix_path, sz, NULL, NULL );
|
2020-02-26 19:50:10 +03:00
|
|
|
if(!sz)
|
|
|
|
{
|
|
|
|
ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW));
|
2023-10-19 13:38:31 +03:00
|
|
|
HeapFree(GetProcessHeap(), 0, params.unix_path);
|
2020-02-26 19:50:10 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
strcat( params.unix_path, append_path );
|
2020-02-26 19:50:10 +03:00
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
TRACE( "got openvr runtime path: %s\n", params.unix_path );
|
2019-08-06 12:18:50 +03:00
|
|
|
|
2023-09-30 15:15:53 +03:00
|
|
|
VRCLIENT_CALL( vrclient_init, ¶ms );
|
|
|
|
if (params._ret) loaded = TRUE;
|
2018-01-18 22:29:49 +03:00
|
|
|
|
2023-10-19 13:38:31 +03:00
|
|
|
HeapFree( GetProcessHeap(), 0, params.unix_path );
|
|
|
|
return loaded;
|
2018-01-18 22:29:49 +03:00
|
|
|
}
|
|
|
|
|
2019-08-06 12:18:50 +03:00
|
|
|
void *CDECL HmdSystemFactory(const char *name, int *return_code)
|
|
|
|
{
|
2023-09-30 15:15:53 +03:00
|
|
|
struct vrclient_HmdSystemFactory_params params = {.name = name, .return_code = return_code};
|
2019-08-06 12:18:50 +03:00
|
|
|
TRACE("name: %s, return_code: %p\n", name, return_code);
|
2023-10-19 13:38:31 +03:00
|
|
|
if (!load_vrclient()) return NULL;
|
2023-09-30 15:15:53 +03:00
|
|
|
VRCLIENT_CALL( vrclient_HmdSystemFactory, ¶ms );
|
|
|
|
return create_win_interface( name, params._ret );
|
2019-08-06 12:18:50 +03:00
|
|
|
}
|
|
|
|
|
2018-01-18 22:29:49 +03:00
|
|
|
void *CDECL VRClientCoreFactory(const char *name, int *return_code)
|
|
|
|
{
|
2023-09-30 15:15:53 +03:00
|
|
|
struct vrclient_VRClientCoreFactory_params params = {.name = name, .return_code = return_code};
|
2018-01-18 22:29:49 +03:00
|
|
|
TRACE("name: %s, return_code: %p\n", name, return_code);
|
2023-10-19 13:38:31 +03:00
|
|
|
if (!load_vrclient()) return NULL;
|
2023-09-30 15:15:53 +03:00
|
|
|
VRCLIENT_CALL( vrclient_VRClientCoreFactory, ¶ms );
|
|
|
|
return create_win_interface( name, params._ret );
|
2018-01-18 22:29:49 +03:00
|
|
|
}
|
2018-04-04 18:20:44 +03:00
|
|
|
|
2021-05-03 22:10:55 +03:00
|
|
|
static bool is_hmd_present_reg(void)
|
|
|
|
{
|
|
|
|
DWORD type, value, wait_status, size;
|
|
|
|
DWORD is_hmd_present = 0;
|
|
|
|
LSTATUS status;
|
|
|
|
HANDLE event;
|
|
|
|
HKEY vr_key;
|
|
|
|
|
|
|
|
if ((status = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, KEY_READ, &vr_key)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not create key, status %#x.\n", status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(value);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "state", NULL, &type, (BYTE *)&value, &size)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not query value, status %#x.\n", status);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (type != REG_DWORD)
|
|
|
|
{
|
|
|
|
WINE_ERR("Unexpected value type %#x.\n", type);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return value == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = CreateEventA( NULL, FALSE, FALSE, NULL );
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (RegNotifyChangeKeyValue(vr_key, FALSE, REG_NOTIFY_CHANGE_LAST_SET, event, TRUE))
|
|
|
|
{
|
|
|
|
WINE_ERR("Error registering registry change notification.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
size = sizeof(value);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "state", NULL, &type, (BYTE *)&value, &size)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not query value, status %#x.\n", status);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (value)
|
|
|
|
break;
|
|
|
|
while ((wait_status = WaitForSingleObject(event, 1000)) == WAIT_TIMEOUT)
|
|
|
|
WINE_ERR("VR state wait timeout.\n");
|
|
|
|
|
|
|
|
if (wait_status != WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
WINE_ERR("Got unexpected wait status %#x.\n", wait_status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value != 1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = sizeof(is_hmd_present);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "is_hmd_present", NULL, &type, (BYTE *)&is_hmd_present, &size)))
|
|
|
|
WINE_ERR("Could not query is_hmd_present value, status %#x.\n", status);
|
|
|
|
|
|
|
|
done:
|
|
|
|
CloseHandle(event);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return is_hmd_present;
|
|
|
|
}
|
|
|
|
|
2023-09-27 10:39:03 +03:00
|
|
|
static void *ivrclientcore_get_generic_interface( void *object, const char *name_and_version, struct client_core_data *user_data )
|
2021-05-03 22:10:55 +03:00
|
|
|
{
|
2023-09-24 15:50:45 +03:00
|
|
|
struct w_steam_iface *win_object;
|
2018-04-19 16:50:32 +03:00
|
|
|
struct generic_interface *iface;
|
2023-09-30 13:02:30 +03:00
|
|
|
iface_destructor destructor;
|
2018-04-19 16:50:32 +03:00
|
|
|
|
2023-09-27 10:39:03 +03:00
|
|
|
TRACE( "%p %p\n", object, name_and_version );
|
2018-04-19 16:50:32 +03:00
|
|
|
|
|
|
|
if (!(win_object = create_win_interface(name_and_version, object)))
|
|
|
|
{
|
|
|
|
ERR("Failed to create win object %s.\n", name_and_version);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-30 13:02:30 +03:00
|
|
|
if ((destructor = find_iface_destructor( name_and_version )))
|
2018-04-19 16:50:32 +03:00
|
|
|
{
|
|
|
|
EnterCriticalSection(&user_data->critical_section);
|
|
|
|
if (array_reserve((void **)&user_data->created_interfaces,
|
|
|
|
&user_data->created_interfaces_size, user_data->created_interface_count + 1,
|
|
|
|
sizeof(*user_data->created_interfaces)))
|
|
|
|
{
|
|
|
|
iface = &user_data->created_interfaces[user_data->created_interface_count++];
|
|
|
|
iface->object = win_object;
|
|
|
|
iface->dtor = destructor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Failed to add interface to array.\n");
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&user_data->critical_section);
|
|
|
|
}
|
|
|
|
|
2018-06-04 18:45:00 +03:00
|
|
|
if (name_and_version && !strncmp(name_and_version, "FnTable:", 8))
|
|
|
|
return *((void **)win_object);
|
2018-04-19 16:50:32 +03:00
|
|
|
return win_object;
|
|
|
|
}
|
|
|
|
|
2021-02-03 14:14:28 +03:00
|
|
|
static void destroy_compositor_data(void)
|
|
|
|
{
|
|
|
|
TRACE("Destroying compositor data.\n");
|
|
|
|
memset(&compositor_data, 0, sizeof(compositor_data));
|
|
|
|
}
|
|
|
|
|
2023-09-27 10:39:03 +03:00
|
|
|
static void ivrclientcore_cleanup( struct client_core_data *user_data )
|
2018-04-19 16:50:32 +03:00
|
|
|
{
|
|
|
|
struct generic_interface *iface;
|
|
|
|
SIZE_T i;
|
|
|
|
|
|
|
|
EnterCriticalSection(&user_data->critical_section);
|
|
|
|
for (i = 0; i < user_data->created_interface_count; ++i)
|
|
|
|
{
|
|
|
|
iface = &user_data->created_interfaces[i];
|
|
|
|
|
|
|
|
iface->dtor(iface->object);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, user_data->created_interfaces);
|
|
|
|
user_data->created_interfaces = NULL;
|
|
|
|
user_data->created_interfaces_size = 0;
|
|
|
|
user_data->created_interface_count = 0;
|
|
|
|
LeaveCriticalSection(&user_data->critical_section);
|
|
|
|
|
|
|
|
DeleteCriticalSection(&user_data->critical_section);
|
|
|
|
}
|
|
|
|
|
2023-09-29 12:28:17 +03:00
|
|
|
w_Texture_t vrclient_translate_texture_dxvk( const w_Texture_t *texture, w_VRVulkanTextureData_t *vkdata,
|
|
|
|
IDXGIVkInteropSurface *dxvk_surface, IDXGIVkInteropDevice **p_dxvk_device,
|
|
|
|
VkImageLayout *image_layout, VkImageCreateInfo *image_info )
|
2020-08-16 23:31:33 +03:00
|
|
|
{
|
2023-09-29 12:28:17 +03:00
|
|
|
w_Texture_t vktexture;
|
2020-08-16 23:31:33 +03:00
|
|
|
VkImage image_handle;
|
|
|
|
|
|
|
|
dxvk_surface->lpVtbl->GetDevice(dxvk_surface, p_dxvk_device);
|
|
|
|
|
|
|
|
(*p_dxvk_device)->lpVtbl->GetVulkanHandles(*p_dxvk_device, &vkdata->m_pInstance,
|
|
|
|
&vkdata->m_pPhysicalDevice, &vkdata->m_pDevice);
|
|
|
|
|
|
|
|
(*p_dxvk_device)->lpVtbl->GetSubmissionQueue(*p_dxvk_device, &vkdata->m_pQueue, &vkdata->m_nQueueFamilyIndex);
|
|
|
|
|
|
|
|
image_info->sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
|
|
|
image_info->pNext = NULL;
|
|
|
|
|
|
|
|
dxvk_surface->lpVtbl->GetVulkanImageInfo(dxvk_surface, &image_handle, image_layout, image_info);
|
|
|
|
|
|
|
|
vkdata->m_nImage = (uint64_t)image_handle;
|
|
|
|
vkdata->m_nWidth = image_info->extent.width;
|
|
|
|
vkdata->m_nHeight = image_info->extent.height;
|
|
|
|
vkdata->m_nFormat = image_info->format;
|
|
|
|
vkdata->m_nSampleCount = image_info->samples;
|
|
|
|
|
|
|
|
vktexture = *texture;
|
|
|
|
vktexture.handle = vkdata;
|
|
|
|
vktexture.eType = TextureType_Vulkan;
|
|
|
|
|
|
|
|
return vktexture;
|
|
|
|
}
|
|
|
|
|
2023-09-14 17:22:47 +03:00
|
|
|
uint32_t __thiscall winIVRClientCore_IVRClientCore_002_Init( struct w_steam_iface *_this, uint32_t eApplicationType )
|
2023-09-27 10:09:37 +03:00
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_002_Init_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.eApplicationType = eApplicationType,
|
|
|
|
};
|
2023-09-27 10:09:37 +03:00
|
|
|
|
|
|
|
TRACE( "%p\n", _this );
|
|
|
|
|
|
|
|
InitializeCriticalSection( &_this->user_data.critical_section );
|
|
|
|
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_Init, ¶ms );
|
2023-09-27 12:05:52 +03:00
|
|
|
if (params._ret) WARN( "error %#x\n", params._ret );
|
|
|
|
return params._ret;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void __thiscall winIVRClientCore_IVRClientCore_002_Cleanup( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_002_Cleanup_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
};
|
2023-09-27 10:09:37 +03:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 10:39:03 +03:00
|
|
|
ivrclientcore_cleanup( &_this->user_data );
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_Cleanup, ¶ms );
|
2023-09-27 10:39:03 +03:00
|
|
|
destroy_compositor_data();
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void *__thiscall winIVRClientCore_IVRClientCore_002_GetGenericInterface( struct w_steam_iface *_this,
|
2023-09-14 17:22:47 +03:00
|
|
|
const char *pchNameAndVersion, uint32_t *peError )
|
2023-09-27 10:09:37 +03:00
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_002_GetGenericInterface_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.pchNameAndVersion = pchNameAndVersion,
|
|
|
|
.peError = peError,
|
|
|
|
};
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 10:09:37 +03:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
|
|
|
/* In theory we could pass this along, but we'd have to generate a separate
|
|
|
|
* set of thunks for it. Hopefully this will work as it is. */
|
2023-09-27 12:05:52 +03:00
|
|
|
if (pchNameAndVersion && !strncmp( pchNameAndVersion, "FnTable:", 8 )) params.pchNameAndVersion += 8;
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_GetGenericInterface, ¶ms );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
if (!params._ret)
|
2023-09-27 10:39:03 +03:00
|
|
|
{
|
|
|
|
WARN( "Failed to create %s.\n", pchNameAndVersion );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
params._ret = ivrclientcore_get_generic_interface( params._ret, pchNameAndVersion, &_this->user_data );
|
|
|
|
return params._ret;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool __thiscall winIVRClientCore_IVRClientCore_002_BIsHmdPresent( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_002_BIsHmdPresent_params params = {.linux_side = _this->u_iface};
|
2023-09-27 10:39:03 +03:00
|
|
|
|
|
|
|
TRACE( "linux_side %p, compositor_data.client_core_linux_side %p.\n", _this->u_iface,
|
|
|
|
compositor_data.client_core_linux_side );
|
|
|
|
|
|
|
|
/* BIsHmdPresent() currently always returns FALSE on Linux if called before Init().
|
|
|
|
* Return true if the value stored by steam.exe helper in registry says the HMD is presnt. */
|
|
|
|
if (compositor_data.client_core_linux_side || !is_hmd_present_reg())
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_BIsHmdPresent, ¶ms );
|
2023-09-27 12:05:52 +03:00
|
|
|
return params._ret;
|
2023-09-27 10:39:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
2023-09-14 17:22:47 +03:00
|
|
|
uint32_t __thiscall winIVRClientCore_IVRClientCore_003_Init( struct w_steam_iface *_this,
|
|
|
|
uint32_t eApplicationType, const char *pStartupInfo )
|
2023-09-27 10:09:37 +03:00
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Init_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.eApplicationType = eApplicationType,
|
|
|
|
.pStartupInfo = pStartupInfo,
|
|
|
|
};
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 10:09:37 +03:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
|
|
|
InitializeCriticalSection( &_this->user_data.critical_section );
|
|
|
|
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Init, ¶ms );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
if (params._ret) WARN( "error %#x\n", params._ret );
|
|
|
|
else compositor_data.client_core_linux_side = params.linux_side;
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
return params._ret;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void __thiscall winIVRClientCore_IVRClientCore_003_Cleanup( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Cleanup_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
};
|
2023-09-27 10:09:37 +03:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 10:39:03 +03:00
|
|
|
ivrclientcore_cleanup( &_this->user_data );
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Cleanup, ¶ms );
|
2023-09-27 10:39:03 +03:00
|
|
|
destroy_compositor_data();
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void *__thiscall winIVRClientCore_IVRClientCore_003_GetGenericInterface( struct w_steam_iface *_this,
|
2023-09-14 17:22:47 +03:00
|
|
|
const char *pchNameAndVersion, uint32_t *peError )
|
2023-09-27 10:09:37 +03:00
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_003_GetGenericInterface_params params =
|
2023-09-27 12:05:52 +03:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.pchNameAndVersion = pchNameAndVersion,
|
|
|
|
.peError = peError,
|
|
|
|
};
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 10:09:37 +03:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
|
|
|
/* In theory we could pass this along, but we'd have to generate a separate
|
|
|
|
* set of thunks for it. Hopefully this will work as it is. */
|
2023-09-27 12:05:52 +03:00
|
|
|
if (pchNameAndVersion && !strncmp( pchNameAndVersion, "FnTable:", 8 )) params.pchNameAndVersion += 8;
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_GetGenericInterface, ¶ms );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
if (!params._ret)
|
2023-09-27 10:39:03 +03:00
|
|
|
{
|
|
|
|
WARN( "Failed to create %s.\n", pchNameAndVersion );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
params._ret = ivrclientcore_get_generic_interface( params._ret, pchNameAndVersion, &_this->user_data );
|
|
|
|
return params._ret;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool __thiscall winIVRClientCore_IVRClientCore_003_BIsHmdPresent( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
struct IVRClientCore_IVRClientCore_003_BIsHmdPresent_params params = {.linux_side = _this->u_iface};
|
2023-09-27 10:39:03 +03:00
|
|
|
|
2023-09-27 12:05:52 +03:00
|
|
|
TRACE( "linux_side %p, compositor_data.client_core_linux_side %p.\n", _this->u_iface,
|
|
|
|
compositor_data.client_core_linux_side );
|
2023-09-27 10:39:03 +03:00
|
|
|
|
|
|
|
/* BIsHmdPresent() currently always returns FALSE on Linux if called before Init().
|
|
|
|
* Return true if the value stored by steam.exe helper in registry says the HMD is presnt. */
|
|
|
|
if (compositor_data.client_core_linux_side || !is_hmd_present_reg())
|
|
|
|
{
|
2023-09-30 14:08:49 +03:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_BIsHmdPresent, ¶ms );
|
2023-09-27 12:05:52 +03:00
|
|
|
return params._ret;
|
2023-09-27 10:39:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2023-09-27 10:09:37 +03:00
|
|
|
}
|
2023-10-05 15:28:29 +03:00
|
|
|
|
|
|
|
const w_CameraVideoStreamFrame_t_0914 * __thiscall winIVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame(struct w_steam_iface *_this, uint32_t nDeviceIndex)
|
|
|
|
{
|
|
|
|
static w_CameraVideoStreamFrame_t_0914 w_frame;
|
|
|
|
struct IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame_params params =
|
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.nDeviceIndex = nDeviceIndex,
|
|
|
|
._ret = &w_frame,
|
|
|
|
};
|
|
|
|
TRACE("%p\n", _this);
|
|
|
|
VRCLIENT_CALL( IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame, ¶ms );
|
|
|
|
return params._ret;
|
|
|
|
}
|