Compare commits
No commits in common. "33180f1b0dafba3eec21e0a0ffd6f506b04e3ca6" and "a0447b930f44e2bf493a1b53b9eaa08c86bf19fd" have entirely different histories.
33180f1b0d
...
a0447b930f
|
@ -153,10 +153,6 @@ deploy_all:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ls -lah
|
- ls -lah
|
||||||
- dnf -y install git
|
|
||||||
- mkdir -p release/source_code
|
|
||||||
- git bundle create release/source_code/source_code.bundle --all
|
|
||||||
- "echo \"This is a git bundle of the full repo, to use: git clone source_code.bundle --branch master\" > release/source_code/Readme.txt"
|
|
||||||
- mv linux release/
|
- mv linux release/
|
||||||
- shopt -s extglob
|
- shopt -s extglob
|
||||||
- rm -rf .g*
|
- rm -rf .g*
|
||||||
|
|
|
@ -7,10 +7,10 @@ mkdir -p linux/tools
|
||||||
cp scripts/find_interfaces.sh linux/tools/
|
cp scripts/find_interfaces.sh linux/tools/
|
||||||
cp scripts/steamclient_loader.sh linux/tools/
|
cp scripts/steamclient_loader.sh linux/tools/
|
||||||
../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
|
../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
|
||||||
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32
|
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32
|
||||||
g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect32
|
g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect32
|
||||||
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32_steamclient
|
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32_steamclient
|
||||||
../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
|
../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
|
||||||
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64
|
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64
|
||||||
g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect64
|
g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect64
|
||||||
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64_steamclient
|
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64_steamclient
|
||||||
|
|
|
@ -25,9 +25,7 @@
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <dirent.h>
|
# include <libudev.h>
|
||||||
# include <sys/stat.h>
|
|
||||||
# include <time.h>
|
|
||||||
#else
|
#else
|
||||||
# error "Unknown platform in gamepad.c"
|
# error "Unknown platform in gamepad.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,8 +60,6 @@ struct GAMEPAD_STATE {
|
||||||
char* device;
|
char* device;
|
||||||
int fd;
|
int fd;
|
||||||
int effect;
|
int effect;
|
||||||
double axis_min[ABS_MAX];
|
|
||||||
double axis_max[ABS_MAX];
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,8 +126,7 @@ void GamepadShutdown(void) {
|
||||||
/* no Win32 shutdown required */
|
/* no Win32 shutdown required */
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right, unsigned int rumble_length_ms) {
|
void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right) {
|
||||||
//TODO: rumble_length_ms
|
|
||||||
if ((STATE[gamepad].flags & FLAG_RUMBLE) != 0) {
|
if ((STATE[gamepad].flags & FLAG_RUMBLE) != 0) {
|
||||||
XINPUT_VIBRATION vib;
|
XINPUT_VIBRATION vib;
|
||||||
ZeroMemory(&vib, sizeof(vib));
|
ZeroMemory(&vib, sizeof(vib));
|
||||||
|
@ -142,103 +137,14 @@ void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right, unsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#define test_bit(nr, addr) \
|
|
||||||
(((1UL << ((nr) % (sizeof(long) * 8))) & ((addr)[(nr) / (sizeof(long) * 8)])) != 0)
|
|
||||||
#define NBITS(x) ((((x)-1)/(sizeof(long) * 8))+1)
|
|
||||||
|
|
||||||
|
/* UDev handles */
|
||||||
static int IsGamepad(int fd, char *namebuf, const size_t namebuflen)
|
static struct udev* UDEV = NULL;
|
||||||
{
|
static struct udev_monitor* MON = NULL;
|
||||||
struct input_id inpid;
|
|
||||||
//uint16_t *guid16 = (uint16_t *)guid->data;
|
|
||||||
|
|
||||||
/* When udev is enabled we only get joystick devices here, so there's no need to test them */
|
|
||||||
unsigned long evbit[NBITS(EV_MAX)] = { 0 };
|
|
||||||
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
|
||||||
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
|
|
||||||
|
|
||||||
if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
|
|
||||||
(ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
|
|
||||||
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) {
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
|
|
||||||
test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGNAME(namebuflen), namebuf) < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGID, &inpid) < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
|
||||||
|
|
||||||
//memset(guid->data, 0, sizeof(guid->data));
|
|
||||||
|
|
||||||
/* We only need 16 bits for each of these; space them out to fill 128. */
|
|
||||||
/* Byteswap so devices get same GUID on little/big endian platforms. */
|
|
||||||
/*
|
|
||||||
*guid16++ = SDL_SwapLE16(inpid.bustype);
|
|
||||||
*guid16++ = 0;
|
|
||||||
|
|
||||||
if (inpid.vendor && inpid.product) {
|
|
||||||
*guid16++ = SDL_SwapLE16(inpid.vendor);
|
|
||||||
*guid16++ = 0;
|
|
||||||
*guid16++ = SDL_SwapLE16(inpid.product);
|
|
||||||
*guid16++ = 0;
|
|
||||||
*guid16++ = SDL_SwapLE16(inpid.version);
|
|
||||||
*guid16++ = 0;
|
|
||||||
} else {
|
|
||||||
strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(namebuf, *guid)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GamepadAddDevice(const char* devPath);
|
static void GamepadAddDevice(const char* devPath);
|
||||||
static void GamepadRemoveDevice(const char* devPath);
|
static void GamepadRemoveDevice(const char* devPath);
|
||||||
|
|
||||||
static void GamepadDetect()
|
|
||||||
{
|
|
||||||
DIR *folder;
|
|
||||||
struct dirent *dent;
|
|
||||||
|
|
||||||
folder = opendir("/dev/input");
|
|
||||||
if (folder) {
|
|
||||||
while ((dent = readdir(folder))) {
|
|
||||||
int len = strlen(dent->d_name);
|
|
||||||
if (len > 5 && strncmp(dent->d_name, "event", 5) == 0) {
|
|
||||||
char path[PATH_MAX];
|
|
||||||
snprintf(path, sizeof(path), "/dev/input/%s", dent->d_name);
|
|
||||||
GamepadAddDevice(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i != GAMEPAD_COUNT; ++i) {
|
|
||||||
if ((STATE[i].flags & FLAG_CONNECTED) && STATE[i].device) {
|
|
||||||
struct stat sb;
|
|
||||||
//printf("%s\n", STATE[i].device);
|
|
||||||
if (stat(STATE[i].device, &sb) == -1) {
|
|
||||||
GamepadRemoveDevice(STATE[i].device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Helper to add a new device */
|
/* Helper to add a new device */
|
||||||
static void GamepadAddDevice(const char* devPath) {
|
static void GamepadAddDevice(const char* devPath) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -248,25 +154,11 @@ static void GamepadAddDevice(const char* devPath) {
|
||||||
if ((STATE[i].flags & FLAG_CONNECTED) == 0) {
|
if ((STATE[i].flags & FLAG_CONNECTED) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STATE[i].device && strcmp(devPath, STATE[i].device) == 0) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (i == GAMEPAD_COUNT) {
|
if (i == GAMEPAD_COUNT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd = open(devPath, O_RDWR, 0);
|
|
||||||
if (fd < 0) return;
|
|
||||||
char namebuf[128];
|
|
||||||
int is_gamepad = IsGamepad(fd, namebuf, sizeof (namebuf));
|
|
||||||
if (!is_gamepad) {
|
|
||||||
close(fd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy the device path */
|
/* copy the device path */
|
||||||
STATE[i].device = strdup(devPath);
|
STATE[i].device = strdup(devPath);
|
||||||
if (STATE[i].device == NULL) {
|
if (STATE[i].device == NULL) {
|
||||||
|
@ -276,87 +168,25 @@ static void GamepadAddDevice(const char* devPath) {
|
||||||
/* reset device state */
|
/* reset device state */
|
||||||
GamepadResetState((GAMEPAD_DEVICE)i);
|
GamepadResetState((GAMEPAD_DEVICE)i);
|
||||||
|
|
||||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
/* attempt to open the device in read-write mode, which we need fo rumble */
|
||||||
STATE[i].fd = fd;
|
STATE[i].fd = open(STATE[i].device, O_RDWR|O_NONBLOCK);
|
||||||
STATE[i].flags |= FLAG_CONNECTED;
|
if (STATE[i].fd != -1) {
|
||||||
|
STATE[i].flags = FLAG_CONNECTED|FLAG_RUMBLE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int controller = i;
|
/* attempt to open in read-only mode if access was denied */
|
||||||
{
|
if (errno == EACCES) {
|
||||||
int i, t;
|
STATE[i].fd = open(STATE[i].device, O_RDONLY|O_NONBLOCK);
|
||||||
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
if (STATE[i].fd != -1) {
|
||||||
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
|
STATE[i].flags = FLAG_CONNECTED;
|
||||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
return;
|
||||||
unsigned long ffbit[NBITS(FF_MAX)] = { 0 };
|
|
||||||
|
|
||||||
/* See if this device uses the new unified event API */
|
|
||||||
if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
|
|
||||||
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
|
|
||||||
(ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0)) {
|
|
||||||
|
|
||||||
/* Get the number of buttons, axes, and other thingamajigs */
|
|
||||||
for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
|
|
||||||
if (test_bit(i, keybit)) {
|
|
||||||
//printf("Joystick has button: 0x%x\n", i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < BTN_JOYSTICK; ++i) {
|
|
||||||
if (test_bit(i, keybit)) {
|
|
||||||
//printf("Joystick has button: 0x%x\n", i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < ABS_MAX; ++i) {
|
|
||||||
/* Skip hats */
|
|
||||||
if (i == ABS_HAT0X) {
|
|
||||||
i = ABS_HAT3Y;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (test_bit(i, absbit)) {
|
|
||||||
struct input_absinfo absinfo;
|
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
printf("Joystick has absolute axis: 0x%.2x\n", i);
|
|
||||||
printf("Values = { %d, %d, %d, %d, %d }\n",
|
|
||||||
absinfo.value, absinfo.minimum, absinfo.maximum,
|
|
||||||
absinfo.fuzz, absinfo.flat);
|
|
||||||
*/
|
|
||||||
STATE[controller].axis_min[i] = absinfo.minimum;
|
|
||||||
STATE[controller].axis_max[i] = absinfo.maximum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
|
|
||||||
if (test_bit(i, absbit) || test_bit(i + 1, absbit)) {
|
|
||||||
struct input_absinfo absinfo;
|
|
||||||
int hat_index = (i - ABS_HAT0X) / 2;
|
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
printf("Joystick has hat %d\n", hat_index);
|
|
||||||
printf("Values = { %d, %d, %d, %d, %d }\n",
|
|
||||||
absinfo.value, absinfo.minimum, absinfo.maximum,
|
|
||||||
absinfo.fuzz, absinfo.flat);
|
|
||||||
*/
|
|
||||||
//joystick->hwdata->hats_indices[joystick->nhats++] = hat_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (test_bit(REL_X, relbit) || test_bit(REL_Y, relbit)) {
|
|
||||||
//++joystick->nballs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) >= 0) {
|
/* could not open the device at all */
|
||||||
if (test_bit(FF_RUMBLE, ffbit)) {
|
free(STATE[i].device);
|
||||||
STATE[controller].flags |= FLAG_RUMBLE;
|
STATE[i].device = NULL;
|
||||||
}
|
|
||||||
if (test_bit(FF_SINE, ffbit)) {
|
|
||||||
//printf("sine\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper to remove a device */
|
/* Helper to remove a device */
|
||||||
|
@ -388,145 +218,159 @@ void GamepadInit(void) {
|
||||||
STATE[i].fd = STATE[i].effect = -1;
|
STATE[i].fd = STATE[i].effect = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadDetect();
|
/* open the udev handle */
|
||||||
|
UDEV = udev_new();
|
||||||
|
if (UDEV == NULL) {
|
||||||
|
/* FIXME: flag error? */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open monitoring device (safe to fail) */
|
||||||
|
MON = udev_monitor_new_from_netlink(UDEV, "udev");
|
||||||
|
/* FIXME: flag error if hot-plugging can't be supported? */
|
||||||
|
if (MON != NULL) {
|
||||||
|
udev_monitor_enable_receiving(MON);
|
||||||
|
udev_monitor_filter_add_match_subsystem_devtype(MON, "input", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enumerate joypad devices */
|
||||||
|
enu = udev_enumerate_new(UDEV);
|
||||||
|
udev_enumerate_add_match_subsystem(enu, "input");
|
||||||
|
udev_enumerate_scan_devices(enu);
|
||||||
|
devices = udev_enumerate_get_list_entry(enu);
|
||||||
|
|
||||||
|
udev_list_entry_foreach(item, devices) {
|
||||||
|
const char* name;
|
||||||
|
const char* sysPath;
|
||||||
|
const char* devPath;
|
||||||
|
struct udev_device* dev;
|
||||||
|
|
||||||
|
name = udev_list_entry_get_name(item);
|
||||||
|
dev = udev_device_new_from_syspath(UDEV, name);
|
||||||
|
sysPath = udev_device_get_syspath(dev);
|
||||||
|
devPath = udev_device_get_devnode(dev);
|
||||||
|
|
||||||
|
if (sysPath != NULL && devPath != NULL && strstr(sysPath, "/js") != 0) {
|
||||||
|
GamepadAddDevice(devPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
udev_device_unref(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
udev_enumerate_unref(enu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadUpdate(void) {
|
void GamepadUpdate(void) {
|
||||||
static unsigned long last = 0;
|
if (MON != NULL) {
|
||||||
unsigned long cur = time(NULL);
|
fd_set r;
|
||||||
|
struct timeval tv;
|
||||||
|
int fd = udev_monitor_get_fd(MON);
|
||||||
|
|
||||||
if (last + 2 < cur) {
|
/* set up a poll on the udev device */
|
||||||
GamepadDetect();
|
FD_ZERO(&r);
|
||||||
last = cur;
|
FD_SET(fd, &r);
|
||||||
|
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
select(fd + 1, &r, 0, 0, &tv);
|
||||||
|
|
||||||
|
/* test if we have a device change */
|
||||||
|
if (FD_ISSET(fd, &r)) {
|
||||||
|
struct udev_device* dev = udev_monitor_receive_device(MON);
|
||||||
|
if (dev) {
|
||||||
|
const char* devNode = udev_device_get_devnode(dev);
|
||||||
|
const char* sysPath = udev_device_get_syspath(dev);
|
||||||
|
const char* action = udev_device_get_action(dev);
|
||||||
|
sysPath = udev_device_get_syspath(dev);
|
||||||
|
action = udev_device_get_action(dev);
|
||||||
|
|
||||||
|
if (strstr(sysPath, "/js") != 0) {
|
||||||
|
if (strcmp(action, "remove") == 0) {
|
||||||
|
GamepadRemoveDevice(devNode);
|
||||||
|
} else if (strcmp(action, "add") == 0) {
|
||||||
|
GamepadAddDevice(devNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
udev_device_unref(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadUpdateCommon();
|
GamepadUpdateCommon();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adjust_values_trigger(double min, double max, double value)
|
|
||||||
{
|
|
||||||
return (((value + (0 - min)) / (max - min)) * 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int adjust_values_stick(double min, double max, double value)
|
|
||||||
{
|
|
||||||
return (((value + (0 - min)) / (max - min)) * (65535.0)) - 32768.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GamepadUpdateDevice(GAMEPAD_DEVICE gamepad) {
|
static void GamepadUpdateDevice(GAMEPAD_DEVICE gamepad) {
|
||||||
if (STATE[gamepad].flags & FLAG_CONNECTED) {
|
if (STATE[gamepad].flags & FLAG_CONNECTED) {
|
||||||
struct input_event events[32];
|
struct js_event je;
|
||||||
int i, len;
|
while (read(STATE[gamepad].fd, &je, sizeof(je)) > 0) {
|
||||||
int code;
|
int button;
|
||||||
|
switch (je.type) {
|
||||||
while ((len = read(STATE[gamepad].fd, events, (sizeof events))) > 0) {
|
case JS_EVENT_BUTTON:
|
||||||
len /= sizeof(events[0]);
|
/* determine which button the event is for */
|
||||||
for (i = 0; i < len; ++i) {
|
switch (je.number) {
|
||||||
int button = 0;
|
case 0: button = BUTTON_A; break;
|
||||||
code = events[i].code;
|
case 1: button = BUTTON_B; break;
|
||||||
switch (events[i].type) {
|
case 2: button = BUTTON_X; break;
|
||||||
case EV_KEY:
|
case 3: button = BUTTON_Y; break;
|
||||||
//printf("EV_KEY %i\n", code);
|
case 4: button = BUTTON_LEFT_SHOULDER; break;
|
||||||
switch (code) {
|
case 5: button = BUTTON_RIGHT_SHOULDER; break;
|
||||||
case BTN_SOUTH: button = BUTTON_A; break;
|
case 6: button = BUTTON_BACK; break;
|
||||||
case BTN_EAST: button = BUTTON_B; break;
|
case 7: button = BUTTON_START; break;
|
||||||
case BTN_NORTH: button = BUTTON_X; break;
|
case 8: button = 0; break; /* XBOX button */
|
||||||
case BTN_WEST: button = BUTTON_Y; break;
|
case 9: button = BUTTON_LEFT_THUMB; break;
|
||||||
case BTN_TL: button = BUTTON_LEFT_SHOULDER; break;
|
case 10: button = BUTTON_RIGHT_THUMB; break;
|
||||||
case BTN_TR: button = BUTTON_RIGHT_SHOULDER; break;
|
|
||||||
case BTN_SELECT: button = BUTTON_BACK; break;
|
|
||||||
case BTN_START: button = BUTTON_START; break;
|
|
||||||
case BTN_MODE: button = 0; break; /* XBOX button */
|
|
||||||
case BTN_THUMBL: button = BUTTON_LEFT_THUMB; break;
|
|
||||||
case BTN_THUMBR: button = BUTTON_RIGHT_THUMB; break;
|
|
||||||
default: button = 0; break;
|
default: button = 0; break;
|
||||||
}
|
}
|
||||||
if (events[i].value) {
|
|
||||||
|
/* set or unset the button */
|
||||||
|
if (je.value) {
|
||||||
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(button);
|
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(button);
|
||||||
} else {
|
} else {
|
||||||
STATE[gamepad].bCurrent ^= BUTTON_TO_FLAG(button);
|
STATE[gamepad].bCurrent ^= BUTTON_TO_FLAG(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EV_ABS:
|
case JS_EVENT_AXIS:
|
||||||
switch (code) {
|
/* normalize and store the axis */
|
||||||
case ABS_HAT0X:
|
switch (je.number) {
|
||||||
case ABS_HAT0Y:
|
case 0: STATE[gamepad].stick[STICK_LEFT].x = je.value; break;
|
||||||
case ABS_HAT1X:
|
case 1: STATE[gamepad].stick[STICK_LEFT].y = -je.value; break;
|
||||||
case ABS_HAT1Y:
|
case 2: STATE[gamepad].trigger[TRIGGER_LEFT].value = (je.value + 32768) >> 8; break;
|
||||||
case ABS_HAT2X:
|
case 3: STATE[gamepad].stick[STICK_RIGHT].x = je.value; break;
|
||||||
case ABS_HAT2Y:
|
case 4: STATE[gamepad].stick[STICK_RIGHT].y = -je.value; break;
|
||||||
case ABS_HAT3X:
|
case 5: STATE[gamepad].trigger[TRIGGER_RIGHT].value = (je.value + 32768) >> 8; break;
|
||||||
case ABS_HAT3Y:
|
case 6:
|
||||||
//code -= ABS_HAT0X;
|
if (je.value == -32767) {
|
||||||
//printf("ABS_HAT %i\n", code);
|
|
||||||
switch(code) {
|
|
||||||
case ABS_HAT0X:
|
|
||||||
if (events[i].value < 0) {
|
|
||||||
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_LEFT);
|
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_LEFT);
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
||||||
} else if (events[i].value > 0) {
|
} else if (je.value == 32767) {
|
||||||
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_LEFT);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_LEFT);
|
||||||
} else {
|
} else {
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_LEFT) & ~BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_LEFT) & ~BUTTON_TO_FLAG(BUTTON_DPAD_RIGHT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ABS_HAT0Y:
|
case 7:
|
||||||
if (events[i].value < 0) {
|
if (je.value == -32767) {
|
||||||
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_UP);
|
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_UP);
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
||||||
} else if (events[i].value > 0) {
|
} else if (je.value == 32767) {
|
||||||
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
STATE[gamepad].bCurrent |= BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_UP);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_UP);
|
||||||
} else {
|
} else {
|
||||||
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_UP) & ~BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
STATE[gamepad].bCurrent &= ~BUTTON_TO_FLAG(BUTTON_DPAD_UP) & ~BUTTON_TO_FLAG(BUTTON_DPAD_DOWN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//printf("EV_ABS %i %i\n", code, events[i].value);
|
|
||||||
if (code == ABS_Z || code == ABS_RZ) {
|
|
||||||
int value = adjust_values_trigger(STATE[gamepad].axis_min[code], STATE[gamepad].axis_max[code], events[i].value);
|
|
||||||
switch(code) {
|
|
||||||
case ABS_Z : STATE[gamepad].trigger[TRIGGER_LEFT].value = value; break;
|
|
||||||
case ABS_RZ: STATE[gamepad].trigger[TRIGGER_RIGHT].value = value; break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int value = adjust_values_stick(STATE[gamepad].axis_min[code], STATE[gamepad].axis_max[code], events[i].value);
|
|
||||||
switch(code) {
|
|
||||||
case ABS_X : STATE[gamepad].stick[STICK_LEFT].x = value; break;
|
|
||||||
case ABS_Y : STATE[gamepad].stick[STICK_LEFT].y = -value; break;
|
|
||||||
case ABS_RX: STATE[gamepad].stick[STICK_RIGHT].x = value; break;
|
|
||||||
case ABS_RY: STATE[gamepad].stick[STICK_RIGHT].y = -value; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EV_REL:
|
|
||||||
switch (code) {
|
|
||||||
case REL_X:
|
|
||||||
case REL_Y:
|
|
||||||
code -= REL_X;
|
|
||||||
//printf("EV_REL %i %i\n", code, events[i].value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case EV_SYN:
|
|
||||||
switch (code) {
|
|
||||||
case SYN_DROPPED :
|
|
||||||
//printf("Event SYN_DROPPED detected\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,6 +378,10 @@ static void GamepadUpdateDevice(GAMEPAD_DEVICE gamepad) {
|
||||||
void GamepadShutdown(void) {
|
void GamepadShutdown(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* cleanup udev */
|
||||||
|
udev_monitor_unref(MON);
|
||||||
|
udev_unref(UDEV);
|
||||||
|
|
||||||
/* cleanup devices */
|
/* cleanup devices */
|
||||||
for (i = 0; i != GAMEPAD_COUNT; ++i) {
|
for (i = 0; i != GAMEPAD_COUNT; ++i) {
|
||||||
if (STATE[i].device != NULL) {
|
if (STATE[i].device != NULL) {
|
||||||
|
@ -546,17 +394,33 @@ void GamepadShutdown(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right, unsigned int rumble_length_ms) {
|
void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right) {
|
||||||
if (STATE[gamepad].fd != -1) {
|
if (STATE[gamepad].fd != -1) {
|
||||||
struct input_event play;
|
struct input_event play;
|
||||||
|
|
||||||
|
/* delete any existing effect */
|
||||||
|
if (STATE[gamepad].effect != -1) {
|
||||||
|
/* stop the effect */
|
||||||
|
play.type = EV_FF;
|
||||||
|
play.code = STATE[gamepad].effect;
|
||||||
|
play.value = 0;
|
||||||
|
|
||||||
|
write(STATE[gamepad].fd, (const void*)&play, sizeof(play));
|
||||||
|
|
||||||
|
/* delete the effect */
|
||||||
|
ioctl(STATE[gamepad].fd, EVIOCRMFF, STATE[gamepad].effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if rumble parameters are non-zero, start the new effect */
|
||||||
|
if (left != 0.f || right != 0.f) {
|
||||||
struct ff_effect ff;
|
struct ff_effect ff;
|
||||||
|
|
||||||
/* define an effect for this rumble setting */
|
/* define an effect for this rumble setting */
|
||||||
ff.type = FF_RUMBLE;
|
ff.type = FF_RUMBLE;
|
||||||
ff.id = STATE[gamepad].effect;
|
ff.id = -1;
|
||||||
ff.u.rumble.strong_magnitude = (unsigned short)(left * 65535);
|
ff.u.rumble.strong_magnitude = (unsigned short)(left * 65535);
|
||||||
ff.u.rumble.weak_magnitude = (unsigned short)(right * 65535);
|
ff.u.rumble.weak_magnitude = (unsigned short)(right * 65535);
|
||||||
ff.replay.length = rumble_length_ms;
|
ff.replay.length = 5;
|
||||||
ff.replay.delay = 0;
|
ff.replay.delay = 0;
|
||||||
|
|
||||||
/* upload the effect */
|
/* upload the effect */
|
||||||
|
@ -572,6 +436,7 @@ void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right, unsigned
|
||||||
write(STATE[gamepad].fd, (const void*)&play, sizeof(play));
|
write(STATE[gamepad].fd, (const void*)&play, sizeof(play));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else /* !defined(_WIN32) && !defined(__linux__) */
|
#else /* !defined(_WIN32) && !defined(__linux__) */
|
||||||
|
|
||||||
|
|
|
@ -232,9 +232,8 @@ GAMEPAD_API GAMEPAD_BOOL GamepadTriggerReleased(GAMEPAD_DEVICE device, GAMEPAD_T
|
||||||
* \param device The device to update.
|
* \param device The device to update.
|
||||||
* \param left Left motor strengh (0 to 1).
|
* \param left Left motor strengh (0 to 1).
|
||||||
* \param right Right motor strengh (0 to 1).
|
* \param right Right motor strengh (0 to 1).
|
||||||
* \param rumble_length_ms rumble time in ms (0 = unlimited).
|
|
||||||
*/
|
*/
|
||||||
GAMEPAD_API void GamepadSetRumble(GAMEPAD_DEVICE device, float left, float right, unsigned int rumble_length_ms);
|
GAMEPAD_API void GamepadSetRumble(GAMEPAD_DEVICE device, float left, float right);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the position of an analog stick as raw values.
|
* Query the position of an analog stick as raw values.
|
||||||
|
|
|
@ -193,15 +193,6 @@ std::string get_lib_path() {
|
||||||
|
|
||||||
std::string get_full_program_path()
|
std::string get_full_program_path()
|
||||||
{
|
{
|
||||||
std::string env_program_path = get_env_variable("SteamAppPath");
|
|
||||||
if (env_program_path.length()) {
|
|
||||||
if (env_program_path.back() != PATH_SEPARATOR[0]) {
|
|
||||||
env_program_path = env_program_path.append(PATH_SEPARATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return env_program_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string program_path;
|
std::string program_path;
|
||||||
#if defined(STEAM_WIN32)
|
#if defined(STEAM_WIN32)
|
||||||
char DllPath[MAX_PATH] = {0};
|
char DllPath[MAX_PATH] = {0};
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#define CLIENT_HSTEAMUSER 12
|
#define CLIENT_HSTEAMUSER 12
|
||||||
#define SERVER_HSTEAMUSER 13
|
#define SERVER_HSTEAMUSER 13
|
||||||
|
|
||||||
|
#define CLIENT_STEAM_PIPE 5
|
||||||
|
#define SERVER_STEAM_PIPE 6
|
||||||
|
|
||||||
#define DEFAULT_NAME "Goldberg"
|
#define DEFAULT_NAME "Goldberg"
|
||||||
#define PROGRAM_NAME "Goldberg SteamEmu"
|
#define PROGRAM_NAME "Goldberg SteamEmu"
|
||||||
#define DEFAULT_LANGUAGE "english"
|
#define DEFAULT_LANGUAGE "english"
|
||||||
|
|
69
dll/dll.cpp
69
dll/dll.cpp
|
@ -15,7 +15,6 @@
|
||||||
License along with the Goldberg Emulator; if not, see
|
License along with the Goldberg Emulator; if not, see
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#define STEAM_API_FUNCTIONS_IMPL
|
|
||||||
#include "dll.h"
|
#include "dll.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,17 +203,14 @@ STEAMAPI_API void * S_CALLTYPE SteamInternal_ContextInit( void *pContextInitData
|
||||||
//steam_api.h
|
//steam_api.h
|
||||||
// SteamAPI_Init must be called before using any other API functions. If it fails, an
|
// SteamAPI_Init must be called before using any other API functions. If it fails, an
|
||||||
// error message will be output to the debugger (or stderr) with further information.
|
// error message will be output to the debugger (or stderr) with further information.
|
||||||
static HSteamPipe user_steam_pipe;
|
|
||||||
STEAMAPI_API bool S_CALLTYPE SteamAPI_Init()
|
STEAMAPI_API bool S_CALLTYPE SteamAPI_Init()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamAPI_Init called\n");
|
PRINT_DEBUG("SteamAPI_Init called\n");
|
||||||
if (user_steam_pipe) return true;
|
|
||||||
#ifdef EMU_EXPERIMENTAL_BUILD
|
#ifdef EMU_EXPERIMENTAL_BUILD
|
||||||
crack_SteamAPI_Init();
|
crack_SteamAPI_Init();
|
||||||
#endif
|
#endif
|
||||||
load_old_interface_versions();
|
load_old_interface_versions();
|
||||||
user_steam_pipe = get_steam_client()->CreateSteamPipe();
|
get_steam_client()->userLogIn();
|
||||||
get_steam_client()->ConnectToGlobalUser(user_steam_pipe);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +226,6 @@ STEAMAPI_API void S_CALLTYPE SteamAPI_Shutdown()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamAPI_Shutdown\n");
|
PRINT_DEBUG("SteamAPI_Shutdown\n");
|
||||||
get_steam_client()->clientShutdown();
|
get_steam_client()->clientShutdown();
|
||||||
get_steam_client()->BReleaseSteamPipe(user_steam_pipe);
|
|
||||||
user_steam_pipe = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SteamAPI_RestartAppIfNecessary ensures that your executable was launched through Steam.
|
// SteamAPI_RestartAppIfNecessary ensures that your executable was launched through Steam.
|
||||||
|
@ -422,7 +416,8 @@ STEAMAPI_API const char *SteamAPI_GetSteamInstallPath()
|
||||||
STEAMAPI_API HSteamPipe SteamAPI_GetHSteamPipe()
|
STEAMAPI_API HSteamPipe SteamAPI_GetHSteamPipe()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamAPI_GetHSteamPipe\n");
|
PRINT_DEBUG("SteamAPI_GetHSteamPipe\n");
|
||||||
return user_steam_pipe;
|
if (!get_steam_client()->user_logged_in) return 0;
|
||||||
|
return CLIENT_STEAM_PIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks
|
// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks
|
||||||
|
@ -489,11 +484,11 @@ STEAMAPI_API void * S_CALLTYPE SteamGameServerInternal_CreateInterface( const ch
|
||||||
return SteamInternal_CreateInterface(ver);
|
return SteamInternal_CreateInterface(ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HSteamPipe server_steam_pipe;
|
|
||||||
STEAMAPI_API HSteamPipe S_CALLTYPE SteamGameServer_GetHSteamPipe()
|
STEAMAPI_API HSteamPipe S_CALLTYPE SteamGameServer_GetHSteamPipe()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamGameServer_GetHSteamPipe\n");
|
PRINT_DEBUG("SteamGameServer_GetHSteamPipe\n");
|
||||||
return server_steam_pipe;
|
if (!get_steam_client()->server_init) return 0;
|
||||||
|
return SERVER_STEAM_PIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API HSteamUser S_CALLTYPE SteamGameServer_GetHSteamUser()
|
STEAMAPI_API HSteamUser S_CALLTYPE SteamGameServer_GetHSteamUser()
|
||||||
|
@ -538,12 +533,10 @@ STEAMAPI_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamInternal_GameServer_Init %u %hu %hu %hu %u %s\n", unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
|
PRINT_DEBUG("SteamInternal_GameServer_Init %u %hu %hu %hu %u %s\n", unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
|
||||||
load_old_interface_versions();
|
load_old_interface_versions();
|
||||||
get_steam_client()->CreateLocalUser(&server_steam_pipe, k_EAccountTypeGameServer);
|
get_steam_client()->serverInit();
|
||||||
//g_pSteamClientGameServer is only used in pre 1.37 (where the interface versions are not provided by the game)
|
//g_pSteamClientGameServer is only used in pre 1.37 (where the interface versions are not provided by the game)
|
||||||
g_pSteamClientGameServer = SteamGameServerClient();
|
g_pSteamClientGameServer = SteamGameServerClient();
|
||||||
uint32 unFlags = 0;
|
return get_steam_client()->steam_gameserver->InitGameServer(unIP, usGamePort, usQueryPort, eServerMode, 0, pchVersionString);
|
||||||
if (eServerMode == eServerModeAuthenticationAndSecure) unFlags = k_unServerFlagSecure;
|
|
||||||
return get_steam_client()->steam_gameserver->InitGameServer(unIP, usGamePort, usQueryPort, unFlags, 0, pchVersionString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//SteamGameServer004 and before:
|
//SteamGameServer004 and before:
|
||||||
|
@ -582,9 +575,7 @@ STEAMAPI_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16
|
||||||
STEAMAPI_API void SteamGameServer_Shutdown()
|
STEAMAPI_API void SteamGameServer_Shutdown()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SteamGameServer_Shutdown\n");
|
PRINT_DEBUG("SteamGameServer_Shutdown\n");
|
||||||
get_steam_client()->serverShutdown();
|
get_steam_clientserver_old()->serverShutdown();
|
||||||
get_steam_client()->BReleaseSteamPipe(server_steam_pipe);
|
|
||||||
server_steam_pipe = 0;
|
|
||||||
g_pSteamClientGameServer = NULL; //TODO: check if this actually gets nulled when SteamGameServer_Shutdown is called
|
g_pSteamClientGameServer = NULL; //TODO: check if this actually gets nulled when SteamGameServer_Shutdown is called
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,26 +752,15 @@ STEAMCLIENT_API bool Steam_BGetCallback( HSteamPipe hSteamPipe, CallbackMsg_t *p
|
||||||
PRINT_DEBUG("%s %i\n", __FUNCTION__, hSteamPipe);
|
PRINT_DEBUG("%s %i\n", __FUNCTION__, hSteamPipe);
|
||||||
std::queue<struct cb_data> *q = NULL;
|
std::queue<struct cb_data> *q = NULL;
|
||||||
HSteamUser m_hSteamUser = 0;
|
HSteamUser m_hSteamUser = 0;
|
||||||
Steam_Client *steam_client = get_steam_client();
|
get_steam_client()->callback_results_server->setCbAll(&cb_add_queue_server);
|
||||||
steam_client->callback_results_server->setCbAll(&cb_add_queue_server);
|
get_steam_client()->callback_results_client->setCbAll(&cb_add_queue_client);
|
||||||
steam_client->callback_results_client->setCbAll(&cb_add_queue_client);
|
get_steam_client()->RunCallbacks(true, true);
|
||||||
steam_client->RunCallbacks(true, true);
|
if (hSteamPipe == SERVER_STEAM_PIPE) {
|
||||||
if (!steam_client->steamclient_server_inited) {
|
|
||||||
while(!server_cb.empty()) server_cb.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!steam_client->steam_pipes.count(hSteamPipe)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::SERVER) {
|
|
||||||
q = &server_cb;
|
q = &server_cb;
|
||||||
m_hSteamUser = SERVER_HSTEAMUSER;
|
m_hSteamUser = SERVER_HSTEAMUSER;
|
||||||
} else if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::CLIENT) {
|
} else {
|
||||||
q = &client_cb;
|
q = &client_cb;
|
||||||
m_hSteamUser = CLIENT_HSTEAMUSER;
|
m_hSteamUser = CLIENT_HSTEAMUSER;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (q->empty()) return false;
|
if (q->empty()) return false;
|
||||||
|
@ -800,17 +780,10 @@ STEAMCLIENT_API void Steam_FreeLastCallback( HSteamPipe hSteamPipe )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("%s %i\n", __FUNCTION__, hSteamPipe);
|
PRINT_DEBUG("%s %i\n", __FUNCTION__, hSteamPipe);
|
||||||
std::queue<struct cb_data> *q = NULL;
|
std::queue<struct cb_data> *q = NULL;
|
||||||
Steam_Client *steam_client = get_steam_client();
|
if (hSteamPipe == SERVER_STEAM_PIPE) {
|
||||||
if (!steam_client->steam_pipes.count(hSteamPipe)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::SERVER) {
|
|
||||||
q = &server_cb;
|
q = &server_cb;
|
||||||
} else if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::CLIENT) {
|
|
||||||
q = &client_cb;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
q = &client_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!q->empty()) q->pop();
|
if (!q->empty()) q->pop();
|
||||||
|
@ -819,17 +792,11 @@ STEAMCLIENT_API void Steam_FreeLastCallback( HSteamPipe hSteamPipe )
|
||||||
STEAMCLIENT_API bool Steam_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed )
|
STEAMCLIENT_API bool Steam_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_GetAPICallResult %i %llu %i %i\n", hSteamPipe, hSteamAPICall, cubCallback, iCallbackExpected);
|
PRINT_DEBUG("Steam_GetAPICallResult %i %llu %i %i\n", hSteamPipe, hSteamAPICall, cubCallback, iCallbackExpected);
|
||||||
Steam_Client *steam_client = get_steam_client();
|
if (!hSteamPipe) return false;
|
||||||
if (!steam_client->steam_pipes.count(hSteamPipe)) {
|
if (hSteamPipe == SERVER_STEAM_PIPE) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::SERVER) {
|
|
||||||
return get_steam_client()->steam_gameserver_utils->GetAPICallResult(hSteamAPICall, pCallback, cubCallback, iCallbackExpected, pbFailed);
|
return get_steam_client()->steam_gameserver_utils->GetAPICallResult(hSteamAPICall, pCallback, cubCallback, iCallbackExpected, pbFailed);
|
||||||
} else if (steam_client->steam_pipes[hSteamPipe] == Steam_Pipe::CLIENT) {
|
|
||||||
return get_steam_client()->steam_utils->GetAPICallResult(hSteamAPICall, pCallback, cubCallback, iCallbackExpected, pbFailed);
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return get_steam_client()->steam_utils->GetAPICallResult(hSteamAPICall, pCallback, cubCallback, iCallbackExpected, pbFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,25 +18,20 @@
|
||||||
#include "steam_client.h"
|
#include "steam_client.h"
|
||||||
#include "settings_parser.h"
|
#include "settings_parser.h"
|
||||||
|
|
||||||
#include <condition_variable>
|
|
||||||
|
|
||||||
static std::condition_variable kill_background_thread_cv;
|
|
||||||
static std::atomic_bool kill_background_thread;
|
|
||||||
static void background_thread(Steam_Client *client)
|
static void background_thread(Steam_Client *client)
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("background thread starting\n");
|
PRINT_DEBUG("background thread starting\n");
|
||||||
std::mutex mtx;
|
|
||||||
std::unique_lock<std::mutex> lck(mtx);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (kill_background_thread || kill_background_thread_cv.wait_for(lck, std::chrono::seconds(1)) != std::cv_status::timeout) {
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
if (kill_background_thread) {
|
global_mutex.lock();
|
||||||
|
if (!client->network->isAlive()) {
|
||||||
|
global_mutex.unlock();
|
||||||
|
//delete network;
|
||||||
PRINT_DEBUG("background thread exit\n");
|
PRINT_DEBUG("background thread exit\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
global_mutex.lock();
|
|
||||||
PRINT_DEBUG("background thread run\n");
|
PRINT_DEBUG("background thread run\n");
|
||||||
client->network->Run();
|
client->network->Run();
|
||||||
client->steam_matchmaking->RunBackground();
|
client->steam_matchmaking->RunBackground();
|
||||||
|
@ -159,38 +154,23 @@ void Steam_Client::setAppID(uint32 appid)
|
||||||
HSteamPipe Steam_Client::CreateSteamPipe()
|
HSteamPipe Steam_Client::CreateSteamPipe()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("CreateSteamPipe\n");
|
PRINT_DEBUG("CreateSteamPipe\n");
|
||||||
HSteamPipe pipe = steam_pipe_counter++;
|
return CLIENT_STEAM_PIPE;
|
||||||
PRINT_DEBUG("creating pipe %i\n", pipe);
|
|
||||||
|
|
||||||
steam_pipes[pipe] = Steam_Pipe::NO_USER;
|
|
||||||
return pipe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Releases a previously created communications pipe
|
// Releases a previously created communications pipe
|
||||||
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
|
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
|
||||||
bool Steam_Client::BReleaseSteamPipe( HSteamPipe hSteamPipe )
|
bool Steam_Client::BReleaseSteamPipe( HSteamPipe hSteamPipe )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("BReleaseSteamPipe %i\n", hSteamPipe);
|
PRINT_DEBUG("BReleaseSteamPipe\n");
|
||||||
if (steam_pipes.count(hSteamPipe)) {
|
|
||||||
steam_pipes.erase(hSteamPipe);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// connects to an existing global user, failing if none exists
|
// connects to an existing global user, failing if none exists
|
||||||
// used by the game to coordinate with the steamUI
|
// used by the game to coordinate with the steamUI
|
||||||
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
|
// NOT THREADSAFE - ensure that no other threads are accessing Steamworks API when calling
|
||||||
HSteamUser Steam_Client::ConnectToGlobalUser( HSteamPipe hSteamPipe )
|
HSteamUser Steam_Client::ConnectToGlobalUser( HSteamPipe hSteamPipe )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("ConnectToGlobalUser %i\n", hSteamPipe);
|
PRINT_DEBUG("ConnectToGlobalUser\n");
|
||||||
if (!steam_pipes.count(hSteamPipe)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
userLogIn();
|
|
||||||
steam_pipes[hSteamPipe] = Steam_Pipe::CLIENT;
|
|
||||||
return CLIENT_HSTEAMUSER;
|
return CLIENT_HSTEAMUSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,19 +179,13 @@ HSteamUser Steam_Client::ConnectToGlobalUser( HSteamPipe hSteamPipe )
|
||||||
HSteamUser Steam_Client::CreateLocalUser( HSteamPipe *phSteamPipe, EAccountType eAccountType )
|
HSteamUser Steam_Client::CreateLocalUser( HSteamPipe *phSteamPipe, EAccountType eAccountType )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("CreateLocalUser %p %i\n", phSteamPipe, eAccountType);
|
PRINT_DEBUG("CreateLocalUser %p %i\n", phSteamPipe, eAccountType);
|
||||||
//if (eAccountType == k_EAccountTypeIndividual) {
|
if (eAccountType == k_EAccountTypeIndividual) {
|
||||||
//Is this actually used?
|
if (phSteamPipe) *phSteamPipe = CLIENT_STEAM_PIPE;
|
||||||
//if (phSteamPipe) *phSteamPipe = CLIENT_STEAM_PIPE;
|
return CLIENT_HSTEAMUSER;
|
||||||
//return CLIENT_HSTEAMUSER;
|
} else {
|
||||||
//} else { //k_EAccountTypeGameServer
|
if (phSteamPipe) *phSteamPipe = SERVER_STEAM_PIPE;
|
||||||
serverInit();
|
|
||||||
|
|
||||||
HSteamPipe pipe = CreateSteamPipe();
|
|
||||||
if (phSteamPipe) *phSteamPipe = pipe;
|
|
||||||
steam_pipes[pipe] = Steam_Pipe::SERVER;
|
|
||||||
steamclient_server_inited = true;
|
|
||||||
return SERVER_HSTEAMUSER;
|
return SERVER_HSTEAMUSER;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HSteamUser Steam_Client::CreateLocalUser( HSteamPipe *phSteamPipe )
|
HSteamUser Steam_Client::CreateLocalUser( HSteamPipe *phSteamPipe )
|
||||||
|
@ -224,16 +198,13 @@ HSteamUser Steam_Client::CreateLocalUser( HSteamPipe *phSteamPipe )
|
||||||
void Steam_Client::ReleaseUser( HSteamPipe hSteamPipe, HSteamUser hUser )
|
void Steam_Client::ReleaseUser( HSteamPipe hSteamPipe, HSteamUser hUser )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("ReleaseUser\n");
|
PRINT_DEBUG("ReleaseUser\n");
|
||||||
if (hUser == SERVER_HSTEAMUSER && steam_pipes.count(hSteamPipe)) {
|
|
||||||
steamclient_server_inited = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieves the ISteamUser interface associated with the handle
|
// retrieves the ISteamUser interface associated with the handle
|
||||||
ISteamUser *Steam_Client::GetISteamUser( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamUser *Steam_Client::GetISteamUser( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamUser %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamUser %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "SteamUser009") == 0) {
|
if (strcmp(pchVersion, "SteamUser009") == 0) {
|
||||||
return (ISteamUser *)(void *)(ISteamUser009 *)steam_user;
|
return (ISteamUser *)(void *)(ISteamUser009 *)steam_user;
|
||||||
|
@ -270,7 +241,7 @@ ISteamUser *Steam_Client::GetISteamUser( HSteamUser hSteamUser, HSteamPipe hStea
|
||||||
ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamGameServer %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamGameServer %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "SteamGameServer005") == 0) {
|
if (strcmp(pchVersion, "SteamGameServer005") == 0) {
|
||||||
return (ISteamGameServer *)(void *)(ISteamGameServer005 *)steam_gameserver;
|
return (ISteamGameServer *)(void *)(ISteamGameServer005 *)steam_gameserver;
|
||||||
|
@ -313,7 +284,7 @@ void Steam_Client::SetLocalIPBinding( const SteamIPAddress_t &unIP, uint16 usPor
|
||||||
ISteamFriends *Steam_Client::GetISteamFriends( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamFriends *Steam_Client::GetISteamFriends( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamFriends %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamFriends %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "SteamFriends004") == 0) {
|
if (strcmp(pchVersion, "SteamFriends004") == 0) {
|
||||||
return (ISteamFriends *)(void *)(ISteamFriends004 *)steam_friends;
|
return (ISteamFriends *)(void *)(ISteamFriends004 *)steam_friends;
|
||||||
|
@ -354,11 +325,11 @@ ISteamFriends *Steam_Client::GetISteamFriends( HSteamUser hSteamUser, HSteamPipe
|
||||||
ISteamUtils *Steam_Client::GetISteamUtils( HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamUtils *Steam_Client::GetISteamUtils( HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamUtils %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamUtils %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe)) return NULL;
|
if (!hSteamPipe) return NULL;
|
||||||
|
|
||||||
Steam_Utils *steam_utils_temp;
|
Steam_Utils *steam_utils_temp;
|
||||||
|
|
||||||
if (steam_pipes[hSteamPipe] == Steam_Pipe::SERVER) {
|
if (hSteamPipe == SERVER_STEAM_PIPE) {
|
||||||
steam_utils_temp = steam_gameserver_utils;
|
steam_utils_temp = steam_gameserver_utils;
|
||||||
} else {
|
} else {
|
||||||
steam_utils_temp = steam_utils;
|
steam_utils_temp = steam_utils;
|
||||||
|
@ -391,7 +362,7 @@ ISteamUtils *Steam_Client::GetISteamUtils( HSteamPipe hSteamPipe, const char *pc
|
||||||
ISteamMatchmaking *Steam_Client::GetISteamMatchmaking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamMatchmaking *Steam_Client::GetISteamMatchmaking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamMatchmaking %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamMatchmaking %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "SteamMatchMaking001") == 0) {
|
if (strcmp(pchVersion, "SteamMatchMaking001") == 0) {
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -428,7 +399,7 @@ ISteamMatchmaking *Steam_Client::GetISteamMatchmaking( HSteamUser hSteamUser, HS
|
||||||
ISteamMatchmakingServers *Steam_Client::GetISteamMatchmakingServers( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamMatchmakingServers *Steam_Client::GetISteamMatchmakingServers( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamMatchmakingServers %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamMatchmakingServers %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
return steam_matchmaking_servers;
|
return steam_matchmaking_servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +407,7 @@ ISteamMatchmakingServers *Steam_Client::GetISteamMatchmakingServers( HSteamUser
|
||||||
void *Steam_Client::GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
void *Steam_Client::GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamGenericInterface %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamGenericInterface %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe)) return NULL;
|
if (!hSteamPipe) return NULL;
|
||||||
|
|
||||||
bool server = false;
|
bool server = false;
|
||||||
if (hSteamUser == SERVER_HSTEAMUSER) {
|
if (hSteamUser == SERVER_HSTEAMUSER) {
|
||||||
|
@ -565,7 +536,7 @@ void *Steam_Client::GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe
|
||||||
ISteamUserStats *Steam_Client::GetISteamUserStats( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamUserStats *Steam_Client::GetISteamUserStats( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamUserStats %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamUserStats %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "STEAMUSERSTATS_INTERFACE_VERSION001") == 0) {
|
if (strcmp(pchVersion, "STEAMUSERSTATS_INTERFACE_VERSION001") == 0) {
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -602,7 +573,7 @@ ISteamUserStats *Steam_Client::GetISteamUserStats( HSteamUser hSteamUser, HSteam
|
||||||
ISteamGameServerStats *Steam_Client::GetISteamGameServerStats( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamGameServerStats *Steam_Client::GetISteamGameServerStats( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamGameServerStats %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamGameServerStats %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_gameserverstats;
|
return steam_gameserverstats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +581,7 @@ ISteamGameServerStats *Steam_Client::GetISteamGameServerStats( HSteamUser hSteam
|
||||||
ISteamApps *Steam_Client::GetISteamApps( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamApps *Steam_Client::GetISteamApps( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamApps %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamApps %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
if (hSteamUser == SERVER_HSTEAMUSER) {
|
if (hSteamUser == SERVER_HSTEAMUSER) {
|
||||||
return steam_gameserver_apps;
|
return steam_gameserver_apps;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +593,7 @@ ISteamApps *Steam_Client::GetISteamApps( HSteamUser hSteamUser, HSteamPipe hStea
|
||||||
ISteamNetworking *Steam_Client::GetISteamNetworking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamNetworking *Steam_Client::GetISteamNetworking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamNetworking %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamNetworking %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
Steam_Networking *steam_networking_temp;
|
Steam_Networking *steam_networking_temp;
|
||||||
|
|
||||||
|
@ -655,7 +626,7 @@ ISteamNetworking *Steam_Client::GetISteamNetworking( HSteamUser hSteamUser, HSte
|
||||||
ISteamRemoteStorage *Steam_Client::GetISteamRemoteStorage( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamRemoteStorage *Steam_Client::GetISteamRemoteStorage( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamRemoteStorage %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamRemoteStorage %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "STEAMREMOTESTORAGE_INTERFACE_VERSION001") == 0) {
|
if (strcmp(pchVersion, "STEAMREMOTESTORAGE_INTERFACE_VERSION001") == 0) {
|
||||||
return (ISteamRemoteStorage *)(void *)(ISteamRemoteStorage001 *)steam_remote_storage;
|
return (ISteamRemoteStorage *)(void *)(ISteamRemoteStorage001 *)steam_remote_storage;
|
||||||
|
@ -696,7 +667,7 @@ ISteamRemoteStorage *Steam_Client::GetISteamRemoteStorage( HSteamUser hSteamuser
|
||||||
ISteamScreenshots *Steam_Client::GetISteamScreenshots( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamScreenshots *Steam_Client::GetISteamScreenshots( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamScreenshots %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamScreenshots %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_screenshots;
|
return steam_screenshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,25 +701,14 @@ void Steam_Client::SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction
|
||||||
bool Steam_Client::BShutdownIfAllPipesClosed()
|
bool Steam_Client::BShutdownIfAllPipesClosed()
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("BShutdownIfAllPipesClosed\n");
|
PRINT_DEBUG("BShutdownIfAllPipesClosed\n");
|
||||||
if (!steam_pipes.size()) {
|
|
||||||
if (background_keepalive.joinable()) {
|
|
||||||
kill_background_thread = true;
|
|
||||||
kill_background_thread_cv.notify_one();
|
|
||||||
background_keepalive.join();
|
|
||||||
}
|
|
||||||
|
|
||||||
PRINT_DEBUG("all pipes closed\n");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expose HTTP interface
|
// Expose HTTP interface
|
||||||
ISteamHTTP *Steam_Client::GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamHTTP *Steam_Client::GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamHTTP %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamHTTP %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
if (hSteamuser == SERVER_HSTEAMUSER) {
|
if (hSteamuser == SERVER_HSTEAMUSER) {
|
||||||
return steam_gameserver_http;
|
return steam_gameserver_http;
|
||||||
}
|
}
|
||||||
|
@ -760,14 +720,14 @@ ISteamHTTP *Steam_Client::GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hStea
|
||||||
void *Steam_Client::DEPRECATED_GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
void *Steam_Client::DEPRECATED_GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("DEPRECATED_GetISteamUnifiedMessages %s\n", pchVersion);
|
PRINT_DEBUG("DEPRECATED_GetISteamUnifiedMessages %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return (void *)(ISteamUnifiedMessages *)steam_unified_messages;
|
return (void *)(ISteamUnifiedMessages *)steam_unified_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISteamUnifiedMessages *Steam_Client::GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamUnifiedMessages *Steam_Client::GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamUnifiedMessages %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamUnifiedMessages %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_unified_messages;
|
return steam_unified_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,7 +735,7 @@ ISteamUnifiedMessages *Steam_Client::GetISteamUnifiedMessages( HSteamUser hSteam
|
||||||
ISteamController *Steam_Client::GetISteamController( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamController *Steam_Client::GetISteamController( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamController %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamController %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "STEAMCONTROLLER_INTERFACE_VERSION") == 0) {
|
if (strcmp(pchVersion, "STEAMCONTROLLER_INTERFACE_VERSION") == 0) {
|
||||||
return (ISteamController *)(void *)(ISteamController001 *)steam_controller;
|
return (ISteamController *)(void *)(ISteamController001 *)steam_controller;
|
||||||
|
@ -803,7 +763,7 @@ ISteamController *Steam_Client::GetISteamController( HSteamUser hSteamUser, HSte
|
||||||
ISteamUGC *Steam_Client::GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamUGC *Steam_Client::GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamUGC %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamUGC %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
Steam_UGC *steam_ugc_temp;
|
Steam_UGC *steam_ugc_temp;
|
||||||
|
|
||||||
if (hSteamUser == SERVER_HSTEAMUSER) {
|
if (hSteamUser == SERVER_HSTEAMUSER) {
|
||||||
|
@ -855,7 +815,7 @@ ISteamUGC *Steam_Client::GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamP
|
||||||
ISteamAppList *Steam_Client::GetISteamAppList( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamAppList *Steam_Client::GetISteamAppList( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamAppList %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamAppList %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
return steam_applist;
|
return steam_applist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,7 +823,7 @@ ISteamAppList *Steam_Client::GetISteamAppList( HSteamUser hSteamUser, HSteamPipe
|
||||||
ISteamMusic *Steam_Client::GetISteamMusic( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamMusic *Steam_Client::GetISteamMusic( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamMusic %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamMusic %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_music;
|
return steam_music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +831,7 @@ ISteamMusic *Steam_Client::GetISteamMusic( HSteamUser hSteamuser, HSteamPipe hSt
|
||||||
ISteamMusicRemote *Steam_Client::GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion)
|
ISteamMusicRemote *Steam_Client::GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion)
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamMusicRemote %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamMusicRemote %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_musicremote;
|
return steam_musicremote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +839,7 @@ ISteamMusicRemote *Steam_Client::GetISteamMusicRemote(HSteamUser hSteamuser, HSt
|
||||||
ISteamHTMLSurface *Steam_Client::GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion)
|
ISteamHTMLSurface *Steam_Client::GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion)
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamHTMLSurface %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamHTMLSurface %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
|
|
||||||
if (strcmp(pchVersion, "STEAMHTMLSURFACE_INTERFACE_VERSION_001") == 0) {
|
if (strcmp(pchVersion, "STEAMHTMLSURFACE_INTERFACE_VERSION_001") == 0) {
|
||||||
return (ISteamHTMLSurface *)(void *)(ISteamHTMLSurface001 *)steam_HTMLsurface;
|
return (ISteamHTMLSurface *)(void *)(ISteamHTMLSurface001 *)steam_HTMLsurface;
|
||||||
|
@ -928,7 +888,7 @@ void Steam_Client::Remove_SteamAPI_CPostAPIResultInProcess( SteamAPI_PostAPIResu
|
||||||
ISteamInventory *Steam_Client::GetISteamInventory( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamInventory *Steam_Client::GetISteamInventory( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamInventory %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamInventory %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
Steam_Inventory *steam_inventory_temp;
|
Steam_Inventory *steam_inventory_temp;
|
||||||
Settings *settings_temp;
|
Settings *settings_temp;
|
||||||
SteamCallBacks *callbacks_temp;
|
SteamCallBacks *callbacks_temp;
|
||||||
|
@ -957,7 +917,7 @@ ISteamInventory *Steam_Client::GetISteamInventory( HSteamUser hSteamuser, HSteam
|
||||||
ISteamVideo *Steam_Client::GetISteamVideo( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamVideo *Steam_Client::GetISteamVideo( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamVideo %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamVideo %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_video;
|
return steam_video;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,21 +925,21 @@ ISteamVideo *Steam_Client::GetISteamVideo( HSteamUser hSteamuser, HSteamPipe hSt
|
||||||
ISteamParentalSettings *Steam_Client::GetISteamParentalSettings( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamParentalSettings *Steam_Client::GetISteamParentalSettings( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamParentalSettings %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamParentalSettings %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
return steam_parental;
|
return steam_parental;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISteamMasterServerUpdater *Steam_Client::GetISteamMasterServerUpdater( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamMasterServerUpdater *Steam_Client::GetISteamMasterServerUpdater( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamMasterServerUpdater %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamMasterServerUpdater %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
return steam_masterserver_updater;
|
return steam_masterserver_updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISteamContentServer *Steam_Client::GetISteamContentServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamContentServer *Steam_Client::GetISteamContentServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamContentServer %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamContentServer %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,7 +947,7 @@ ISteamContentServer *Steam_Client::GetISteamContentServer( HSteamUser hSteamUser
|
||||||
ISteamGameSearch *Steam_Client::GetISteamGameSearch( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamGameSearch *Steam_Client::GetISteamGameSearch( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamGameSearch %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamGameSearch %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamuser) return NULL;
|
if (!hSteamPipe || !hSteamuser) return NULL;
|
||||||
|
|
||||||
return steam_game_search;
|
return steam_game_search;
|
||||||
}
|
}
|
||||||
|
@ -996,7 +956,7 @@ ISteamGameSearch *Steam_Client::GetISteamGameSearch( HSteamUser hSteamuser, HSte
|
||||||
ISteamInput *Steam_Client::GetISteamInput( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamInput *Steam_Client::GetISteamInput( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamInput %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamInput %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
return steam_controller;
|
return steam_controller;
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +965,7 @@ ISteamInput *Steam_Client::GetISteamInput( HSteamUser hSteamUser, HSteamPipe hSt
|
||||||
ISteamParties *Steam_Client::GetISteamParties( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamParties *Steam_Client::GetISteamParties( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamParties %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamParties %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
return steam_parties;
|
return steam_parties;
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +973,7 @@ ISteamParties *Steam_Client::GetISteamParties( HSteamUser hSteamUser, HSteamPipe
|
||||||
ISteamRemotePlay *Steam_Client::GetISteamRemotePlay( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
ISteamRemotePlay *Steam_Client::GetISteamRemotePlay( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("GetISteamRemotePlay %s\n", pchVersion);
|
PRINT_DEBUG("GetISteamRemotePlay %s\n", pchVersion);
|
||||||
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
|
if (!hSteamPipe || !hSteamUser) return NULL;
|
||||||
|
|
||||||
return steam_remoteplay;
|
return steam_remoteplay;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,12 +55,6 @@
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
enum Steam_Pipe {
|
|
||||||
NO_USER,
|
|
||||||
CLIENT,
|
|
||||||
SERVER
|
|
||||||
};
|
|
||||||
|
|
||||||
class Steam_Client :
|
class Steam_Client :
|
||||||
public ISteamClient007,
|
public ISteamClient007,
|
||||||
public ISteamClient008,
|
public ISteamClient008,
|
||||||
|
@ -130,10 +124,6 @@ public:
|
||||||
bool user_logged_in = false;
|
bool user_logged_in = false;
|
||||||
bool server_init = false;
|
bool server_init = false;
|
||||||
std::thread background_keepalive;
|
std::thread background_keepalive;
|
||||||
bool steamclient_server_inited = false;
|
|
||||||
|
|
||||||
unsigned steam_pipe_counter = 2;
|
|
||||||
std::map<HSteamPipe, enum Steam_Pipe> steam_pipes;
|
|
||||||
|
|
||||||
Steam_Client();
|
Steam_Client();
|
||||||
~Steam_Client();
|
~Steam_Client();
|
||||||
|
|
|
@ -661,8 +661,8 @@ int GetAnalogActionOrigins( InputHandle_t inputHandle, InputActionSetHandle_t ac
|
||||||
if (a == map->second.active_analog.end()) return 0;
|
if (a == map->second.active_analog.end()) return 0;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto b: a->second.first) {
|
for (auto a: a->second.first) {
|
||||||
switch (b) {
|
switch (a) {
|
||||||
case TRIGGER_LEFT:
|
case TRIGGER_LEFT:
|
||||||
originsOut[count] = k_EInputActionOrigin_XBox360_LeftTrigger_Pull;
|
originsOut[count] = k_EInputActionOrigin_XBox360_LeftTrigger_Pull;
|
||||||
break;
|
break;
|
||||||
|
@ -692,7 +692,7 @@ int GetAnalogActionOrigins( InputHandle_t inputHandle, InputActionSetHandle_t ac
|
||||||
|
|
||||||
void StopAnalogActionMomentum( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction )
|
void StopAnalogActionMomentum( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Controller::StopAnalogActionMomentum %llu %llu\n", controllerHandle, eAction);
|
PRINT_DEBUG("Steam_Controller::StopAnalogActionMomentum\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -723,12 +723,7 @@ void TriggerVibration( ControllerHandle_t controllerHandle, unsigned short usLef
|
||||||
auto controller = controllers.find(controllerHandle);
|
auto controller = controllers.find(controllerHandle);
|
||||||
if (controller == controllers.end()) return;
|
if (controller == controllers.end()) return;
|
||||||
|
|
||||||
unsigned int rumble_length_ms = 0;
|
GamepadSetRumble((GAMEPAD_DEVICE)(controllerHandle - 1), ((double)usLeftSpeed) / 65535.0, ((double)usRightSpeed) / 65535.0);
|
||||||
#if defined(__linux__)
|
|
||||||
//FIXME: shadow of the tomb raider on linux doesn't seem to turn off the rumble so I made it expire after 100ms. Need to check if this is how linux steam actually behaves.
|
|
||||||
rumble_length_ms = 100;
|
|
||||||
#endif
|
|
||||||
GamepadSetRumble((GAMEPAD_DEVICE)(controllerHandle - 1), ((double)usLeftSpeed) / 65535.0, ((double)usRightSpeed) / 65535.0, rumble_length_ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ bool Steam_GameServer::BSecure()
|
||||||
PRINT_DEBUG("BSecure\n");
|
PRINT_DEBUG("BSecure\n");
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
if (!policy_response_called) return false;
|
if (!policy_response_called) return false;
|
||||||
return !!(flags & k_unServerFlagSecure);
|
return flags == eServerModeAuthenticationAndSecure;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSteamID Steam_GameServer::GetSteamID()
|
CSteamID Steam_GameServer::GetSteamID()
|
||||||
|
@ -414,7 +414,6 @@ bool Steam_GameServer::BSetServerType( uint32 unServerFlags, uint32 unGameIP, ui
|
||||||
version.erase(std::remove(version.begin(), version.end(), ' '), version.end());
|
version.erase(std::remove(version.begin(), version.end(), ' '), version.end());
|
||||||
version.erase(std::remove(version.begin(), version.end(), '.'), version.end());
|
version.erase(std::remove(version.begin(), version.end(), '.'), version.end());
|
||||||
server_data.set_version(stoi(version));
|
server_data.set_version(stoi(version));
|
||||||
flags = unServerFlags;
|
|
||||||
|
|
||||||
//TODO?
|
//TODO?
|
||||||
return true;
|
return true;
|
||||||
|
@ -663,7 +662,7 @@ void Steam_GameServer::RunCallbacks()
|
||||||
if (logged_in && !policy_response_called) {
|
if (logged_in && !policy_response_called) {
|
||||||
PRINT_DEBUG("Steam_GameServer::GSPolicyResponse_t\n");
|
PRINT_DEBUG("Steam_GameServer::GSPolicyResponse_t\n");
|
||||||
GSPolicyResponse_t data;
|
GSPolicyResponse_t data;
|
||||||
data.m_bSecure = !!(flags & k_unServerFlagSecure);
|
data.m_bSecure = flags == eServerModeAuthenticationAndSecure;
|
||||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.11);
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.11);
|
||||||
policy_response_called = true;
|
policy_response_called = true;
|
||||||
}
|
}
|
||||||
|
|
455
dll/wrap.cpp
455
dll/wrap.cpp
|
@ -15,8 +15,6 @@
|
||||||
License along with the Goldberg Emulator; if not, see
|
License along with the Goldberg Emulator; if not, see
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#define STEAM_API_FUNCTIONS_IMPL
|
|
||||||
#include "base.h"
|
|
||||||
#include "dll.h"
|
#include "dll.h"
|
||||||
|
|
||||||
#ifdef STEAM_WIN32
|
#ifdef STEAM_WIN32
|
||||||
|
@ -34,266 +32,39 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
#define PATH_SEPARATOR_CHAR '/'
|
STEAMAPI_API FILE *__wrap_freopen(const char *pathname, const char *mode, FILE *stream)
|
||||||
#define STEAM_PATH_CACHE_SIZE 4096
|
|
||||||
|
|
||||||
const char *STEAM_PATH;
|
|
||||||
size_t STEAM_PATH_SIZE;
|
|
||||||
|
|
||||||
const char *get_steam_path()
|
|
||||||
{
|
{
|
||||||
char *home_path = getenv("HOME");
|
return freopen(pathname, mode, stream);
|
||||||
char steam_path[STEAM_PATH_CACHE_SIZE];
|
|
||||||
char *steam_realpath = nullptr;
|
|
||||||
|
|
||||||
// Build steam_path from home
|
|
||||||
int required_size = snprintf(steam_path, STEAM_PATH_CACHE_SIZE, "%s/.steam/steam", home_path);
|
|
||||||
|
|
||||||
// Allocate more space for steam_path if needed (required_size does not count terminator)
|
|
||||||
if (required_size > 0 && required_size >= STEAM_PATH_CACHE_SIZE) {
|
|
||||||
char *large_steam_path = (char *)malloc(sizeof(char) * (required_size + 1));
|
|
||||||
int check_size = snprintf(steam_path, required_size + 1, "%s/.steam/steam", home_path);
|
|
||||||
// Check that path fits this time
|
|
||||||
if (check_size == required_size) {
|
|
||||||
steam_realpath = realpath(large_steam_path, nullptr);
|
|
||||||
}
|
|
||||||
free(large_steam_path);
|
|
||||||
} else {
|
|
||||||
steam_realpath = realpath(steam_path, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminate path with a file separator
|
STEAMAPI_API FILE *__wrap_fopen(const char *filename, const char *mode)
|
||||||
if (steam_realpath && *steam_realpath) {
|
|
||||||
size_t path_size = strlen(steam_realpath);
|
|
||||||
if (steam_realpath[path_size - 1] != PATH_SEPARATOR_CHAR) {
|
|
||||||
steam_realpath = (char *)realloc(steam_realpath, path_size + 2);
|
|
||||||
steam_realpath[path_size] = PATH_SEPARATOR_CHAR;
|
|
||||||
steam_realpath[path_size + 1] = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Failsafe to root
|
|
||||||
steam_realpath = strdup("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
return steam_realpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool match_path(char *path, int start, bool accept_same_case)
|
|
||||||
{
|
{
|
||||||
if (!path[start + 1]) {
|
return fopen(filename, mode);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snap to the next separator in path
|
STEAMAPI_API FILE *__wrap_fopen64(const char *filename, const char *mode)
|
||||||
int separator = start + 1;
|
|
||||||
while (path[separator] != PATH_SEPARATOR_CHAR && path[separator]) {
|
|
||||||
separator++;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_last_component = path[separator] != PATH_SEPARATOR_CHAR;
|
|
||||||
|
|
||||||
char stored_char = path[separator];
|
|
||||||
path[separator] = 0;
|
|
||||||
bool path_accessible = access(path, 0) == 0;
|
|
||||||
path[separator] = stored_char;
|
|
||||||
|
|
||||||
if (!path_accessible || (!is_last_component && !match_path(path, separator, accept_same_case))) {
|
|
||||||
DIR *current_directory = nullptr;
|
|
||||||
int component = start + 1;
|
|
||||||
|
|
||||||
if (start) {
|
|
||||||
stored_char = path[start];
|
|
||||||
path[start] = 0;
|
|
||||||
current_directory = opendir(path);
|
|
||||||
path[start] = stored_char;
|
|
||||||
component = start + 1;
|
|
||||||
} else {
|
|
||||||
if (*path == PATH_SEPARATOR_CHAR) {
|
|
||||||
component = start + 1;
|
|
||||||
current_directory = opendir("/");
|
|
||||||
} else {
|
|
||||||
component = start;
|
|
||||||
current_directory = opendir(".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0123456789012345678901234567890123456789
|
|
||||||
// path = /this/is/a/sample/path/to/file.txt
|
|
||||||
// ^^ ^
|
|
||||||
// ab c
|
|
||||||
// a. start = 10
|
|
||||||
// b. component = 11
|
|
||||||
// c. separator = 17
|
|
||||||
// current_directory = /this/is/a/
|
|
||||||
|
|
||||||
if (current_directory) {
|
|
||||||
dirent64 *entry = (dirent64 *)readdir64(current_directory);
|
|
||||||
while (entry) {
|
|
||||||
const char *entry_name = entry->d_name;
|
|
||||||
stored_char = path[separator];
|
|
||||||
path[separator] = 0;
|
|
||||||
|
|
||||||
// Fix current component if entry with similar name exists
|
|
||||||
if (!strcasecmp(&path[component], entry_name)) {
|
|
||||||
bool case_differs = strcmp(&path[component], entry_name) != 0;
|
|
||||||
path[separator] = stored_char;
|
|
||||||
if (case_differs) {
|
|
||||||
char *iterator = &path[component];
|
|
||||||
// Replace with entry name
|
|
||||||
while (*entry_name != PATH_SEPARATOR_CHAR && *entry_name) {
|
|
||||||
*(iterator++) = *(entry_name++);
|
|
||||||
}
|
|
||||||
// Fix next component
|
|
||||||
if (is_last_component || match_path(path, separator, accept_same_case)) {
|
|
||||||
closedir(current_directory);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
path[separator] = stored_char;
|
|
||||||
}
|
|
||||||
entry = (dirent64 *)readdir64(current_directory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_directory) {
|
|
||||||
closedir(current_directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return accept_same_case && is_last_component;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *lowercase_path(const char *path, bool accept_same_case, bool stop_at_separator)
|
|
||||||
{
|
{
|
||||||
std::locale loc;
|
return fopen64(filename, mode);
|
||||||
char *path_lowercased = nullptr;
|
|
||||||
|
|
||||||
if (path && *path) {
|
|
||||||
if (access(path, 0)) {
|
|
||||||
// Make a copy of the path on which to work on
|
|
||||||
path_lowercased = strdup(path);
|
|
||||||
if (!path_lowercased) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
// Load steam path if not done already
|
|
||||||
if (!STEAM_PATH) {
|
|
||||||
STEAM_PATH = get_steam_path();
|
|
||||||
STEAM_PATH_SIZE = strlen(STEAM_PATH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *lowercase_iterator = path_lowercased;
|
STEAMAPI_API int __wrap_open(const char *pathname, int flags, mode_t mode)
|
||||||
// Lowercase whole steam path if possible
|
|
||||||
if (!strncasecmp(path_lowercased, STEAM_PATH, STEAM_PATH_SIZE)) {
|
|
||||||
memcpy(path_lowercased, STEAM_PATH, STEAM_PATH_SIZE);
|
|
||||||
lowercase_iterator = &path_lowercased[STEAM_PATH_SIZE - 1];
|
|
||||||
}
|
|
||||||
// Lowercase rest of the path
|
|
||||||
char *iterator = lowercase_iterator;
|
|
||||||
while ((!stop_at_separator || *iterator != PATH_SEPARATOR_CHAR) && *iterator) {
|
|
||||||
*iterator = std::tolower(*iterator, loc);
|
|
||||||
iterator++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we can access the lowered-case path
|
|
||||||
int error = access(path_lowercased, 0);
|
|
||||||
if (!error) {
|
|
||||||
// The new path is valid
|
|
||||||
return path_lowercased;
|
|
||||||
} else {
|
|
||||||
if (accept_same_case) {
|
|
||||||
const char *name_iterator = &path[lowercase_iterator - path_lowercased];
|
|
||||||
while (*lowercase_iterator) {
|
|
||||||
*(lowercase_iterator++) = *(name_iterator++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Retry accesing the file again and tweak the path if needed
|
|
||||||
if (match_path(path_lowercased, STEAM_PATH_SIZE - 1, accept_same_case)) {
|
|
||||||
return path_lowercased;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
STEAMAPI_API FILE *__wrap_freopen(const char *path, const char *modes, FILE *stream)
|
|
||||||
{
|
{
|
||||||
bool is_writable = strpbrk(modes, "wa+") != 0;
|
return open(pathname, flags, mode);
|
||||||
const char *path_lowercased = lowercase_path(path, is_writable, true);
|
|
||||||
FILE *result = freopen(path_lowercased, modes, stream);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API FILE *__wrap_fopen(const char *path, const char *modes)
|
STEAMAPI_API int __wrap_open64(const char *pathname, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
bool is_writable = strpbrk(modes, "wa+") != 0;
|
return open64(pathname, flags, mode);
|
||||||
const char *path_lowercased = lowercase_path(path, is_writable, true);
|
|
||||||
FILE *result = fopen(path_lowercased, modes);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API FILE *__wrap_fopen64(const char *path, const char *modes)
|
STEAMAPI_API int __wrap_access(const char *pathname, int mode)
|
||||||
{
|
{
|
||||||
bool is_writable = strpbrk(modes, "wa+") != 0;
|
return access(pathname, mode);
|
||||||
const char *path_lowercased = lowercase_path(path, is_writable, true);
|
|
||||||
FILE *result = fopen64(path_lowercased, modes);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_open(const char *path, int flags, mode_t mode)
|
|
||||||
{
|
|
||||||
bool is_writable = flags & 3;
|
|
||||||
const char *path_lowercased = lowercase_path(path, is_writable, true);
|
|
||||||
int result = open(path_lowercased, flags, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_open64(const char *path, int flags, mode_t mode)
|
|
||||||
{
|
|
||||||
bool is_writable = flags & 3;
|
|
||||||
const char *path_lowercased = lowercase_path(path, is_writable, true);
|
|
||||||
int result = open64(path_lowercased, flags, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_access(const char *path, int mode)
|
|
||||||
{
|
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
|
||||||
int result = access(path_lowercased, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap___xstat(int ver, const char * path, struct stat * stat_buf)
|
STEAMAPI_API int __wrap___xstat(int ver, const char * path, struct stat * stat_buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return __xstat(ver, path, stat_buf);
|
||||||
int result = __xstat(ver, path_lowercased, stat_buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_stat(const char * path, struct stat * stat_buf)
|
STEAMAPI_API int __wrap_stat(const char * path, struct stat * stat_buf)
|
||||||
|
@ -303,12 +74,7 @@ STEAMAPI_API int __wrap_stat(const char * path, struct stat * stat_buf)
|
||||||
|
|
||||||
STEAMAPI_API int __wrap___lxstat(int ver, const char * path, struct stat * stat_buf)
|
STEAMAPI_API int __wrap___lxstat(int ver, const char * path, struct stat * stat_buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return __lxstat(ver, path, stat_buf);
|
||||||
int result = __lxstat(ver, path_lowercased, stat_buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_lstat(const char * path, struct stat * stat_buf)
|
STEAMAPI_API int __wrap_lstat(const char * path, struct stat * stat_buf)
|
||||||
|
@ -316,250 +82,119 @@ STEAMAPI_API int __wrap_lstat(const char * path, struct stat * stat_buf)
|
||||||
return __wrap___lxstat(3, path, stat_buf);
|
return __wrap___lxstat(3, path, stat_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_scandir(const char *path, struct dirent ***namelist, int (*sel)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **))
|
STEAMAPI_API int __wrap_scandir(const char *dir, struct dirent ***namelist, int (*sel)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **))
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return scandir(dir, namelist, sel, compar);
|
||||||
int result = scandir(path_lowercased, namelist, sel, compar);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_scandir64(const char *path, struct dirent64 ***namelist, int (*sel)(const struct dirent64 *), int (*compar)(const struct dirent64 **, const struct dirent64 **))
|
STEAMAPI_API int __wrap_scandir64(const char *dir, struct dirent64 ***namelist, int (*sel)(const struct dirent64 *), int (*compar)(const struct dirent64 **, const struct dirent64 **))
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return scandir64(dir, namelist, sel, compar);
|
||||||
int result = scandir64(path_lowercased, namelist, sel, compar);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API DIR *__wrap_opendir(const char *path)
|
STEAMAPI_API DIR *__wrap_opendir(const char *name)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return opendir(name);
|
||||||
DIR *result = opendir(path_lowercased);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap___xstat64(int ver, const char *path, struct stat64 *stat_buf)
|
STEAMAPI_API int __wrap___xstat64(int vers, const char *name, struct stat64 *buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return __xstat64(vers, name, buf);
|
||||||
int result = __xstat64(ver, path_lowercased, stat_buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap___lxstat64(int ver, const char *path, struct stat64 *stat_buf)
|
STEAMAPI_API int __wrap___lxstat64(int vers, const char *name, struct stat64 *buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return __lxstat64(vers, name, buf);
|
||||||
int result = __lxstat64(ver, path_lowercased, stat_buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_statvfs(const char *path, struct statvfs *buf)
|
STEAMAPI_API int __wrap_statvfs(const char *path, struct statvfs *buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return statvfs(path, buf);
|
||||||
int result = statvfs(path_lowercased, buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_statvfs64(const char *path, struct statvfs64 *buf)
|
STEAMAPI_API int __wrap_statvfs64(const char *path, struct statvfs64 *buf)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return statvfs64(path, buf);
|
||||||
int result = statvfs64(path_lowercased, buf);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_chmod(const char *path, mode_t mode)
|
STEAMAPI_API int __wrap_chmod(const char *pathname, mode_t mode)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return chmod(pathname, mode);
|
||||||
int result = chmod(path_lowercased, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_chown(const char *path, uid_t owner, gid_t group)
|
STEAMAPI_API int __wrap_chown(const char *path, uid_t owner, gid_t group)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return chown(path, owner, group);
|
||||||
int result = chown(path_lowercased, owner, group);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_lchown(const char *path, uid_t owner, gid_t group)
|
STEAMAPI_API int __wrap_lchown(const char *path, uid_t owner, gid_t group)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return lchown(path, owner, group);
|
||||||
int result = lchown(path_lowercased, owner, group);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_symlink(const char *path1, const char *path2)
|
STEAMAPI_API int __wrap_symlink(const char *path1, const char *path2)
|
||||||
{
|
{
|
||||||
const char *path_lowercased1 = lowercase_path(path1, true, true);
|
return symlink(path1, path2);
|
||||||
const char *path_lowercased2 = lowercase_path(path2, false, false);
|
|
||||||
int result = symlink(path_lowercased1, path_lowercased2);
|
|
||||||
if (path_lowercased1 != path1) {
|
|
||||||
free((void *)path_lowercased1);
|
|
||||||
}
|
|
||||||
if (path_lowercased2 != path2) {
|
|
||||||
free((void *)path_lowercased2);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_link(const char *path1, const char *path2)
|
STEAMAPI_API int __wrap_link(const char *path1, const char *path2)
|
||||||
{
|
{
|
||||||
const char *path_lowercased1 = lowercase_path(path1, true, true);
|
return link(path1, path2);
|
||||||
const char *path_lowercased2 = lowercase_path(path2, false, false);
|
|
||||||
int result = link(path_lowercased1, path_lowercased2);
|
|
||||||
if (path_lowercased1 != path1) {
|
|
||||||
free((void *)path_lowercased1);
|
|
||||||
}
|
|
||||||
if (path_lowercased2 != path2) {
|
|
||||||
free((void *)path_lowercased2);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_mknod(const char *path, mode_t mode, dev_t dev)
|
STEAMAPI_API int __wrap_mknod(const char *path, mode_t mode, dev_t dev)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, true, true);
|
return __xmknod(1, path, mode, &dev);
|
||||||
int result = __xmknod(1, path_lowercased, mode, &dev);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data)
|
STEAMAPI_API int __wrap_mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data)
|
||||||
{
|
{
|
||||||
const char *source_lowercased = lowercase_path(source, false, false);
|
return mount(source, target, filesystemtype, mountflags, data);
|
||||||
const char *target_lowercased = lowercase_path(target, false, false);
|
|
||||||
int result = mount(source_lowercased, target_lowercased, filesystemtype, mountflags, data);
|
|
||||||
if (source_lowercased != source) {
|
|
||||||
free((void *)source_lowercased);
|
|
||||||
}
|
|
||||||
if (target_lowercased != target) {
|
|
||||||
free((void *)target_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_unlink(const char *path)
|
STEAMAPI_API int __wrap_unlink(const char *path)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return unlink(path);
|
||||||
int result = unlink(path);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_mkfifo(const char *path, mode_t mode)
|
STEAMAPI_API int __wrap_mkfifo(const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, true, true);
|
return mkfifo(path, mode);
|
||||||
int result = mkfifo(path, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_rename(const char *old_name, const char *new_name)
|
STEAMAPI_API int __wrap_rename(const char *old_name, const char *new_name)
|
||||||
{
|
{
|
||||||
const char *old_name_lowercased = lowercase_path(old_name, true, true);
|
return rename(old_name, new_name);
|
||||||
const char *new_name_lowercased = lowercase_path(new_name, false, false);
|
|
||||||
int result = rename(old_name_lowercased, new_name_lowercased);
|
|
||||||
if (old_name_lowercased != old_name) {
|
|
||||||
free((void *)old_name_lowercased);
|
|
||||||
}
|
|
||||||
if (new_name_lowercased != new_name) {
|
|
||||||
free((void *)new_name_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_utime(const char *path, const struct utimbuf *times)
|
STEAMAPI_API int __wrap_utime(const char *path, const struct utimbuf *times)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return utime(path, times);
|
||||||
int result = utime(path_lowercased, times);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_utimes(const char *path, const struct timeval times[2])
|
STEAMAPI_API int __wrap_utimes(const char *path, const struct timeval times[2])
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return utimes(path, times);
|
||||||
int result = utimes(path_lowercased, times);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_mkdir(const char *path, mode_t mode)
|
STEAMAPI_API int __wrap_mkdir(const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, true, true);
|
return mkdir(path, mode);
|
||||||
int result = mkdir(path_lowercased, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API int __wrap_rmdir(const char *path)
|
STEAMAPI_API int __wrap_rmdir(const char *path)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return rmdir(path);
|
||||||
int result = rmdir(path_lowercased);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API void *__wrap_dlopen(const char *path, int mode)
|
STEAMAPI_API void * __wrap_dlopen(const char *file, int mode)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return dlopen(file, mode);
|
||||||
void * result = dlopen(path_lowercased, mode);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STEAMAPI_API void *__wrap_dlmopen(Lmid_t lmid, const char *path, int flags)
|
STEAMAPI_API void * __wrap_dlmopen(Lmid_t lmid, const char *filename, int flags)
|
||||||
{
|
{
|
||||||
const char *path_lowercased = lowercase_path(path, false, false);
|
return dlmopen(lmid, filename, flags);
|
||||||
void * result = dlmopen(lmid, path_lowercased, flags);
|
|
||||||
if (path_lowercased != path) {
|
|
||||||
free((void *)path_lowercased);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,13 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
APP_NAME="bin/test_executable"
|
APP_PATH=./example_executable
|
||||||
APP_ID=480
|
APP_ID=480
|
||||||
APP_PATH=$(dirname "$0")
|
|
||||||
CONFIG_PATH=$(dirname "$0")
|
|
||||||
#path to steam-runtime/run.sh
|
|
||||||
STEAM_RUNTIME=""
|
|
||||||
|
|
||||||
CUR_DIR=$(pwd)
|
set -e
|
||||||
cd "$CONFIG_PATH"
|
|
||||||
mkdir -p ~/.steam/sdk64
|
mkdir -p ~/.steam/sdk64
|
||||||
mkdir -p ~/.steam/sdk32
|
mkdir -p ~/.steam/sdk32
|
||||||
#make a backup of original files
|
#make a backup of original files
|
||||||
|
@ -18,15 +13,8 @@ mv ~/.steam/sdk32/steamclient.so ~/.steam/sdk32/steamclient.so.orig || true
|
||||||
cp x86/steamclient.so ~/.steam/sdk32/steamclient.so
|
cp x86/steamclient.so ~/.steam/sdk32/steamclient.so
|
||||||
cp x86_64/steamclient.so ~/.steam/sdk64/steamclient.so
|
cp x86_64/steamclient.so ~/.steam/sdk64/steamclient.so
|
||||||
echo $BASHPID > ~/.steam/steam.pid
|
echo $BASHPID > ~/.steam/steam.pid
|
||||||
cd "$APP_PATH"
|
SteamAppId=$APP_ID SteamGameId=$APP_ID $APP_PATH
|
||||||
if [ -z "$STEAM_RUNTIME" ]
|
|
||||||
then
|
|
||||||
SteamAppPath="$APP_PATH" SteamAppId=$APP_ID SteamGameId=$APP_ID "$APP_NAME"
|
|
||||||
else
|
|
||||||
SteamAppPath="$APP_PATH" SteamAppId=$APP_ID SteamGameId=$APP_ID "$STEAM_RUNTIME" "$APP_NAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$CUR_DIR"
|
|
||||||
#restore original
|
#restore original
|
||||||
rm -f ~/.steam/steam.pid
|
rm -f ~/.steam/steam.pid
|
||||||
rm -f ~/.steam/sdk64/steamclient.so
|
rm -f ~/.steam/sdk64/steamclient.so
|
||||||
|
|
|
@ -39,19 +39,11 @@
|
||||||
#endif // STEAM_API_EXPORTS
|
#endif // STEAM_API_EXPORTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STEAM_API_EXPORTS
|
|
||||||
#ifdef STEAM_API_FUNCTIONS_IMPL
|
|
||||||
#ifdef STEAMCLIENT_DLL
|
#ifdef STEAMCLIENT_DLL
|
||||||
#define S_API static
|
#define S_API static
|
||||||
#else
|
#else
|
||||||
#define S_API S_API_EXPORT
|
#define S_API S_API_EXPORT
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#define S_API
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define S_API S_API_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ( defined(STEAM_API_EXPORTS) || defined(STEAM_API_NODLL) ) && !defined(API_GEN)
|
#if ( defined(STEAM_API_EXPORTS) || defined(STEAM_API_NODLL) ) && !defined(API_GEN)
|
||||||
#define STEAM_PRIVATE_API( ... ) __VA_ARGS__
|
#define STEAM_PRIVATE_API( ... ) __VA_ARGS__
|
||||||
|
|
Loading…
Reference in New Issue