-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 198adfe
Showing
16 changed files
with
879 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="CB_RPC_legacy" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/CB_RPC_legacy" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="3" /> | ||
<Option compiler="gcc" /> | ||
<Option createDefFile="1" /> | ||
<Option createStaticLib="1" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
<Linker> | ||
<Add library="lib/discord-rpc.lib" /> | ||
<Add directory="lib" /> | ||
</Linker> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/CB_RPC_legacy" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Linker> | ||
<Add library="lib/discord-rpc.lib" /> | ||
<Add directory="lib" /> | ||
</Linker> | ||
<Unit filename="discord-files/discord_register.h" /> | ||
<Unit filename="discord-files/discord_rpc.h" /> | ||
<Unit filename="dllmain.cpp" /> | ||
<Unit filename="gms.h" /> | ||
<Unit filename="main.cpp" /> | ||
<Extensions /> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# depslib dependency file v1.0 | ||
1640353095 source:e:\visualstudio\projects\cb_rpc_legacy\main.cpp | ||
<windows.h> | ||
<stdio.h> | ||
<stdint.h> | ||
<stdio.h> | ||
<string.h> | ||
<time.h> | ||
<iostream> | ||
"utf_conv.h" | ||
"gms.h" | ||
"discord-files/discord_rpc.h" | ||
<stdint.h> | ||
<stdio.h> | ||
<string.h> | ||
<time.h> | ||
"gms.h" | ||
"discord-files/discord_rpc.h" | ||
|
||
1640340760 e:\visualstudio\projects\cb_rpc_legacy\discord-files\discord_rpc.h | ||
<stdint.h> | ||
|
||
1640343972 source:e:\visualstudio\projects\cb_rpc_legacy\dllmain.cpp | ||
<stdio.h> | ||
<stdint.h> | ||
<stdio.h> | ||
<string.h> | ||
<time.h> | ||
<iostream> | ||
"gms.h" | ||
"discord-files/discord_rpc.h" | ||
|
||
1640353575 e:\visualstudio\projects\cb_rpc_legacy\gms.h | ||
<string> | ||
<string.h> | ||
<iostream> | ||
|
||
1640350508 e:\visualstudio\projects\cb_rpc_legacy\utf_conv.h | ||
<windows.h> | ||
<string> | ||
<locale> | ||
<codecvt> | ||
<string.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="gms.h" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="93" topLine="21" /> | ||
</Cursor> | ||
</File> | ||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="3643" topLine="45" /> | ||
</Cursor> | ||
<Folding> | ||
<Collapse line="22" /> | ||
<Collapse line="30" /> | ||
<Collapse line="35" /> | ||
<Collapse line="40" /> | ||
<Collapse line="45" /> | ||
<Collapse line="50" /> | ||
<Collapse line="60" /> | ||
<Collapse line="113" /> | ||
</Folding> | ||
</File> | ||
<File name="dllmain.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="3837" topLine="6" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
EXPORTS | ||
gmrpc_clear @1 | ||
gmrpc_exit @2 | ||
gmrpc_init @3 | ||
gmrpc_setPresence @4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#if defined(DISCORD_DYNAMIC_LIB) | ||
#if defined(_WIN32) | ||
#if defined(DISCORD_BUILDING_SDK) | ||
#define DISCORD_EXPORT __declspec(dllexport) | ||
#else | ||
#define DISCORD_EXPORT __declspec(dllimport) | ||
#endif | ||
#else | ||
#define DISCORD_EXPORT __attribute__((visibility("default"))) | ||
#endif | ||
#else | ||
#define DISCORD_EXPORT | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); | ||
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
// clang-format off | ||
|
||
#if defined(DISCORD_DYNAMIC_LIB) | ||
# if defined(_WIN32) | ||
# if defined(DISCORD_BUILDING_SDK) | ||
# define DISCORD_EXPORT __declspec(dllexport) | ||
# else | ||
# define DISCORD_EXPORT __declspec(dllimport) | ||
# endif | ||
# else | ||
# define DISCORD_EXPORT __attribute__((visibility("default"))) | ||
# endif | ||
#else | ||
# define DISCORD_EXPORT | ||
#endif | ||
|
||
// clang-format on | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct DiscordRichPresence { | ||
const char* state; /* max 128 bytes */ | ||
const char* details; /* max 128 bytes */ | ||
int64_t startTimestamp; | ||
int64_t endTimestamp; | ||
const char* largeImageKey; /* max 32 bytes */ | ||
const char* largeImageText; /* max 128 bytes */ | ||
const char* smallImageKey; /* max 32 bytes */ | ||
const char* smallImageText; /* max 128 bytes */ | ||
const char* partyId; /* max 128 bytes */ | ||
int partySize; | ||
int partyMax; | ||
const char* matchSecret; /* max 128 bytes */ | ||
const char* joinSecret; /* max 128 bytes */ | ||
const char* spectateSecret; /* max 128 bytes */ | ||
int8_t instance; | ||
} DiscordRichPresence; | ||
|
||
typedef struct DiscordUser { | ||
const char* userId; | ||
const char* username; | ||
const char* discriminator; | ||
const char* avatar; | ||
} DiscordUser; | ||
|
||
typedef struct DiscordEventHandlers { | ||
void (*ready)(const DiscordUser* request); | ||
void (*disconnected)(int errorCode, const char* message); | ||
void (*errored)(int errorCode, const char* message); | ||
void (*joinGame)(const char* joinSecret); | ||
void (*spectateGame)(const char* spectateSecret); | ||
void (*joinRequest)(const DiscordUser* request); | ||
} DiscordEventHandlers; | ||
|
||
#define DISCORD_REPLY_NO 0 | ||
#define DISCORD_REPLY_YES 1 | ||
#define DISCORD_REPLY_IGNORE 2 | ||
|
||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId, | ||
DiscordEventHandlers* handlers, | ||
int autoRegister, | ||
const char* optionalSteamId); | ||
DISCORD_EXPORT void Discord_Shutdown(void); | ||
|
||
/* checks for incoming messages, dispatches callbacks */ | ||
DISCORD_EXPORT void Discord_RunCallbacks(void); | ||
|
||
/* If you disable the lib starting its own io thread, you'll need to call this from your own */ | ||
#ifdef DISCORD_DISABLE_IO_THREAD | ||
DISCORD_EXPORT void Discord_UpdateConnection(void); | ||
#endif | ||
|
||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); | ||
DISCORD_EXPORT void Discord_ClearPresence(void); | ||
|
||
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply); | ||
|
||
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers); | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/*#define _CRT_SECURE_NO_WARNINGS | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <time.h> | ||
#include <iostream> | ||
#include "gms.h" | ||
#include "discord-files/discord_rpc.h" | ||
static const char* APPLICATION_ID = "345229890980937739"; | ||
static int SendPresence = 1; | ||
static stringToDLL P_state = ""; | ||
static stringToDLL P_details = ""; | ||
static stringToDLL P_largeKey = ""; | ||
static stringToDLL P_smallKey = ""; | ||
static void handleDiscordReady(const DiscordUser* connectedUser) | ||
{ | ||
printf("\nDiscord: connected to user %s#%s - %s\n", | ||
connectedUser->username, | ||
connectedUser->discriminator, | ||
connectedUser->userId); | ||
} | ||
static void handleDiscordDisconnected(int errcode, const char* message) | ||
{ | ||
printf("\nDiscord: disconnected (%d: %s)\n", errcode, message); | ||
} | ||
static void handleDiscordError(int errcode, const char* message) | ||
{ | ||
printf("\nDiscord: error (%d: %s)\n", errcode, message); | ||
} | ||
static void handleDiscordJoin(const char* secret) | ||
{ | ||
printf("\nDiscord: join (%s)\n", secret); | ||
} | ||
static void handleDiscordSpectate(const char* secret) | ||
{ | ||
printf("\nDiscord: spectate (%s)\n", secret); | ||
} | ||
static void handleDiscordJoinRequest(const DiscordUser* request) | ||
{ | ||
int response = -1; | ||
printf("\nDiscord: join request from %s#%s - %s\n", | ||
request->username, | ||
request->discriminator, | ||
request->userId); | ||
} | ||
static void updateDiscordPresence() | ||
{ | ||
if (SendPresence) { | ||
DiscordRichPresence discordPresence; | ||
memset(&discordPresence, 0, sizeof(discordPresence)); | ||
discordPresence.state = P_state; | ||
discordPresence.details = P_details; | ||
//discordPresence.startTimestamp = StartTime; | ||
//discordPresence.endTimestamp = time(0) + 5 * 60; | ||
discordPresence.largeImageKey = P_largeKey; | ||
discordPresence.smallImageKey = P_smallKey; | ||
//discordPresence.partyId = "party1234"; | ||
//discordPresence.partySize = 1; | ||
//discordPresence.partyMax = 6; | ||
//discordPresence.matchSecret = "xyzzy"; | ||
//discordPresence.joinSecret = "join"; | ||
//discordPresence.spectateSecret = "look"; | ||
discordPresence.instance = 0; | ||
Discord_UpdatePresence(&discordPresence); | ||
} | ||
else { | ||
Discord_ClearPresence(); | ||
} | ||
} | ||
static void discordInit() | ||
{ | ||
DiscordEventHandlers handlers; | ||
memset(&handlers, 0, sizeof(handlers)); | ||
handlers.ready = handleDiscordReady; | ||
handlers.disconnected = handleDiscordDisconnected; | ||
handlers.errored = handleDiscordError; | ||
handlers.joinGame = handleDiscordJoin; | ||
handlers.spectateGame = handleDiscordSpectate; | ||
handlers.joinRequest = handleDiscordJoinRequest; | ||
Discord_Initialize(APPLICATION_ID, &handlers, 1, NULL); | ||
} | ||
gmx GMBOOL gmrpc_init(double appid) | ||
{ | ||
APPLICATION_ID = gmu::string_to_constcharptr(std::to_string(appid)); | ||
discordInit(); | ||
std::cout << "Set APPID to "<< APPLICATION_ID << "."<< std::endl; | ||
return GMTRUE; | ||
} | ||
gmx GMBOOL gmrpc_setText(stringToDLL state, stringToDLL details) | ||
{ | ||
P_state = state; | ||
P_details = details; | ||
return GMTRUE; | ||
} | ||
gmx GMBOOL gmrpc_setImages(stringToDLL large, stringToDLL small) | ||
{ | ||
P_smallKey = small; | ||
P_largeKey = large; | ||
return GMTRUE; | ||
} | ||
gmx GMBOOL gmrpc_update(GMINT appid) | ||
{ | ||
std::cout << "Updating GMRPC with APPID "<<appid <<std::endl; | ||
updateDiscordPresence(); | ||
Discord_RunCallbacks(); | ||
return GMTRUE; | ||
} | ||
gmx GMBOOL gmrpc_exit(GMINT appid) | ||
{ | ||
std::cout << "Exiting GMRPC with APPID "<<appid <<std::endl; | ||
Discord_Shutdown(); | ||
return GMTRUE; | ||
} | ||
gmx GMBOOL gmrpc_toggleActive(GMINT on) | ||
{ | ||
SendPresence = (int)on; | ||
updateDiscordPresence(); | ||
} | ||
*/ |
Oops, something went wrong.