vrclient: Split IVRInput helpers to vrinput_manual.c.
CW-Bug-Id: #22729
This commit is contained in:
parent
51f76d68ab
commit
d26ee86dcd
4 changed files with 129 additions and 112 deletions
|
@ -8,6 +8,7 @@ EXTRADEFS = -DWINE_NO_LONG_TYPES -DGNUC
|
|||
C_SRCS = \
|
||||
vrclient_x64/flatapi.c \
|
||||
vrclient_x64/vrclient_main.c \
|
||||
vrclient_x64/vrinput_manual.c \
|
||||
vrclient_x64/vroverlay_manual.c \
|
||||
vrclient_x64/vrsystem_manual.c \
|
||||
vrclient_x64/vrrendermodels_manual.c \
|
||||
|
|
|
@ -33,28 +33,7 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
||||
|
||||
static void *vrclient_lib;
|
||||
static struct
|
||||
{
|
||||
ID3D11Device *d3d11_device;
|
||||
IDXGIVkInteropDevice *dxvk_device;
|
||||
BOOL d3d11_explicit_handoff, handoff_called;
|
||||
void *client_core_linux_side;
|
||||
|
||||
#ifndef __x86_64__
|
||||
/* Digital action state change fixup hack. */
|
||||
struct
|
||||
{
|
||||
VRActionHandle_t action;
|
||||
VRInputValueHandle_t origin;
|
||||
LARGE_INTEGER update_qpf_time;
|
||||
BOOL previous_state;
|
||||
}
|
||||
digital_actions_state[128];
|
||||
unsigned int digital_action_count;
|
||||
LARGE_INTEGER qpf_freq;
|
||||
#endif
|
||||
}
|
||||
compositor_data;
|
||||
struct compositor_data compositor_data;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
|
||||
{
|
||||
|
@ -1136,93 +1115,3 @@ vrmb_typeb ivrmailbox_undoc3(
|
|||
|
||||
return r;
|
||||
}
|
||||
|
||||
#pragma pack(push, 8)
|
||||
struct winInputDigitalActionData_t {
|
||||
bool bActive;
|
||||
VRInputValueHandle_t activeOrigin;
|
||||
bool bState;
|
||||
bool bChanged;
|
||||
float fUpdateTime;
|
||||
} __attribute__ ((ms_struct));
|
||||
#pragma pack(pop)
|
||||
|
||||
EVRInputError ivrinput_get_digital_action_data(
|
||||
void *func,
|
||||
void *linux_side, VRActionHandle_t action_handle, void *action_data, uint32_t action_data_size,
|
||||
VRInputValueHandle_t restrict_to_device, unsigned int version)
|
||||
{
|
||||
EVRInputError (*cpp_func)(void *, VRActionHandle_t, struct winInputDigitalActionData_t *, uint32_t, VRInputValueHandle_t) = func;
|
||||
|
||||
#ifdef __x86_64__
|
||||
return cpp_func(linux_side, action_handle, action_data, action_data_size, restrict_to_device);
|
||||
#else
|
||||
/* Digital action state change fixup hack. */
|
||||
struct winInputDigitalActionData_t *data = action_data;
|
||||
LARGE_INTEGER qpf;
|
||||
EVRInputError ret;
|
||||
unsigned int i;
|
||||
|
||||
ret = cpp_func(linux_side, action_handle, action_data, action_data_size, restrict_to_device);
|
||||
|
||||
TRACE("handle %s, data %p, data_size %u, restrict %s, origin %s, state %#x, changed %#x, ret %u, active %#x.\n",
|
||||
wine_dbgstr_longlong(action_handle), action_data, action_data_size,
|
||||
wine_dbgstr_longlong(restrict_to_device), wine_dbgstr_longlong(data->activeOrigin),
|
||||
data->bState, data->bChanged, ret, data->bActive);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (action_data_size != sizeof(*data))
|
||||
{
|
||||
WARN("Unexpected action_data_size %u.\n", action_data_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!data->bActive)
|
||||
return 0;
|
||||
|
||||
if (!compositor_data.qpf_freq.QuadPart)
|
||||
QueryPerformanceFrequency(&compositor_data.qpf_freq);
|
||||
QueryPerformanceCounter(&qpf);
|
||||
|
||||
for (i = 0; i < compositor_data.digital_action_count; ++i)
|
||||
{
|
||||
if (compositor_data.digital_actions_state[i].action == action_handle
|
||||
&& compositor_data.digital_actions_state[i].origin == data->activeOrigin)
|
||||
{
|
||||
if ((data->bChanged = (!compositor_data.digital_actions_state[i].previous_state != !data->bState)))
|
||||
{
|
||||
TRACE("action %s (%s) changed to %#x, data->fUpdateTime %f.\n", wine_dbgstr_longlong(action_handle),
|
||||
wine_dbgstr_longlong(restrict_to_device), data->bState, data->fUpdateTime);
|
||||
|
||||
compositor_data.digital_actions_state[i].update_qpf_time = qpf;
|
||||
compositor_data.digital_actions_state[i].previous_state = data->bState;
|
||||
}
|
||||
if (compositor_data.digital_actions_state[i].update_qpf_time.QuadPart)
|
||||
data->fUpdateTime = -(float)(qpf.QuadPart
|
||||
- compositor_data.digital_actions_state[i].update_qpf_time.QuadPart)
|
||||
/ compositor_data.qpf_freq.QuadPart;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(compositor_data.digital_actions_state))
|
||||
{
|
||||
static unsigned int once;
|
||||
if (!once++)
|
||||
WARN("Too many actions.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
compositor_data.digital_actions_state[i].action = action_handle;
|
||||
compositor_data.digital_actions_state[i].origin = data->activeOrigin;
|
||||
compositor_data.digital_actions_state[i].previous_state = data->bState;
|
||||
compositor_data.digital_actions_state[i].update_qpf_time = qpf;
|
||||
++compositor_data.digital_action_count;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -65,6 +65,29 @@ struct client_core_data
|
|||
SIZE_T created_interfaces_size;
|
||||
};
|
||||
|
||||
struct compositor_data
|
||||
{
|
||||
ID3D11Device *d3d11_device;
|
||||
IDXGIVkInteropDevice *dxvk_device;
|
||||
BOOL d3d11_explicit_handoff, handoff_called;
|
||||
void *client_core_linux_side;
|
||||
|
||||
#ifndef __x86_64__
|
||||
/* Digital action state change fixup hack. */
|
||||
struct
|
||||
{
|
||||
VRActionHandle_t action;
|
||||
VRInputValueHandle_t origin;
|
||||
LARGE_INTEGER update_qpf_time;
|
||||
BOOL previous_state;
|
||||
} digital_actions_state[128];
|
||||
unsigned int digital_action_count;
|
||||
LARGE_INTEGER qpf_freq;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern struct compositor_data compositor_data;
|
||||
|
||||
struct w_steam_iface
|
||||
{
|
||||
vtable_ptr *vtable;
|
||||
|
|
104
vrclient_x64/vrclient_x64/vrinput_manual.c
Normal file
104
vrclient_x64/vrclient_x64/vrinput_manual.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "dxvk-interop.h"
|
||||
#include "vrclient_defs.h"
|
||||
#include "vrclient_private.h"
|
||||
|
||||
#include "flatapi.h"
|
||||
|
||||
#include "struct_converters.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
||||
|
||||
#pragma pack( push, 8 )
|
||||
struct winInputDigitalActionData_t
|
||||
{
|
||||
bool bActive;
|
||||
VRInputValueHandle_t activeOrigin;
|
||||
bool bState;
|
||||
bool bChanged;
|
||||
float fUpdateTime;
|
||||
} __attribute__((ms_struct));
|
||||
#pragma pack( pop )
|
||||
|
||||
EVRInputError ivrinput_get_digital_action_data( void *func, void *linux_side, VRActionHandle_t action_handle,
|
||||
void *action_data, uint32_t action_data_size,
|
||||
VRInputValueHandle_t restrict_to_device, unsigned int version )
|
||||
{
|
||||
EVRInputError (*cpp_func)( void *, VRActionHandle_t, struct winInputDigitalActionData_t *,
|
||||
uint32_t, VRInputValueHandle_t ) = func;
|
||||
|
||||
#ifdef __x86_64__
|
||||
TRACE( "%p\n", linux_side );
|
||||
return cpp_func( linux_side, action_handle, action_data, action_data_size, restrict_to_device );
|
||||
#else
|
||||
/* Digital action state change fixup hack. */
|
||||
struct winInputDigitalActionData_t *data = action_data;
|
||||
LARGE_INTEGER qpf;
|
||||
EVRInputError ret;
|
||||
unsigned int i;
|
||||
|
||||
ret = cpp_func( linux_side, action_handle, action_data, action_data_size, restrict_to_device );
|
||||
|
||||
TRACE( "handle %s, data %p, data_size %u, restrict %s, origin %s, state %#x, changed %#x, ret "
|
||||
"%u, active %#x.\n",
|
||||
wine_dbgstr_longlong( action_handle ), action_data, action_data_size,
|
||||
wine_dbgstr_longlong( restrict_to_device ), wine_dbgstr_longlong( data->activeOrigin ),
|
||||
data->bState, data->bChanged, ret, data->bActive );
|
||||
|
||||
if (ret) return ret;
|
||||
|
||||
if (action_data_size != sizeof(*data))
|
||||
{
|
||||
WARN( "Unexpected action_data_size %u.\n", action_data_size );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!data->bActive) return 0;
|
||||
|
||||
if (!compositor_data.qpf_freq.QuadPart) QueryPerformanceFrequency( &compositor_data.qpf_freq );
|
||||
QueryPerformanceCounter( &qpf );
|
||||
|
||||
for (i = 0; i < compositor_data.digital_action_count; ++i)
|
||||
{
|
||||
if (compositor_data.digital_actions_state[i].action == action_handle &&
|
||||
compositor_data.digital_actions_state[i].origin == data->activeOrigin)
|
||||
{
|
||||
if ((data->bChanged = (!compositor_data.digital_actions_state[i].previous_state != !data->bState)))
|
||||
{
|
||||
TRACE( "action %s (%s) changed to %#x, data->fUpdateTime %f.\n",
|
||||
wine_dbgstr_longlong( action_handle ),
|
||||
wine_dbgstr_longlong( restrict_to_device ), data->bState, data->fUpdateTime );
|
||||
|
||||
compositor_data.digital_actions_state[i].update_qpf_time = qpf;
|
||||
compositor_data.digital_actions_state[i].previous_state = data->bState;
|
||||
}
|
||||
if (compositor_data.digital_actions_state[i].update_qpf_time.QuadPart)
|
||||
data->fUpdateTime = -(float)(qpf.QuadPart - compositor_data.digital_actions_state[i].update_qpf_time.QuadPart) / compositor_data.qpf_freq.QuadPart;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(compositor_data.digital_actions_state))
|
||||
{
|
||||
static unsigned int once;
|
||||
if (!once++) WARN( "Too many actions.\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
compositor_data.digital_actions_state[i].action = action_handle;
|
||||
compositor_data.digital_actions_state[i].origin = data->activeOrigin;
|
||||
compositor_data.digital_actions_state[i].previous_state = data->bState;
|
||||
compositor_data.digital_actions_state[i].update_qpf_time = qpf;
|
||||
++compositor_data.digital_action_count;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
Loading…
Reference in a new issue