Restructured the source code in the Playdate bindings target.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension System {
|
||||
/// The state of the d-pad and face buttons, as an option set.
|
||||
public struct Buttons: OptionSet, Sendable {
|
||||
public let rawValue: UInt32
|
||||
public init(rawValue: UInt32) { self.rawValue = rawValue }
|
||||
init(_ buttons: PDButtons) { self.rawValue = UInt32(buttons.rawValue) }
|
||||
var cValue: PDButtons { PDButtons(PDButtons.RawValue(rawValue)) }
|
||||
|
||||
public static let left = Buttons(kButtonLeft)
|
||||
public static let right = Buttons(kButtonRight)
|
||||
public static let up = Buttons(kButtonUp)
|
||||
public static let down = Buttons(kButtonDown)
|
||||
public static let b = Buttons(kButtonB)
|
||||
public static let a = Buttons(kButtonA)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension System {
|
||||
/// A calendar date and time, mirroring `PDDateTime`.
|
||||
public struct DateTime: Sendable {
|
||||
public var year: UInt16
|
||||
/// 1...12
|
||||
public var month: UInt8
|
||||
/// 1...31
|
||||
public var day: UInt8
|
||||
/// 1 = Monday ... 7 = Sunday
|
||||
public var weekday: UInt8
|
||||
/// 0...23
|
||||
public var hour: UInt8
|
||||
public var minute: UInt8
|
||||
public var second: UInt8
|
||||
|
||||
public init(year: UInt16, month: UInt8, day: UInt8, weekday: UInt8 = 0,
|
||||
hour: UInt8, minute: UInt8, second: UInt8) {
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.day = day
|
||||
self.weekday = weekday
|
||||
self.hour = hour
|
||||
self.minute = minute
|
||||
self.second = second
|
||||
}
|
||||
|
||||
init(_ dateTime: PDDateTime) {
|
||||
year = dateTime.year
|
||||
month = dateTime.month
|
||||
day = dateTime.day
|
||||
weekday = dateTime.weekday
|
||||
hour = dateTime.hour
|
||||
minute = dateTime.minute
|
||||
second = dateTime.second
|
||||
}
|
||||
|
||||
var cValue: PDDateTime {
|
||||
PDDateTime(year: year, month: month, day: day, weekday: weekday,
|
||||
hour: hour, minute: minute, second: second)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
extension System {
|
||||
/// OS, language, and pdx version information, mirroring `PDInfo`.
|
||||
public struct Info: Sendable {
|
||||
public let osVersion: UInt32
|
||||
public let language: Language
|
||||
public let pdxVersion: UInt32
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension System {
|
||||
/// Peripherals that can be enabled with `setPeripheralsEnabled(_:)`.
|
||||
public struct Peripherals: OptionSet, Sendable {
|
||||
public let rawValue: UInt32
|
||||
public init(rawValue: UInt32) { self.rawValue = rawValue }
|
||||
|
||||
public static let none = Peripherals([])
|
||||
public static let accelerometer = Peripherals(rawValue: UInt32(kAccelerometer.rawValue))
|
||||
public static let all = Peripherals(rawValue: UInt32(kAllPeripherals.rawValue))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension System {
|
||||
/// Battery and power supply state.
|
||||
public struct PowerStatus: OptionSet, Sendable {
|
||||
public let rawValue: UInt32
|
||||
public init(rawValue: UInt32) { self.rawValue = rawValue }
|
||||
|
||||
public static let charging = PowerStatus(rawValue: UInt32(kPDPowerStatusCharging.rawValue))
|
||||
public static let usb = PowerStatus(rawValue: UInt32(kPDPowerStatusUsb.rawValue))
|
||||
public static let screws = PowerStatus(rawValue: UInt32(kPDPowerStatusScrews.rawValue))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user