Skip to content

Commit

Permalink
Update to Steamworks 1.60 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfairh authored Jul 9, 2024
1 parent 7273b03 commit 38404ca
Show file tree
Hide file tree
Showing 22 changed files with 254 additions and 20 deletions.
2 changes: 2 additions & 0 deletions DocIndex/docc-custom-topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
- <doc:SteamRemotePlay-Interface>
- <doc:SteamRemoteStorage-Interface>
- <doc:SteamScreenshots-Interface>
- <doc:SteamTimeline-Interface>
- <doc:SteamUGC-Interface>
- <doc:SteamUser-Interface>
- <doc:SteamUserStats-Interface>
- <doc:SteamUtils-Interface>
- <doc:SteamVideo-Interface>
### Common Types
- <doc:Common-Types>
- ``SteamConstants``
19 changes: 19 additions & 0 deletions DocIndex/jazzy-custom-groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@
children:
- ScreenshotReady
- ScreenshotRequested
- name: SteamTimeline
topics:
- name: Interfaces
children:
- SteamTimeline
- name: Enumerations and Option Sets
children:
- TimelineEventClipPriority
- TimelineGameMode
- name: SteamUGC
topics:
- name: Interfaces
Expand Down Expand Up @@ -624,6 +633,15 @@
- LowBatteryPower
- SteamAPICallCompleted
- SteamShutdown
- name: SteamVideo
topics:
- name: Interfaces
children:
- SteamVideo
- name: Callbacks
children:
- GetOPFSettingsResult
- GetVideoURLResult
- name: Common Types
topics:
- name: Simple types
Expand All @@ -647,6 +665,7 @@
- AccountType
- AuthSessionResponse
- BeginAuthSessionResult
- BetaBranchFlags
- BroadcastUploadResult
- ChatEntryType
- ChatRoomEnterResponse
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![macOS](https://shields.io/badge/platform-macOS%20|%20Linux%20|%20%3F%3F-lightgrey)
![Steamworks 1.59](https://shields.io/badge/steamworks-1.59-lightgrey)
![Steamworks 1.60](https://shields.io/badge/steamworks-1.60-lightgrey)
[![Test](https://github.com/johnfairh/steamworks-swift/actions/workflows/test.yml/badge.svg)](https://github.com/johnfairh/steamworks-swift/actions/workflows/test.yml)
![MIT](https://shields.io/badge/license-MIT-black)

Expand Down
4 changes: 2 additions & 2 deletions Sources/CSteamworks/steamapi_headers.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <steam/steam_api.h>
#include <steam/steam_gameserver.h>

// Steamworks 1.59 still has fucked up SteamVideo json
S_API ISteamVideo *SteamAPI_SteamVideo_v004();
//// Steamworks 1.59 still has fucked up SteamVideo json
//S_API ISteamVideo *SteamAPI_SteamVideo_v004();

#include <steam/steam_api_flat.h>
#include <steam/steamnetworkingfakeip.h>
Expand Down
2 changes: 0 additions & 2 deletions Sources/LibGenerate/DocStructure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ struct DocStructure {
"isteamgamecoordinator.h", // ??
"isteamps3overlayrenderer.h", // PS3
"isteamnetworking.h", // deprecated

"isteamvideo.h" // randomly broken in 1.59
])

guard !ignoredISteamHeaders.contains(filename) else {
Expand Down
5 changes: 3 additions & 2 deletions Sources/LibGenerate/Interfaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ extension SteamHungarianName {
private extension SwiftExpr {
/// New identifiers from old
func withPrefix(_ prefix: String) -> SwiftExpr {
"\(prefix)\(expr.prefix(1).uppercased())\(expr.dropFirst())"
let bareExpr = expr.replacingOccurrences(of: "`", with: "")
return "\(prefix)\(bareExpr.prefix(1).uppercased())\(bareExpr.dropFirst())"
}
}

Expand Down Expand Up @@ -583,7 +584,7 @@ extension Array where Element == SteamParam {
} else {
let rcTuple = rcText.flatMap { "rc: \($0), "} ?? ""
let outTuple = map { param in
"\(param.swiftName): \(param[keyPath: paramField])"
"\(param.swiftName.withoutBackticks): \(param[keyPath: paramField])"
}.commaJoined
return T("(\(rcTuple)\(outTuple))")
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/LibGenerate/Resources/EXPECTED_SDK
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.59
1.60
19 changes: 17 additions & 2 deletions Sources/LibGenerate/Resources/steam_api_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ consts:
type: HHTMLBrowser
STEAM_INPUT_HANDLE_ALL_CONTROLLERS:
nested_name: allControllers
k_flMaxTimelineEventDuration:
value: '600'
consts_to_ignore:
- k_cchMaxSteamErrMsg
- k_cchPublishedDocumentChangeDescriptionMax
Expand Down Expand Up @@ -69,6 +71,9 @@ typedefs_to_ignore:
enums:
AudioPlayback_Status:
prefix: AudioPlayback
EBetaBranchFlags:
is_set: uint32
prefix: EBetaBranch
EChatEntryType:
intx_to_self: uint8
EChatMemberStateChange:
Expand Down Expand Up @@ -161,8 +166,6 @@ enums:
ESteamNetworkingSendFlags:
is_set: Int32
prefix: nSteamNetworkingSend
ETimelineGameMode:
ignore: "In metadata but not header"
EUGCContentDescriptorID:
prefix: EUGCContentDescriptor
EUGCReadAction:
Expand Down Expand Up @@ -226,6 +229,14 @@ methods:
out_string_count: cchFolderBufferSize
cchFolderBufferSize:
default_value: k_cchFilenameMax
SteamAPI_ISteamApps_GetBetaInfo:
params:
punFlags:
type: EBetaBranchFlags *
pchBetaName:
out_string_count: cchBetaName
pchDescription:
out_string_count: cchDescription
SteamAPI_ISteamApps_GetCurrentBetaName:
params:
pchName:
Expand Down Expand Up @@ -1039,6 +1050,10 @@ methods:
pvecPublishedFileID:
out_array_count: cMaxEntries
out_array_valid_count: 'rc'
SteamAPI_ISteamUGC_GetSupportedGameVersionData:
params:
versionIndex:
name: iVersionIndex
SteamAPI_ISteamUGC_ReleaseQueryUGCRequest:
discardable_result: true
SteamAPI_ISteamUGC_RemoveItemKeyValueTags:
Expand Down
4 changes: 4 additions & 0 deletions Sources/LibGenerate/SteamSwiftTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,8 @@ struct SwiftExpr: StringFungible {
}

var _val: String { expr }

var withoutBackticks: SwiftExpr {
SwiftExpr(expr.re_sub("`", with: ""))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- ``AccountType``
- ``AuthSessionResponse``
- ``BeginAuthSessionResult``
- ``BetaBranchFlags``
- ``BroadcastUploadResult``
- ``ChatEntryType``
- ``ChatRoomEnterResponse``
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SteamTimeline Interface

## Topics

### Interfaces
- ``SteamTimeline``

### Enumerations and Option Sets
- ``TimelineEventClipPriority``
- ``TimelineGameMode``
7 changes: 5 additions & 2 deletions Sources/Steamworks/Generated/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ public enum SteamConstants {
/// Steamworks `k_cbMaxSteamNetworkingSocketsMessageSizeSend`
public static let maxSteamNetworkingSocketsMessageSizeSendSize = Int(512 * 1024)

/// Steamworks `k_nMaxTimelineRangeIDLength`
public static let maxTimelineRangeIDLength = Int(64)
/// Steamworks `k_flMaxTimelineEventDuration`
public static let maxTimelineEventDuration = Float(600)

/// Steamworks `k_unMaxTimelinePriority`
public static let maxTimelinePriority = Int(1000)

/// Steamworks `kNumUGCResultsPerPage`
public static let numUGCResultsPerPage = Int(50)
Expand Down
72 changes: 70 additions & 2 deletions Sources/Steamworks/Generated/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ extension EBeginAuthSessionResult: RawConvertible { typealias From = BeginAuthSe
extension BeginAuthSessionResult: EnumWithUnrepresented { typealias From = EBeginAuthSessionResult }
extension BeginAuthSessionResult: SteamCreatable {}

/// Steamworks `EBetaBranchFlags`
public struct BetaBranchFlags: OptionSet, Sendable {
/// The flags value.
public let rawValue: CUnsignedInt
/// Create a new instance with `rawValue` flags set.
public init(rawValue: CUnsignedInt) { self.rawValue = rawValue }
/// Steamworks `k_EBetaBranch_None`
public static let none = BetaBranchFlags([])
/// Steamworks `k_EBetaBranch_Default`
public static let `default` = BetaBranchFlags(rawValue: 1)
/// Steamworks `k_EBetaBranch_Available`
public static let available = BetaBranchFlags(rawValue: 2)
/// Steamworks `k_EBetaBranch_Private`
public static let `private` = BetaBranchFlags(rawValue: 4)
/// Steamworks `k_EBetaBranch_Selected`
public static let selected = BetaBranchFlags(rawValue: 8)
/// Steamworks `k_EBetaBranch_Installed`
public static let installed = BetaBranchFlags(rawValue: 16)
}

extension EBetaBranchFlags: RawConvertible { typealias From = BetaBranchFlags }
extension BetaBranchFlags: RawConvertible { typealias From = EBetaBranchFlags }
extension BetaBranchFlags: SteamCreatable {}

/// Steamworks `EBroadcastUploadResult`
public enum BroadcastUploadResult: CUnsignedInt, Sendable {
/// Steamworks `k_EBroadcastUploadResultNone`
Expand Down Expand Up @@ -2042,10 +2066,12 @@ public enum ParentalFeature: CUnsignedInt, Sendable {
case siteLicense = 13
/// Steamworks `k_EFeatureKioskMode_Deprecated`
case kioskModeDeprecated = 14
/// Steamworks `k_EFeatureBlockAlways`
case blockAlways = 15
/// Steamworks `k_EFeatureMax`
case max = 15
case max = 16
/// Some undocumented value
case unrepresentedInSwift = 16
case unrepresentedInSwift = 17
}

extension EParentalFeature: RawConvertible { typealias From = ParentalFeature }
Expand Down Expand Up @@ -2974,6 +3000,8 @@ public enum SteamNetworkingConfigValueSetting: CUnsignedInt, Sendable {
case nagleTime = 12
/// Steamworks `k_ESteamNetworkingConfig_IP_AllowWithoutAuth`
case ipAllowWithoutAuth = 23
/// Steamworks `k_ESteamNetworkingConfig_IPLocalHost_AllowWithoutAuth`
case ipLocalHostAllowWithoutAuth = 52
/// Steamworks `k_ESteamNetworkingConfig_MTU_PacketSize`
case mtuPacketSize = 32
/// Steamworks `k_ESteamNetworkingConfig_MTU_DataSize`
Expand Down Expand Up @@ -3298,6 +3326,46 @@ extension ETextFilteringContext: RawConvertible { typealias From = TextFiltering
extension TextFilteringContext: EnumWithUnrepresented { typealias From = ETextFilteringContext }
extension TextFilteringContext: SteamCreatable {}

/// Steamworks `ETimelineEventClipPriority`
public enum TimelineEventClipPriority: CUnsignedInt, Sendable {
/// Steamworks `k_ETimelineEventClipPriority_Invalid`
case invalid = 0
/// Steamworks `k_ETimelineEventClipPriority_None`
case none = 1
/// Steamworks `k_ETimelineEventClipPriority_Standard`
case standard = 2
/// Steamworks `k_ETimelineEventClipPriority_Featured`
case featured = 3
/// Some undocumented value
case unrepresentedInSwift = 4
}

extension ETimelineEventClipPriority: RawConvertible { typealias From = TimelineEventClipPriority }
extension TimelineEventClipPriority: EnumWithUnrepresented { typealias From = ETimelineEventClipPriority }
extension TimelineEventClipPriority: SteamCreatable {}

/// Steamworks `ETimelineGameMode`
public enum TimelineGameMode: CUnsignedInt, Sendable {
/// Steamworks `k_ETimelineGameMode_Invalid`
case invalid = 0
/// Steamworks `k_ETimelineGameMode_Playing`
case playing = 1
/// Steamworks `k_ETimelineGameMode_Staging`
case staging = 2
/// Steamworks `k_ETimelineGameMode_Menus`
case menus = 3
/// Steamworks `k_ETimelineGameMode_LoadingScreen`
case loadingScreen = 4
/// Steamworks `k_ETimelineGameMode_Max`
case max = 5
/// Some undocumented value
case unrepresentedInSwift = 6
}

extension ETimelineGameMode: RawConvertible { typealias From = TimelineGameMode }
extension TimelineGameMode: EnumWithUnrepresented { typealias From = ETimelineGameMode }
extension TimelineGameMode: SteamCreatable {}

/// Steamworks `EUGCContentDescriptorID`
public enum UGCContentDescriptorID: CUnsignedInt, Sendable {
/// Steamworks `k_EUGCContentDescriptor_NudityOrSexualContent`
Expand Down
27 changes: 27 additions & 0 deletions Sources/Steamworks/Generated/SteamApps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ public struct SteamApps: Sendable {
String(SteamAPI_ISteamApps_GetAvailableGameLanguages(interface))
}

/// Steamworks `ISteamApps::GetBetaInfo()`
public func getBetaInfo(appID: AppID, betaIndex: Int, betaNameSize: Int, descriptionSize: Int) -> (rc: Bool, flags: BetaBranchFlags, buildID: Int, betaName: String, description: String) {
var tmpFlags = uint32()
var tmpBuildID = uint32()
var tmpBetaName = SteamOutString(length: betaNameSize)
var tmpDescription = SteamOutString(length: descriptionSize)
let rc = tmpBetaName.setContent { nstBetaName in
tmpDescription.setContent { nstDescription in
SteamAPI_ISteamApps_GetBetaInfo(interface, AppId_t(appID), CInt(betaIndex), &tmpFlags, &tmpBuildID, nstBetaName, CInt(betaNameSize), nstDescription, CInt(descriptionSize))
}
}
return (rc: rc, flags: BetaBranchFlags(tmpFlags), buildID: Int(tmpBuildID), betaName: tmpBetaName.swiftString, description: tmpDescription.swiftString)
}

/// Steamworks `ISteamApps::GetCurrentBetaName()`
public func getCurrentBetaName(nameBufferSize: Int) -> (rc: Bool, name: String) {
var tmpName = SteamOutString(length: nameBufferSize)
Expand Down Expand Up @@ -181,6 +195,14 @@ public struct SteamApps: Sendable {
String(SteamAPI_ISteamApps_GetLaunchQueryParam(interface, key))
}

/// Steamworks `ISteamApps::GetNumBetas()`
public func getNumBetas(appID: AppID) -> (rc: Int, available: Int, private: Int) {
var tmpAvailable = CInt()
var tmpPrivate = CInt()
let rc = Int(SteamAPI_ISteamApps_GetNumBetas(interface, AppId_t(appID), &tmpAvailable, &tmpPrivate))
return (rc: rc, available: Int(tmpAvailable), private: Int(tmpPrivate))
}

/// Steamworks `ISteamApps::InstallDLC()`
public func installDLC(appID: AppID) {
SteamAPI_ISteamApps_InstallDLC(interface, AppId_t(appID))
Expand All @@ -201,6 +223,11 @@ public struct SteamApps: Sendable {
SteamAPI_ISteamApps_RequestAppProofOfPurchaseKey(interface, AppId_t(appID))
}

/// Steamworks `ISteamApps::SetActiveBeta()`
public func setActiveBeta(appID: AppID, betaName: String) -> Bool {
SteamAPI_ISteamApps_SetActiveBeta(interface, AppId_t(appID), betaName)
}

/// Steamworks `ISteamApps::SetDlcContext()`
public func setDlcContext(appID: AppID) -> Bool {
SteamAPI_ISteamApps_SetDlcContext(interface, AppId_t(appID))
Expand Down
2 changes: 1 addition & 1 deletion Sources/Steamworks/Generated/SteamBaseAPI+Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ extension SteamBaseAPI {
/// The version string of the Steamworks SDK that the Steamworks
/// module was generated from, for example. "1.52".
public static var steamworksVersion: String {
"1.59"
"1.60"
}
}
41 changes: 41 additions & 0 deletions Sources/Steamworks/Generated/SteamTimeline.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// SteamTimeline.swift
// Steamworks
//
// Licensed under MIT (https://github.com/johnfairh/steamworks-swift/blob/main/LICENSE
//
// This file is generated code: any edits will be overwritten.

internal import CSteamworks

/// Steamworks [`ISteamTimeline`](https://partner.steamgames.com/doc/api/ISteamTimeline)
///
/// Access via ``SteamAPI/timeline``.
public struct SteamTimeline: Sendable {
var interface: UnsafeMutablePointer<ISteamTimeline> {
SteamAPI_SteamTimeline_v001()
}

init() {
}

/// Steamworks `ISteamTimeline::AddTimelineEvent()`
public func addTimelineEvent(icon: String, title: String, description: String, priority: Int, startOffsetSeconds: Float, durationSeconds: Float, possibleClip: TimelineEventClipPriority) {
SteamAPI_ISteamTimeline_AddTimelineEvent(interface, icon, title, description, uint32(priority), startOffsetSeconds, durationSeconds, ETimelineEventClipPriority(possibleClip))
}

/// Steamworks `ISteamTimeline::ClearTimelineStateDescription()`
public func clearTimelineStateDescription(timeDelta: Float) {
SteamAPI_ISteamTimeline_ClearTimelineStateDescription(interface, timeDelta)
}

/// Steamworks `ISteamTimeline::SetTimelineGameMode()`
public func setTimelineGameMode(mode: TimelineGameMode) {
SteamAPI_ISteamTimeline_SetTimelineGameMode(interface, ETimelineGameMode(mode))
}

/// Steamworks `ISteamTimeline::SetTimelineStateDescription()`
public func setTimelineStateDescription(description: String, timeDelta: Float) {
SteamAPI_ISteamTimeline_SetTimelineStateDescription(interface, description, timeDelta)
}
}
Loading

0 comments on commit 38404ca

Please sign in to comment.