From 3f114fab8ca534bc9c73edf7904e4619213aa0d7 Mon Sep 17 00:00:00 2001 From: LossyDragon Date: Sun, 28 Jul 2024 20:47:44 -0500 Subject: [PATCH 1/3] Add Chat and Ui modes to LogOnDetails --- .../SampleUnifiedMessages.java | 16 ++----- .../steam/handlers/steamuser/ChatMode.kt | 17 ++++++++ .../handlers/steamuser/LogOnDetails.java | 43 +++++++++++++++++++ .../steam/handlers/steamuser/SteamUser.java | 8 ++++ .../steam/handlers/steamuser/UiMode.kt | 22 ++++++++++ 5 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt create mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt diff --git a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java index c6befcc0..9ec20aab 100644 --- a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java +++ b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java @@ -1,18 +1,16 @@ package in.dragonbra.javasteamsamples._8UnifiedMessages; - -import in.dragonbra.javasteam.base.ClientMsgProtobuf; -import in.dragonbra.javasteam.enums.EMsg; import in.dragonbra.javasteam.enums.EResult; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgClientUIMode; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesFriendmessagesSteamclient.CFriendMessages_IncomingMessage_Notification; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesPlayerSteamclient.*; import in.dragonbra.javasteam.rpc.service.Player; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.callback.ServiceMethodNotification; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.callback.ServiceMethodResponse; +import in.dragonbra.javasteam.steam.handlers.steamuser.ChatMode; import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails; import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser; +import in.dragonbra.javasteam.steam.handlers.steamuser.UiMode; import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOffCallback; import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOnCallback; import in.dragonbra.javasteam.steam.steamclient.SteamClient; @@ -127,6 +125,8 @@ private void onConnected(ConnectedCallback callback) { LogOnDetails details = new LogOnDetails(); details.setUsername(user); details.setPassword(pass); + details.setUiMode(UiMode.DEFAULT); + details.setChatMode(ChatMode.NEW_STEAM_CHAT); // Set LoginID to a non-zero value if you have another client connected using the same account, // the same private ip, and same public ip. @@ -164,14 +164,6 @@ private void onLoggedOn(LoggedOnCallback callback) { // at this point, we'd be able to perform actions on Steam - // Set our chat mode in order to use unified chat features - ClientMsgProtobuf uiMode = new ClientMsgProtobuf<>(CMsgClientUIMode.class, EMsg.ClientCurrentUIMode); - uiMode.getBody().setUimode(0); - uiMode.getBody().setChatMode(2); - - // Send our ClientCurrentUIMode request - steamClient.send(uiMode); - // first, build our request object, these are autogenerated and can normally be found in the in.dragonbra.javasteam.protobufs.steamclient package CPlayer_GetFavoriteBadge_Request.Builder favoriteBadgeRequest = CPlayer_GetFavoriteBadge_Request.newBuilder(); favoriteBadgeRequest.setSteamid(steamClient.getSteamID().convertToUInt64()); diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt new file mode 100644 index 00000000..23dc48cd --- /dev/null +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt @@ -0,0 +1,17 @@ +package `in`.dragonbra.javasteam.steam.handlers.steamuser + +/** + * Represents the chat mode for logging into Steam. + */ +@Suppress("unused") +enum class ChatMode(val mode: Int) { + /** + * The default chat mode. + */ + DEFAULT(0), + + /** + * The chat mode for new Steam group chat. + */ + NEW_STEAM_CHAT(1), +} diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java index 1cc11b09..f02725a3 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java @@ -40,6 +40,10 @@ public class LogOnDetails { private String machineName; + private ChatMode chatMode; + + private UiMode uiMode; + public LogOnDetails() { accountInstance = SteamID.DESKTOP_INSTANCE; accountID = 0L; @@ -52,6 +56,9 @@ public LogOnDetails() { envName = System.getenv("HOSTNAME"); } machineName = envName + " (JavaSteam)"; + + chatMode = ChatMode.DEFAULT; + uiMode = UiMode.DEFAULT; } /** @@ -324,4 +331,40 @@ public String getMachineName() { public void setMachineName(String machineName) { this.machineName = machineName; } + + /** + * Gets the chat mode. + * + * @return the {@link ChatMode} + */ + public ChatMode getChatMode() { + return chatMode; + } + + /** + * Sets the chat mode. + * + * @param chatMode the chat mode {@link ChatMode} + */ + public void setChatMode(ChatMode chatMode) { + this.chatMode = chatMode; + } + + /** + * Gets the ui mode. + * + * @return the {@link UiMode} + */ + public UiMode getUiMode() { + return uiMode; + } + + /** + * Sets the ui mode. + * + * @param uiMode the ui mode {@link UiMode} + */ + public void setUiMode(UiMode uiMode) { + this.uiMode = uiMode; + } } diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java index 05ddae91..b14757df 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java @@ -128,6 +128,14 @@ public void logOn(LogOnDetails details) { logon.getBody().setMachineName(details.getMachineName()); logon.getBody().setMachineId(ByteString.copyFrom(HardwareUtils.getMachineID())); + if (details.getChatMode() != ChatMode.DEFAULT) { + logon.getBody().setChatMode(details.getChatMode().getMode()); + } + + if (details.getUiMode() != UiMode.DEFAULT) { + logon.getBody().setUiMode(details.getUiMode().getMode()); + } + // steam guard if (!Strings.isNullOrEmpty(details.getAuthCode())) { logon.getBody().setAuthCode(details.getAuthCode()); diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt new file mode 100644 index 00000000..89a112ed --- /dev/null +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt @@ -0,0 +1,22 @@ +package `in`.dragonbra.javasteam.steam.handlers.steamuser + +/** + * Represents the ui mode for logging into Steam. + */ +@Suppress("unused") +enum class UiMode(val mode: Int) { + /** + * The default ui mode + */ + DEFAULT(0), + + /** + * Big Picture ui mode. + */ + BIG_PICTURE(1), + + /** + * Mobile (phone) ui mode. + */ + MOBILE(2), +} From 778969827cd3d407caa5d450235e5c075920679a Mon Sep 17 00:00:00 2001 From: LossyDragon Date: Tue, 30 Jul 2024 19:47:22 -0500 Subject: [PATCH 2/3] Generate UIMode from enums.steamd --- .../SampleUnifiedMessages.java | 4 ++-- .../handlers/steamuser/LogOnDetails.java | 13 ++++++----- .../steam/handlers/steamuser/SteamUser.java | 5 +++-- .../steam/handlers/steamuser/UiMode.kt | 22 ------------------- .../in/dragonbra/javasteam/enums.steamd | 12 ++++++++++ 5 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt diff --git a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java index 9ec20aab..3fd10f00 100644 --- a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java +++ b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java @@ -1,6 +1,7 @@ package in.dragonbra.javasteamsamples._8UnifiedMessages; import in.dragonbra.javasteam.enums.EResult; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesFriendmessagesSteamclient.CFriendMessages_IncomingMessage_Notification; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesPlayerSteamclient.*; import in.dragonbra.javasteam.rpc.service.Player; @@ -10,7 +11,6 @@ import in.dragonbra.javasteam.steam.handlers.steamuser.ChatMode; import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails; import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser; -import in.dragonbra.javasteam.steam.handlers.steamuser.UiMode; import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOffCallback; import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOnCallback; import in.dragonbra.javasteam.steam.steamclient.SteamClient; @@ -125,7 +125,7 @@ private void onConnected(ConnectedCallback callback) { LogOnDetails details = new LogOnDetails(); details.setUsername(user); details.setPassword(pass); - details.setUiMode(UiMode.DEFAULT); + details.setUiMode(EUIMode.Unknown); details.setChatMode(ChatMode.NEW_STEAM_CHAT); // Set LoginID to a non-zero value if you have another client connected using the same account, diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java index f02725a3..3ec24e4c 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java @@ -1,6 +1,7 @@ package in.dragonbra.javasteam.steam.handlers.steamuser; import in.dragonbra.javasteam.enums.EOSType; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.steam.authentication.AuthPollResult; import in.dragonbra.javasteam.steam.authentication.SteamAuthentication; import in.dragonbra.javasteam.types.SteamID; @@ -42,7 +43,7 @@ public class LogOnDetails { private ChatMode chatMode; - private UiMode uiMode; + private EUIMode uiMode; public LogOnDetails() { accountInstance = SteamID.DESKTOP_INSTANCE; @@ -58,7 +59,7 @@ public LogOnDetails() { machineName = envName + " (JavaSteam)"; chatMode = ChatMode.DEFAULT; - uiMode = UiMode.DEFAULT; + uiMode = EUIMode.Unknown; } /** @@ -353,18 +354,18 @@ public void setChatMode(ChatMode chatMode) { /** * Gets the ui mode. * - * @return the {@link UiMode} + * @return the {@link EUIMode} */ - public UiMode getUiMode() { + public EUIMode getUiMode() { return uiMode; } /** * Sets the ui mode. * - * @param uiMode the ui mode {@link UiMode} + * @param uiMode the ui mode {@link EUIMode} */ - public void setUiMode(UiMode uiMode) { + public void setUiMode(EUIMode uiMode) { this.uiMode = uiMode; } } diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java index b14757df..b48d2aa8 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java @@ -7,6 +7,7 @@ import in.dragonbra.javasteam.enums.EAccountType; import in.dragonbra.javasteam.enums.EMsg; import in.dragonbra.javasteam.enums.EResult; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.generated.MsgClientLogOnResponse; import in.dragonbra.javasteam.generated.MsgClientLoggedOff; import in.dragonbra.javasteam.generated.MsgClientLogon; @@ -132,8 +133,8 @@ public void logOn(LogOnDetails details) { logon.getBody().setChatMode(details.getChatMode().getMode()); } - if (details.getUiMode() != UiMode.DEFAULT) { - logon.getBody().setUiMode(details.getUiMode().getMode()); + if (details.getUiMode() != EUIMode.Unknown) { + logon.getBody().setUiMode(details.getUiMode().code()); } // steam guard diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt deleted file mode 100644 index 89a112ed..00000000 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/UiMode.kt +++ /dev/null @@ -1,22 +0,0 @@ -package `in`.dragonbra.javasteam.steam.handlers.steamuser - -/** - * Represents the ui mode for logging into Steam. - */ -@Suppress("unused") -enum class UiMode(val mode: Int) { - /** - * The default ui mode - */ - DEFAULT(0), - - /** - * Big Picture ui mode. - */ - BIG_PICTURE(1), - - /** - * Mobile (phone) ui mode. - */ - MOBILE(2), -} diff --git a/src/main/steamd/in/dragonbra/javasteam/enums.steamd b/src/main/steamd/in/dragonbra/javasteam/enums.steamd index 746d13d9..26245299 100644 --- a/src/main/steamd/in/dragonbra/javasteam/enums.steamd +++ b/src/main/steamd/in/dragonbra/javasteam/enums.steamd @@ -1661,3 +1661,15 @@ enum ELauncherType SingleApp = 8; GameServer = 9; } + +public enum EUIMode +{ + Unknown = -1; + VGUI = 0; + Tenfoot = 1; + Mobile = 2; + Web = 3; + ClientUI = 4; + MobileChat = 5; + EmbeddedClient = 6; +} From 139a21d344432b7b53240bc5479df189fbbf14c1 Mon Sep 17 00:00:00 2001 From: LossyDragon Date: Fri, 2 Aug 2024 17:47:48 -0500 Subject: [PATCH 3/3] Add steam deck login field --- .../handlers/steamuser/LogOnDetails.java | 21 +++++++++++++++++++ .../steam/handlers/steamuser/SteamUser.java | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java index 3ec24e4c..efbb5ba5 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java @@ -45,6 +45,8 @@ public class LogOnDetails { private EUIMode uiMode; + private boolean isSteamDeck; + public LogOnDetails() { accountInstance = SteamID.DESKTOP_INSTANCE; accountID = 0L; @@ -60,6 +62,7 @@ public LogOnDetails() { chatMode = ChatMode.DEFAULT; uiMode = EUIMode.Unknown; + isSteamDeck = false; } /** @@ -368,4 +371,22 @@ public EUIMode getUiMode() { public void setUiMode(EUIMode uiMode) { this.uiMode = uiMode; } + + /** + * Gets whether this is Steam Deck login. + * + * @return The Steam Deck login value. + */ + public boolean isSteamDeck() { + return isSteamDeck; + } + + /** + * Sets whether this is Steam Deck login. + * + * @param steamDeck The Steam Deck login value. + */ + public void setSteamDeck(boolean steamDeck) { + isSteamDeck = steamDeck; + } } diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java index b48d2aa8..c5d8ad88 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java @@ -137,6 +137,10 @@ public void logOn(LogOnDetails details) { logon.getBody().setUiMode(details.getUiMode().code()); } + if (details.isSteamDeck()) { + logon.getBody().setIsSteamDeck(true); + } + // steam guard if (!Strings.isNullOrEmpty(details.getAuthCode())) { logon.getBody().setAuthCode(details.getAuthCode());