mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
move GetProcessId to C files
This commit is contained in:
parent
6591b53547
commit
5e3fd8e95e
22
deps/discord-rpc/include/discord_rpc.h
vendored
22
deps/discord-rpc/include/discord_rpc.h
vendored
@ -1,12 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
|
|
||||||
# define DISCORD_EXPORT
|
|
||||||
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -52,28 +46,28 @@ typedef struct DiscordEventHandlers
|
|||||||
#define DISCORD_REPLY_YES 1
|
#define DISCORD_REPLY_YES 1
|
||||||
#define DISCORD_REPLY_IGNORE 2
|
#define DISCORD_REPLY_IGNORE 2
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
void Discord_Initialize(const char* applicationId,
|
||||||
DiscordEventHandlers* handlers,
|
DiscordEventHandlers* handlers,
|
||||||
int autoRegister,
|
int autoRegister,
|
||||||
const char* optionalSteamId);
|
const char* optionalSteamId);
|
||||||
DISCORD_EXPORT void Discord_Shutdown(void);
|
void Discord_Shutdown(void);
|
||||||
|
|
||||||
/* checks for incoming messages, dispatches callbacks */
|
/* checks for incoming messages, dispatches callbacks */
|
||||||
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
void Discord_RunCallbacks(void);
|
||||||
|
|
||||||
/* If you disable the lib starting its own I/O thread,
|
/* If you disable the lib starting its own I/O thread,
|
||||||
* you'll need to call this from your own */
|
* you'll need to call this from your own */
|
||||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||||
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
void Discord_UpdateConnection(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||||
DISCORD_EXPORT void Discord_ClearPresence(void);
|
void Discord_ClearPresence(void);
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_Respond(const char* userid,
|
void Discord_Respond(const char* userid,
|
||||||
/* DISCORD_REPLY_ */ int reply);
|
/* DISCORD_REPLY_ */ int reply);
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
3
deps/discord-rpc/src/connection.h
vendored
3
deps/discord-rpc/src/connection.h
vendored
@ -5,9 +5,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* not really connectiony, but need per-platform */
|
|
||||||
int GetProcessId(void);
|
|
||||||
|
|
||||||
struct BaseConnection
|
struct BaseConnection
|
||||||
{
|
{
|
||||||
static BaseConnection* Create();
|
static BaseConnection* Create();
|
||||||
|
5
deps/discord-rpc/src/connection_unix.cpp
vendored
5
deps/discord-rpc/src/connection_unix.cpp
vendored
@ -9,11 +9,6 @@
|
|||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int GetProcessId()
|
|
||||||
{
|
|
||||||
return ::getpid();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct BaseConnectionUnix : public BaseConnection {
|
struct BaseConnectionUnix : public BaseConnection {
|
||||||
int sock{-1};
|
int sock{-1};
|
||||||
};
|
};
|
||||||
|
5
deps/discord-rpc/src/connection_win.cpp
vendored
5
deps/discord-rpc/src/connection_win.cpp
vendored
@ -6,11 +6,6 @@
|
|||||||
#define NOIME
|
#define NOIME
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
int GetProcessId()
|
|
||||||
{
|
|
||||||
return (int)::GetCurrentProcessId();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct BaseConnectionWin : public BaseConnection
|
struct BaseConnectionWin : public BaseConnection
|
||||||
{
|
{
|
||||||
HANDLE pipe{INVALID_HANDLE_VALUE};
|
HANDLE pipe{INVALID_HANDLE_VALUE};
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
@ -13,6 +16,11 @@
|
|||||||
|
|
||||||
#include <discord_rpc.h>
|
#include <discord_rpc.h>
|
||||||
|
|
||||||
|
int get_process_id(void)
|
||||||
|
{
|
||||||
|
return getpid();
|
||||||
|
}
|
||||||
|
|
||||||
/* we want to register games so we can run them from
|
/* we want to register games so we can run them from
|
||||||
* Discord client as discord-<appid>:// */
|
* Discord client as discord-<appid>:// */
|
||||||
void Discord_Register(const char *applicationId, const char *command)
|
void Discord_Register(const char *applicationId, const char *command)
|
||||||
|
5
deps/discord-rpc/src/discord_register_win.c
vendored
5
deps/discord-rpc/src/discord_register_win.c
vendored
@ -9,6 +9,11 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int get_process_id(void)
|
||||||
|
{
|
||||||
|
return (int)GetCurrentProcessId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated fixes for MinGW and WinXP
|
* Updated fixes for MinGW and WinXP
|
||||||
* This block is written the way it does not involve changing the rest of the code
|
* This block is written the way it does not involve changing the rest of the code
|
||||||
|
21
deps/discord-rpc/src/discord_rpc.cpp
vendored
21
deps/discord-rpc/src/discord_rpc.cpp
vendored
@ -1,5 +1,5 @@
|
|||||||
#include <retro_common_api.h>
|
|
||||||
#include "discord_rpc.h"
|
#include "discord_rpc.h"
|
||||||
|
#include "discord_register.h"
|
||||||
|
|
||||||
#include "backoff.h"
|
#include "backoff.h"
|
||||||
#include "msg_queue.h"
|
#include "msg_queue.h"
|
||||||
@ -149,7 +149,7 @@ static void UpdateReconnectTime(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||||
extern "C" DISCORD_EXPORT void Discord_UpdateConnection(void)
|
extern "C" void Discord_UpdateConnection(void)
|
||||||
#else
|
#else
|
||||||
static void Discord_UpdateConnection(void)
|
static void Discord_UpdateConnection(void)
|
||||||
#endif
|
#endif
|
||||||
@ -300,7 +300,7 @@ static bool DeregisterForEvent(const char* evtName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_Initialize(
|
extern "C" void Discord_Initialize(
|
||||||
const char* applicationId,
|
const char* applicationId,
|
||||||
DiscordEventHandlers* handlers,
|
DiscordEventHandlers* handlers,
|
||||||
int autoRegister,
|
int autoRegister,
|
||||||
@ -318,7 +318,7 @@ extern "C" DISCORD_EXPORT void Discord_Initialize(
|
|||||||
Discord_Register(applicationId, nullptr);
|
Discord_Register(applicationId, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pid = GetProcessId();
|
Pid = get_process_id();
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(HandlerMutex);
|
std::lock_guard<std::mutex> guard(HandlerMutex);
|
||||||
@ -373,7 +373,7 @@ extern "C" DISCORD_EXPORT void Discord_Initialize(
|
|||||||
IoThread->Start();
|
IoThread->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_Shutdown(void)
|
extern "C" void Discord_Shutdown(void)
|
||||||
{
|
{
|
||||||
if (!Connection)
|
if (!Connection)
|
||||||
return;
|
return;
|
||||||
@ -390,8 +390,7 @@ extern "C" DISCORD_EXPORT void Discord_Shutdown(void)
|
|||||||
RpcConnection::Destroy(Connection);
|
RpcConnection::Destroy(Connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void
|
extern "C" void Discord_UpdatePresence(const DiscordRichPresence* presence)
|
||||||
Discord_UpdatePresence(const DiscordRichPresence* presence)
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(PresenceMutex);
|
std::lock_guard<std::mutex> guard(PresenceMutex);
|
||||||
@ -402,12 +401,12 @@ Discord_UpdatePresence(const DiscordRichPresence* presence)
|
|||||||
IoThread->Notify();
|
IoThread->Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_ClearPresence(void)
|
extern "C" void Discord_ClearPresence(void)
|
||||||
{
|
{
|
||||||
Discord_UpdatePresence(nullptr);
|
Discord_UpdatePresence(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_Respond(const char* userId, /* DISCORD_REPLY_ */ int reply)
|
extern "C" void Discord_Respond(const char* userId, /* DISCORD_REPLY_ */ int reply)
|
||||||
{
|
{
|
||||||
/* if we are not connected, let's not batch up stale messages for later */
|
/* if we are not connected, let's not batch up stale messages for later */
|
||||||
if (!Connection || !Connection->IsOpen())
|
if (!Connection || !Connection->IsOpen())
|
||||||
@ -423,7 +422,7 @@ extern "C" DISCORD_EXPORT void Discord_Respond(const char* userId, /* DISCORD_RE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_RunCallbacks(void)
|
extern "C" void Discord_RunCallbacks(void)
|
||||||
{
|
{
|
||||||
/* Note on some weirdness: internally we might connect, get other signals, disconnect any number
|
/* Note on some weirdness: internally we might connect, get other signals, disconnect any number
|
||||||
* of times inbetween calls here. Externally, we want the sequence to seem sane, so any other
|
* of times inbetween calls here. Externally, we want the sequence to seem sane, so any other
|
||||||
@ -515,7 +514,7 @@ extern "C" DISCORD_EXPORT void Discord_RunCallbacks(void)
|
|||||||
DeregisterForEvent(event)
|
DeregisterForEvent(event)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* newHandlers)
|
extern "C" void Discord_UpdateHandlers(DiscordEventHandlers* newHandlers)
|
||||||
{
|
{
|
||||||
if (newHandlers)
|
if (newHandlers)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user