Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ server/src/main/native/com_codedisaster_steamworks_*
build/
obj/
target/
bin/
Makefile
*.exp
*.lib
Expand All @@ -22,6 +23,9 @@ Makefile
# IDE files
.idea/
*.iml
.project
.classpath
.settings/

# build tools
build-natives/.vs/
Expand All @@ -30,4 +34,4 @@ premake5*

# test resources
steam_appid.txt
encryptedappticket.key
encryptedappticket.key
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.codedisaster.steamworks;

@SuppressWarnings("unused")
public class SteamApps extends SteamInterface {
public class SteamApps extends SteamInterfaceImpl {

public SteamApps() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codedisaster.steamworks;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamController extends SteamInterface {
public class SteamController extends SteamInterfaceImpl {

public enum Pad {
Left,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Collection;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamFriends extends SteamInterface {
public class SteamFriends extends SteamInterfaceImpl {

public enum FriendRelationship {
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamHTTP extends SteamInterface {
public class SteamHTTP extends SteamInterfaceImpl {

public enum HTTPMethod {
Invalid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,11 @@
package com.codedisaster.steamworks;

import java.nio.Buffer;
/**
* <b>Public</b> interface for any native steam interfaces, implemented by
* {@link SteamInterfaceImpl}, which is package-private.
*/
public interface SteamInterface {

abstract class SteamInterface {

protected long callback;

SteamInterface() {
this(0L);
}

SteamInterface(long callback) {
this.callback = callback;
}

void setCallback(long callback) {
this.callback = callback;
}

public void dispose() {
deleteCallback(callback);
}

void checkBuffer(Buffer buffer) throws SteamException {
if (!buffer.isDirect()) {
throw new SteamException("Direct buffer required.");
}
}

void checkArray(byte[] array, int length) throws SteamException {
if (array.length < length) {
throw new SteamException("Array too small, " + array.length + " found but " + length + " expected.");
}
}

/*
The native API allows passing NULL char pointers in some places, but
the wrapper code generated by jnigen doesn't check for null Strings.
So we silently convert to an empty string here, and check again before
calling the native function.
*/
static String maybeNull(String argument) {
return (argument != null) ? argument : "";
}

/*JNI
#include "SteamCallbackAdapter.h"
*/

protected static native void deleteCallback(long callback); /*
delete (SteamCallbackAdapter*) callback;
*/
void dispose();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.codedisaster.steamworks;

import java.nio.Buffer;

/**
* <ul>
* <li>{@link SteamApps}</li>
* <li>{@link SteamController}</li>
* <li>{@link SteamEncryptedAppTicket}</li>
* <li>{@link SteamFriends}</li>
* <li>{@link SteamGameServer}</li>
* <li>{@link SteamGameServerStats}</li>
* <li>{@link SteamHTTP} &#8594; {@link SteamGameServerHTTP}</li>
* <li>{@link SteamMatchmaking}</li>
* <li>{@link SteamMatchmakingPingResponse}</li>
* <li>{@link SteamMatchmakingPlayerResponse}</li>
* <li>{@link SteamMatchmakingRulesResponse}</li>
* <li>{@link SteamMatchmakingServerListResponse}</li>
* <li>{@link SteamMatchmakingServers}</li>
* <li>{@link SteamNetworking} &#8594; {@link SteamGameServerNetworking}</li>
* <li>{@link SteamRemoteStorage}</li>
* <li>{@link SteamScreenshots}</li>
* <li>{@link SteamUGC}</li>
* <li>{@link SteamUser}</li>
* <li>{@link SteamUserStats}</li>
* <li>{@link SteamUtils}</li>
* </ul>
*/
abstract class SteamInterfaceImpl implements SteamInterface {

protected long callback;

SteamInterfaceImpl() {
this(0L);
}

SteamInterfaceImpl(long callback) {
this.callback = callback;
}

void setCallback(long callback) {
this.callback = callback;
}

@Override
public void dispose() {
deleteCallback(callback);
}

static void checkBuffer(Buffer buffer) throws SteamException {
if (!buffer.isDirect()) {
throw new SteamException("Direct buffer required.");
}
}

static void checkArray(byte[] array, int length) throws SteamException {
if (array.length < length) {
throw new SteamException("Array too small, " + array.length + " found but " + length + " expected.");
}
}

/*
* The native API allows passing NULL char pointers in some places, but the
* wrapper code generated by jnigen doesn't check for null Strings. So we
* silently convert to an empty string here, and check again before calling the
* native function.
*/
static String maybeNull(String argument) {
return (argument != null) ? argument : "";
}

/*
* JNI #include "SteamCallbackAdapter.h"
*/

protected static native void deleteCallback(long callback);
/*
* delete (SteamCallbackAdapter*) callback;
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamMatchmaking extends SteamInterface {
public class SteamMatchmaking extends SteamInterfaceImpl {

public enum LobbyType {
Private,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codedisaster.steamworks;

public abstract class SteamMatchmakingPingResponse extends SteamInterface {
public abstract class SteamMatchmakingPingResponse extends SteamInterfaceImpl {

protected SteamMatchmakingPingResponse() {
super(~0L);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codedisaster.steamworks;

public abstract class SteamMatchmakingPlayersResponse extends SteamInterface {
public abstract class SteamMatchmakingPlayersResponse extends SteamInterfaceImpl {

protected SteamMatchmakingPlayersResponse() {
super(~0L);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codedisaster.steamworks;

public abstract class SteamMatchmakingRulesResponse extends SteamInterface {
public abstract class SteamMatchmakingRulesResponse extends SteamInterfaceImpl {

protected SteamMatchmakingRulesResponse() {
super(~0L);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.codedisaster.steamworks;

public abstract class SteamMatchmakingServerListResponse extends SteamInterface {
public abstract class SteamMatchmakingServerListResponse extends SteamInterfaceImpl {

public enum Response {
ServerResponded,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codedisaster.steamworks;

@SuppressWarnings("unused")
public class SteamMatchmakingServers extends SteamInterface {
public class SteamMatchmakingServers extends SteamInterfaceImpl {

public SteamMatchmakingServers() {
super(-1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamNetworking extends SteamInterface {
public class SteamNetworking extends SteamInterfaceImpl {

public enum P2PSend {
Unreliable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamRemoteStorage extends SteamInterface {
public class SteamRemoteStorage extends SteamInterfaceImpl {

public enum RemoteStoragePlatform {
None(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings("unused")
public class SteamScreenshots extends SteamInterface {
public class SteamScreenshots extends SteamInterfaceImpl {

public SteamScreenshots(SteamScreenshotsCallback callback) {
super(SteamScreenshotsNative.createCallback(new SteamScreenshotsCallbackAdapter(callback)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.EnumSet;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamUGC extends SteamInterface {
public class SteamUGC extends SteamInterfaceImpl {

public enum UserUGCList {
Published,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamUser extends SteamInterface {
public class SteamUser extends SteamInterfaceImpl {

public enum VoiceResult {
OK,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codedisaster.steamworks;

@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class SteamUserStats extends SteamInterface {
public class SteamUserStats extends SteamInterfaceImpl {

public enum LeaderboardDataRequest {
Global,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings("unused")
public class SteamUtils extends SteamInterface {
public class SteamUtils extends SteamInterfaceImpl {

public enum SteamAPICallFailure {
None(-1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.nio.ByteBuffer;

public class SteamEncryptedAppTicket extends SteamInterface {
public class SteamEncryptedAppTicket extends SteamInterfaceImpl {

public static final int SymmetricKeyLen = 32;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.nio.ByteBuffer;

@SuppressWarnings("unused")
public class SteamGameServer extends SteamInterface {
public class SteamGameServer extends SteamInterfaceImpl {

public enum DenyReason {
Invalid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.codedisaster.steamworks;

@SuppressWarnings("unused")
public class SteamGameServerHTTP extends SteamHTTP {

public SteamGameServerHTTP(SteamHTTPCallback callback) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codedisaster.steamworks;

@SuppressWarnings("unused")
public class SteamGameServerStats extends SteamInterface {
public class SteamGameServerStats extends SteamInterfaceImpl {

public SteamGameServerStats(SteamGameServerStatsCallback callback) {
super(SteamGameServerStatsNative.createCallback(new SteamGameServerStatsCallbackAdapter(callback)));
Expand Down