2021-09-15 21:52:44 +02:00
|
|
|
extern "C" {
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "steam_defs.h"
|
|
|
|
#pragma push_macro("__cdecl")
|
|
|
|
#undef __cdecl
|
2023-09-20 08:23:56 +02:00
|
|
|
#pragma push_macro("strncpy")
|
|
|
|
#undef strncpy
|
2021-09-15 21:52:44 +02:00
|
|
|
#include "steamworks_sdk_152/steam_api.h"
|
|
|
|
#include "steamworks_sdk_152/isteaminput.h"
|
|
|
|
#pragma pop_macro("__cdecl")
|
2023-09-20 08:23:56 +02:00
|
|
|
#pragma pop_macro("strncpy")
|
2021-09-15 21:52:44 +02:00
|
|
|
#include "steamclient_private.h"
|
|
|
|
|
2021-10-08 18:09:30 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2021-09-15 21:52:44 +02:00
|
|
|
extern "C" {
|
|
|
|
#define SDKVER_152
|
|
|
|
#include "struct_converters.h"
|
|
|
|
#include "cb_converters.h"
|
|
|
|
|
2023-08-24 01:27:02 +02:00
|
|
|
#define SDK_VERSION 1520
|
|
|
|
#include "steamclient_manual_common.h"
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
#include "cppISteamInput_SteamInput005.h"
|
|
|
|
#include "cppISteamController_SteamController008.h"
|
|
|
|
}
|
|
|
|
|
2021-09-15 21:52:44 +02:00
|
|
|
/***** manual fn wrapper for ISteamInput::EnableActionEventCallbacks *****/
|
|
|
|
win_SteamInputActionEventCallbackPointer win_EnableActionEventCallbacks;
|
|
|
|
|
|
|
|
void lin_SteamInputActionEventCallbackPointer(SteamInputActionEvent_t *dat)
|
|
|
|
{
|
|
|
|
win_SteamInputActionEventCallbackPointer fn = win_EnableActionEventCallbacks;
|
|
|
|
if(fn)
|
|
|
|
fn(dat);
|
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamInput_SteamInput005_EnableActionEventCallbacks( struct cppISteamInput_SteamInput005_EnableActionEventCallbacks_params *params )
|
2021-09-15 21:52:44 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamInput *iface = (ISteamInput *)params->linux_side;
|
|
|
|
win_EnableActionEventCallbacks = (win_SteamInputActionEventCallbackPointer)params->pCallback;
|
|
|
|
iface->EnableActionEventCallbacks( params->pCallback ? &lin_SteamInputActionEventCallbackPointer : NULL );
|
2021-09-15 21:52:44 +02:00
|
|
|
}
|
|
|
|
|
2021-10-08 18:09:30 +02:00
|
|
|
/***** convert and cache ISteamInput glyph paths *****/
|
2021-10-11 15:52:38 +02:00
|
|
|
static const size_t ESteamInputGlyphSize_count = 3;
|
2021-10-08 18:09:30 +02:00
|
|
|
static std::unordered_map<int /*EInputActionOrigin*/, char *> cached_input_glyphs;
|
2021-10-08 19:58:43 +02:00
|
|
|
static std::unordered_map<int /*EInputActionOrigin*/, char *> cached_input_glyphs_xbox;
|
2021-10-11 15:52:38 +02:00
|
|
|
static std::unordered_map<int /*flags*/, std::unordered_map<int /*EInputActionOrigin*/, char *> > cached_input_glyphs_svg;
|
|
|
|
static std::unordered_map<int /*flags*/, std::unordered_map<int /*EInputActionOrigin*/, char *> > cached_input_glyphs_png[ESteamInputGlyphSize_count];
|
2021-10-08 18:09:30 +02:00
|
|
|
|
2022-06-13 21:02:14 +02:00
|
|
|
const char *steamclient_isteaminput_getglyph_png(int origin, int size, int flags, const char *lin_path)
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
|
|
|
if(!lin_path)
|
|
|
|
return NULL;
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
if(size >= ESteamInputGlyphSize_count){
|
|
|
|
ERR("invalid glyph size: %u\n", size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cached_input_glyphs_png[size][flags].find(origin) == cached_input_glyphs_png[size][flags].end()){
|
2021-10-08 18:09:30 +02:00
|
|
|
char *dos_path = (char *)HeapAlloc(GetProcessHeap(), 0, PATH_MAX);
|
|
|
|
|
|
|
|
steamclient_unix_path_to_dos_path(1, lin_path, dos_path, PATH_MAX, 0);
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
cached_input_glyphs_png[size][flags][origin] = dos_path;
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
return cached_input_glyphs_png[size][flags][origin];
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2022-06-10 11:23:18 +02:00
|
|
|
const char *steamclient_isteaminput_getglyph_svg(int origin, int flags, const char *lin_path)
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
|
|
|
if(!lin_path)
|
|
|
|
return NULL;
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
if(cached_input_glyphs_svg[flags].find(origin) == cached_input_glyphs_svg[flags].end()){
|
2021-10-08 18:09:30 +02:00
|
|
|
char *dos_path = (char *)HeapAlloc(GetProcessHeap(), 0, PATH_MAX);
|
|
|
|
|
|
|
|
steamclient_unix_path_to_dos_path(1, lin_path, dos_path, PATH_MAX, 0);
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
cached_input_glyphs_svg[flags][origin] = dos_path;
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 15:52:38 +02:00
|
|
|
return cached_input_glyphs_svg[flags][origin];
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *steamclient_isteaminput_getglyph(int origin, const char *lin_path)
|
|
|
|
{
|
|
|
|
if(!lin_path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(cached_input_glyphs.find(origin) == cached_input_glyphs.end()){
|
|
|
|
char *dos_path = (char *)HeapAlloc(GetProcessHeap(), 0, PATH_MAX);
|
|
|
|
|
|
|
|
steamclient_unix_path_to_dos_path(1, lin_path, dos_path, PATH_MAX, 0);
|
|
|
|
|
|
|
|
cached_input_glyphs[origin] = dos_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cached_input_glyphs[origin];
|
|
|
|
}
|
|
|
|
|
2021-10-08 19:58:43 +02:00
|
|
|
const char *steamclient_isteaminput_getglyph_xbox(int origin, const char *lin_path)
|
|
|
|
{
|
|
|
|
if(!lin_path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(cached_input_glyphs_xbox.find(origin) == cached_input_glyphs_xbox.end()){
|
|
|
|
char *dos_path = (char *)HeapAlloc(GetProcessHeap(), 0, PATH_MAX);
|
|
|
|
|
|
|
|
steamclient_unix_path_to_dos_path(1, lin_path, dos_path, PATH_MAX, 0);
|
|
|
|
|
|
|
|
cached_input_glyphs_xbox[origin] = dos_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cached_input_glyphs_xbox[origin];
|
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamInput_SteamInput005_GetGlyphPNGForActionOrigin( struct cppISteamInput_SteamInput005_GetGlyphPNGForActionOrigin_params *params )
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamInput *iface = (ISteamInput *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphPNGForActionOrigin( (EInputActionOrigin)params->eOrigin,
|
|
|
|
(ESteamInputGlyphSize)params->eSize, params->unFlags );
|
|
|
|
params->_ret = steamclient_isteaminput_getglyph_png( params->eOrigin, params->eSize,
|
|
|
|
params->unFlags, params->_ret );
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamInput_SteamInput005_GetGlyphSVGForActionOrigin( struct cppISteamInput_SteamInput005_GetGlyphSVGForActionOrigin_params *params )
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamInput *iface = (ISteamInput *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphSVGForActionOrigin( (EInputActionOrigin)params->eOrigin, params->unFlags );
|
|
|
|
params->_ret = steamclient_isteaminput_getglyph_svg( params->eOrigin, params->unFlags, params->_ret );
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamInput_SteamInput005_GetGlyphForActionOrigin_Legacy( struct cppISteamInput_SteamInput005_GetGlyphForActionOrigin_Legacy_params *params )
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamInput *iface = (ISteamInput *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphForActionOrigin_Legacy( (EInputActionOrigin)params->eOrigin );
|
|
|
|
params->_ret = steamclient_isteaminput_getglyph( params->eOrigin, params->_ret );
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamInput_SteamInput005_GetGlyphForXboxOrigin( struct cppISteamInput_SteamInput005_GetGlyphForXboxOrigin_params *params )
|
2021-10-08 19:58:43 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamInput *iface = (ISteamInput *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphForXboxOrigin( (EXboxOrigin)params->eOrigin );
|
|
|
|
params->_ret = steamclient_isteaminput_getglyph_xbox( params->eOrigin, params->_ret );
|
2021-10-08 19:58:43 +02:00
|
|
|
}
|
|
|
|
|
2021-10-08 18:09:30 +02:00
|
|
|
/***** convert and cache ISteamController glyph paths *****/
|
|
|
|
static std::unordered_map<int /*EControllerActionOrigin*/, char *> cached_controller_glyphs;
|
|
|
|
|
|
|
|
const char *steamclient_isteamcontroller_getglyph(int origin, const char *lin_path)
|
|
|
|
{
|
|
|
|
if(!lin_path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(cached_controller_glyphs.find(origin) == cached_controller_glyphs.end()){
|
|
|
|
char *dos_path = (char *)HeapAlloc(GetProcessHeap(), 0, PATH_MAX);
|
|
|
|
|
|
|
|
steamclient_unix_path_to_dos_path(1, lin_path, dos_path, PATH_MAX, 0);
|
|
|
|
|
|
|
|
cached_controller_glyphs[origin] = dos_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cached_controller_glyphs[origin];
|
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamController_SteamController008_GetGlyphForActionOrigin( struct cppISteamController_SteamController008_GetGlyphForActionOrigin_params *params )
|
2021-10-08 18:09:30 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamController *iface = (ISteamController *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphForActionOrigin( (EControllerActionOrigin)params->eOrigin );
|
|
|
|
params->_ret = steamclient_isteamcontroller_getglyph( params->eOrigin, params->_ret );
|
2021-10-08 18:09:30 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 14:34:23 +02:00
|
|
|
void cppISteamController_SteamController008_GetGlyphForXboxOrigin( struct cppISteamController_SteamController008_GetGlyphForXboxOrigin_params *params )
|
2021-10-08 19:58:43 +02:00
|
|
|
{
|
2023-09-27 14:34:23 +02:00
|
|
|
ISteamController *iface = (ISteamController *)params->linux_side;
|
|
|
|
params->_ret = iface->GetGlyphForXboxOrigin( (EXboxOrigin)params->eOrigin );
|
|
|
|
params->_ret = steamclient_isteaminput_getglyph_xbox( params->eOrigin, params->_ret );
|
2021-09-15 21:52:44 +02:00
|
|
|
}
|