Added missing documentation to the source code in the Playdate bindings target.
CI / Build & test (macOS) (push) Has been cancelled
CI / Embedded Swift cross-compile (push) Has been cancelled
Documentation / deploy (push) Has been cancelled

This commit is contained in:
2026-07-25 12:55:53 +02:00
parent b435a6e8bd
commit 91783deb7b
63 changed files with 259 additions and 3 deletions
@@ -1,6 +1,10 @@
/// The user's answer to a permission request (microphone, network).
public enum AccessReply: UInt32, Sendable {
/// The user has not answered yet; the request's completion delivers
/// the answer later.
case ask = 0
/// The user has already denied access; the completion is not called.
case deny = 1
/// The user has already granted access; the completion is not called.
case allow = 2
}
@@ -3,19 +3,34 @@ public import CPlaydate
/// A Swift view of `PDSystemEvent` with the key code folded into the
/// key events.
public enum SystemEvent {
/// Sent once at startup, before the first update.
case initialize
/// Sent when the Lua runtime is ready, for registering custom
/// functions and classes.
case initializeLua
/// The device was locked.
case lock
/// The device was unlocked.
case unlock
/// The game was paused (e.g. the system menu opened).
case pause
/// The game resumed after a pause.
case resume
/// The game is about to be terminated.
case terminate
/// A simulator key was pressed.
case keyPressed(keyCode: UInt32)
/// A simulator key was released.
case keyReleased(keyCode: UInt32)
/// The device is about to power down because the battery is low.
case lowPower
/// A Mirror session started.
case mirrorStarted
/// A Mirror session ended.
case mirrorEnded
/// Creates an event from the C event and its argument, or `nil` for
/// events unknown to this binding.
public init?(event: PDSystemEvent, argument: UInt32) {
switch event {
case kEventInit: self = .initialize
+7 -3
View File
@@ -1,8 +1,12 @@
public import CPlaydate
/// The raw C API bootstrap. Everything else in this module (System,
/// Graphics, Sprite, Sound, ...) lives at the top level of the `PlaydateKit`
/// module and requires `initialize(with:)` to have been called first.
/// The raw C API bootstrap.
///
/// The C API is delivered as a `PlaydateAPI` struct of function pointers
/// that the firmware hands to the game's `eventHandler` entry point. Call
/// `initialize(with:)` from that entry point before using any other API in
/// this module. Everything else (System, Graphics, Sprite, Sound, ...)
/// lives at the top level of the `PlaydateKit` module.
public enum Playdate {
/// The raw C API. Populated by `initialize(with:)`.
///
@@ -1,11 +1,15 @@
/// An error reported by the Playdate OS.
public struct PlaydateError: Swift.Error, Sendable {
/// The message reported by the OS, or a description of the failure.
public let message: String
/// Creates an error with the given message.
init(message: String) {
self.message = message
}
/// Creates an error by copying an OS-provided C string; a nil pointer
/// produces "unknown error".
init(cString: UnsafePointer<CChar>?) {
self.init(message: String(playdateCString: cString) ?? "unknown error")
}