@@ -326,26 +326,6 @@ extension GamePad {
326326 self . menu. resetInputStates ( )
327327 }
328328
329- @MainActor @propertyWrapper public struct Polled < T> {
330- weak var gamePad : GamePad ? = nil
331- var _wrappedValue : T
332- public var wrappedValue : T {
333- get {
334- gamePad? . interpreter. hid. gamePads. pollIfNeeded ( )
335- return _wrappedValue
336- }
337- set {
338- _wrappedValue = newValue
339- }
340- }
341- public init ( wrappedValue: T ) {
342- _wrappedValue = wrappedValue
343- }
344- mutating func configureWith( gamePad: GamePad ? ) {
345- self . gamePad = gamePad
346- }
347- }
348-
349329 @MainActor @propertyWrapper public struct AnalogUpdatingPolled {
350330 weak var gamePad : GamePad ? = nil
351331 weak var button : ButtonState ? = nil
@@ -405,17 +385,23 @@ extension GamePad {
405385 }
406386 }
407387
408- @MainActor public class ButtonState {
388+ @MainActor public final class ButtonState {
409389 weak var gamePad : GamePad ?
410390 let id : InternalID
411391 var currentReceipt : UInt8 = 0
412-
392+ var _isPressed : Bool = false
393+
413394 /// `true` if the button is considered down.
414- @Polled public internal( set) var isPressed : Bool = false {
415- didSet {
416- if isPressed != oldValue {
395+ public var isPressed : Bool {
396+ get {
397+ gamePad? . interpreter. hid. gamePads. pollIfNeeded ( )
398+ return _isPressed
399+ }
400+ set {
401+ if _isPressed != newValue {
417402 currentReceipt &+= 1
418403 }
404+ _isPressed = newValue
419405 }
420406 }
421407
@@ -466,25 +452,40 @@ extension GamePad {
466452 self . gamePad = gamePad
467453 self . id = id
468454
469- self . _isPressed. configureWith ( gamePad: gamePad)
470455 self . _value. configureWith ( gamePad: gamePad, button: self )
471456 }
472457 }
473458
474- @MainActor public class StickState {
459+ @MainActor public final class StickState {
475460 weak var gamePad : GamePad ?
476461 let id : InternalID
477462 init ( gamePad: GamePad ? , id: InternalID ) {
478463 self . gamePad = gamePad
479464 self . id = id
480-
481- self . _xAxis. configureWith ( gamePad: gamePad)
482- self . _yAxis. configureWith ( gamePad: gamePad)
483465 }
484466
485- @Polled public internal( set) var xAxis : Float = 0
486- @Polled public internal( set) var yAxis : Float = 0
487-
467+ var _xAxis : Float = 0
468+ public var xAxis : Float {
469+ get {
470+ gamePad? . interpreter. hid. gamePads. pollIfNeeded ( )
471+ return _xAxis
472+ }
473+ set {
474+ _xAxis = newValue
475+ }
476+ }
477+
478+ var _yAxis : Float = 0
479+ public var yAxis : Float {
480+ get {
481+ gamePad? . interpreter. hid. gamePads. pollIfNeeded ( )
482+ return _yAxis
483+ }
484+ set {
485+ _yAxis = newValue
486+ }
487+ }
488+
488489 public func xAxisWithDeadzone( _ deadzone: Float = defaultDeadzone) -> Float {
489490 guard abs ( xAxis) > deadzone else { return 0 }
490491 return xAxis
@@ -527,7 +528,7 @@ extension GamePad {
527528 nonisolated public static let defaultDeadzone : Float = 0.1
528529 }
529530
530- @MainActor public class DPad {
531+ @MainActor public final class DPad {
531532 weak var gamePad : GamePad ?
532533 init ( gamePad: GamePad ? ) {
533534 self . gamePad = gamePad
@@ -550,7 +551,7 @@ extension GamePad {
550551 }
551552 }
552553
553- @MainActor public class Buttons {
554+ @MainActor public final class Buttons {
554555 weak var gamePad : GamePad ?
555556 init ( gamePad: GamePad ? ) {
556557 self . gamePad = gamePad
@@ -587,7 +588,7 @@ extension GamePad {
587588 }
588589 }
589590
590- @MainActor public class Shoulders {
591+ @MainActor public final class Shoulders {
591592 weak var gamePad : GamePad ?
592593 init ( gamePad: GamePad ? ) {
593594 self . gamePad = gamePad
@@ -612,7 +613,7 @@ extension GamePad {
612613 }
613614 }
614615
615- @MainActor public class Triggers {
616+ @MainActor public final class Triggers {
616617 weak var gamePad : GamePad ?
617618 init ( gamePad: GamePad ? ) {
618619 self . gamePad = gamePad
@@ -637,7 +638,7 @@ extension GamePad {
637638 }
638639 }
639640
640- @MainActor public class Sticks {
641+ @MainActor public final class Sticks {
641642 weak var gamePad : GamePad ?
642643 init ( gamePad: GamePad ? ) {
643644 self . gamePad = gamePad
@@ -660,7 +661,7 @@ extension GamePad {
660661 }
661662 }
662663
663- @MainActor public class Menu {
664+ @MainActor public final class Menu {
664665 weak var gamePad : GamePad ?
665666 init ( gamePad: GamePad ? ) {
666667 self . gamePad = gamePad
0 commit comments