Permalink
Browse files

Added discord-rpc

  • Loading branch information...
gudenau committed Dec 28, 2017
1 parent cb8777d commit 9a44d8f4a0ebf409b6be6fbf3c4616179a98f393
View
@@ -7,7 +7,7 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8 x64" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/bin" />
</component>
</project>
View
@@ -6,7 +6,7 @@
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Generator.iml" filepath="$PROJECT_DIR$/.idea/modules/Generator.iml" group="LWJGL" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Java9.iml" filepath="$PROJECT_DIR$/.idea/modules/Java9.iml" group="LWJGL" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/ModuleInfoGen.iml" filepath="$PROJECT_DIR$/.idea/modules/ModuleInfoGen.iml" group="LWJGL" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Root.iml" filepath="$PROJECT_DIR$/.idea/modules/Root.iml" group="LWJGL" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Root.iml" filepath="$PROJECT_DIR$/.idea/modules/Root.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Templates.iml" filepath="$PROJECT_DIR$/.idea/modules/Templates.iml" group="LWJGL" />
</modules>
</component>
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Root" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="org.lwjgl" external.system.module.type="" external.system.module.version="3.1.4" type="JAVA_MODULE" version="4">
<module external.linked.project.id="Root" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="org.lwjgl" external.system.module.type="" external.system.module.version="3.1.6" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../..">
View
@@ -157,6 +157,7 @@ improve the chances of a quick and useful response.
|Library|Description|
|-------|-----------|
|[Discord RPC](https://discordapp.com/)|Enables applications to access the rich presence RPC system that Discord exposes.|
|[dyncall](http://www.dyncall.org/)|Encapsulates architecture-, OS- and compiler-specific function call semantics in a virtual bind argument parameters from left to right and then call interface allowing programmers to call C functions in a completely dynamic manner.|
|[jemalloc](http://www.canonware.com/jemalloc/)|A general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support.|
|[LMDB](https://symas.com/products/lightning-memory-mapped-database/)|An extraordinarily fast, memory-efficient database. With memory-mapped files, it has the read performance of a pure in-memory database while retaining the persistence of standard disk-based databases.|
View
@@ -70,6 +70,11 @@ enum Artifacts {
"A portable Open Source library to import various well-known 3D model formats in a uniform manner.",
Platforms.ALL
),
DISCORD(
"lwjgl-discord", "LWJGL - Discord bindings",
"Enables applications to access the rich presence RPC system that Discord exposes.",
Platforms.ALL
),
BGFX(
"lwjgl-bgfx", "LWJGL - bgfx bindings",
"A cross-platform, graphics API agnostic rendering library. It provides a high performance, low level abstraction for common platform graphics APIs like OpenGL, Direct3D and Apple Metal.",
View
@@ -208,6 +208,7 @@
<src path="${src.templates.kotlin}/org/lwjgl/assimp" if:true="${binding.assimp}"/>
<src path="${src.templates.kotlin}/org/lwjgl/bgfx" if:true="${binding.bgfx}"/>
<src path="${src.templates.kotlin}/org/lwjgl/discord" if:true="${binding.discord}"/>
<src path="${src.templates.kotlin}/org/lwjgl/egl" if:true="${binding.egl}"/>
<src path="${src.templates.kotlin}/org/lwjgl/egl/EGLTypes.kt" if:true="${egl_types}"/>
<src path="${src.templates.kotlin}/org/lwjgl/glfw" if:true="${binding.glfw}"/>
@@ -15,6 +15,7 @@ This script is included in /config/build-definitions.xml.
<!-- // ========== BINDING FLAGS ======== // -->
<property name="binding.assimp" value="true"/>
<property name="binding.discord" value="true"/>
<property name="binding.bgfx" value="true"/>
<property name="binding.egl" value="true"/>
<property name="binding.glfw" value="true"/>
@@ -0,0 +1,19 @@
Copyright 2017 Discord, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
View
@@ -6,6 +6,7 @@ This build includes the following changes:
#### Bindings
- Discord RPC: New binding
- bgfx: Updated to API version 57 (up from 55)
- OpenVR: Updated to 1.0.11 (up from 1.0.10)
- Vulkan: Updated to 1.0.66 (up from 1.0.65)
@@ -1,3 +1,4 @@
#Mon Dec 25 11:30:57 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
@@ -0,0 +1,93 @@
#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
#if defined(_WIN32)
#pragma warning(push)
#pragma warning(disable:4820)
#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;
#if defined(_WIN32)
#pragma warning(pop)
#endif
typedef struct DiscordJoinRequest {
const char* userId;
const char* username;
const char* discriminator;
const char* avatar;
} DiscordJoinRequest;
typedef struct DiscordEventHandlers {
void (*ready)(void);
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 DiscordJoinRequest* 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_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
#ifdef __cplusplus
} /* extern "C" */
#endif
@@ -241,6 +241,11 @@
/** Similar to {@link #LIBRARY_NAME} for the EGL library (<b>org.lwjgl.egl.libname</b>). */
public static final Configuration<String> EGL_LIBRARY_NAME = new Configuration<>("org.lwjgl.egl.libname", StateInit.STRING);
// -- Discord-RPC
/** Similar to {@link #LIBRARY_NAME} for the Discord-RPC library (<b>org.lwjgl.discord.libname</b>). */
public static final Configuration<String> DISCORD_LIBRARY_NAME = new Configuration<>("org.lwjgl.discord.libname", StateInit.STRING);
// -- GLFW
/** Similar to {@link #LIBRARY_NAME} for the GLFW library (<b>org.lwjgl.glfw.libname</b>). */
@@ -38,6 +38,7 @@ enum class Binding(
val arrayOverloads: Boolean = true
) {
ASSIMP("binding.assimp", "org.lwjgl.assimp"),
DISCORD("binding.discord", "org.lwjgl.discord"),
BGFX("binding.bgfx", "org.lwjgl.bgfx"),
EGL("binding.egl", "org.lwjgl.egl"),
GLFW("binding.glfw", "org.lwjgl.glfw"),
@@ -0,0 +1,9 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
module org.lwjgl.odbc {
requires transitive org.lwjgl;
exports org.lwjgl.discord;
}
@@ -0,0 +1,95 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.discord
import org.lwjgl.generator.*
val DISCORD_PACKAGE = "org.lwjgl.discord"
fun config() {
packageInfo(
DISCORD_PACKAGE,
"""
Contains bindings to the ${url("https://github.com/discordapp/discord-rpc", "discord-rpc")} library. Discord RPC
enables programs to access the rich presence feature of Discord.
Documentation can be found on the ${url("https://discordapp.com/developers/docs/rich-presence/how-to", "developer site")}
with examples on the ${url("https://github.com/discordapp/discord-rpc", "GitHub repo")}.
"""
)
}
val DISCORD_BINDING = simpleBinding("discord", """Configuration.DISCORD_LIBRARY_NAME.get(Platform.mapLibraryNameBundled("discord"))""")
val DiscordRichPresence = struct(DISCORD_PACKAGE, "DiscordRichPresence"){
char.p.const.member("state", "the user's current party status")
char.p.const.member("details", "what the player is currently doing")
int64_t.member("startTimestamp", "epoch seconds for game start - including will show time as \"elapsed\"")
int64_t.member("endTimestamp", "epoch seconds for game end - including will show time as \"remaining\"")
char.p.const.member("largeImageKey", "name of the uploaded image for the large profile artwork")
char.p.const.member("largeImageText", "tooltip for the largeImageKey")
char.p.const.member("smallImageKey", "name of the uploaded image for the small profile artwork")
char.p.const.member("smallImageText", "tootltip for the smallImageKey")
char.p.const.member("partyId", "id of the player's party, lobby, or group")
int.member("partySize", "current size of the player's party, lobby, or group")
int.member("partyMax", "maximum size of the player's party, lobby, or group")
char.p.const.member("matchSecret", "unique hashed string for Spectate and Join")
char.p.const.member("joinSecret", "unique hashed string for Spectate button")
char.p.const.member("spectateSecret", "unique hashed string for chat invitations and Ask to Join")
int8_t.member("instance", "marks the matchSecret as a game session with a specific beginning and end")
}
val DiscordJoinRequest = struct(DISCORD_PACKAGE, "DiscordJoinRequest", mutable = false){
char.p.const.member("userId", "the userId of the player asking to join")
char.p.const.member("username", "the username of the player asking to join")
char.p.const.member("discriminator", "the discriminator of the player asking to join")
char.p.const.member("avatar", "the avatar hash of the player asking to join—see ${url("https://discordapp.com/developers/docs/reference#image-formatting", "image formatting")} for how to retrieve the image")
}
val ready = "ready".callback(
DISCORD_PACKAGE, void, "ready",
""
)
val disconnected = "disconnected".callback(
DISCORD_PACKAGE, void, "disconnected",
"",
int.IN("errorCode", ""),
char.p.const.IN("message", "")
)
val errored = "errored".callback(
DISCORD_PACKAGE, void, "errored",
"",
int.IN("errorCode", ""),
char.p.const.IN("message", "")
)
val joinGame = "joinGame".callback(
DISCORD_PACKAGE, void, "joinGame",
"",
char.p.const.IN("joinSecret", "")
)
val spectateGame = "spectateGame".callback(
DISCORD_PACKAGE, void, "spectateGame",
"",
char.p.const.IN("joinSecret", "")
)
val joinRequest = "joinRequest".callback(
DISCORD_PACKAGE, void, "joinRequest",
"",
DiscordJoinRequest.p.const.IN("request", "")
)
val DiscordEventHandlers = struct(DISCORD_PACKAGE, "DiscordEventHandlers"){
ready.member("ready", "")
disconnected.member("disconnected", "")
errored.member("errored", "")
joinGame.member("joinGame", "")
spectateGame.member("spectateGame", "")
joinRequest.member("joinRequest", "")
}
@@ -0,0 +1,70 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
package org.lwjgl.discord.templates
import org.lwjgl.discord.*
import org.lwjgl.generator.*
val discord = "discord".nativeClass(DISCORD_PACKAGE, binding = DISCORD_BINDING){
nativeDirective("""#include "discord-rpc.h"""")
IntConstant("", "DISCORD_REPLY_NO".."0")
IntConstant("", "DISCORD_REPLY_YES".."1")
IntConstant("", "DISCORD_REPLY_IGNORE".."2")
void(
"Discord_Initialize",
"""
""",
char.p.const.IN("applicationId", ""),
DiscordEventHandlers.p.IN("handlers", ""),
int.IN("autoRegister", ""),
char.p.const.IN("optionalSteamId", "")
)
void(
"Discord_Shutdown",
"""
"""
)
void(
"Discord_RunCallbacks",
"""
"""
)
// Un-comment this if you ever disable the library's built in thread.
// Relevent C flag: DISCORD_DISABLE_IO_THREAD
/*void(
"Discord_UpdateConnection",
"""
"""
)*/
void(
"Discord_UpdatePresence",
"""
""",
DiscordRichPresence.p.const.IN("presence", "")
)
void(
"Discord_Respond",
"""
""",
char.p.const.IN("userid", ""),
int.IN("reply", "")
)
}

0 comments on commit 9a44d8f

Please sign in to comment.