Skip to content

Commit b7c7839

Browse files
committed
Add subscript getter
1 parent 8e3bff1 commit b7c7839

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/GateEngine/System/HID/GamePad/GamePad.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,16 @@ extension GamePad {
579579
public var isPressed: Bool {
580580
return north.isPressed || south.isPressed || west.isPressed || east.isPressed
581581
}
582+
583+
public subscript (_ id: InternalID) -> ButtonState {
584+
switch id {
585+
case .north: return self.north
586+
case .south: return self.south
587+
case .west: return self.west
588+
case .east: return self.east
589+
default: fatalError("Unhandled button ID: \(id)")
590+
}
591+
}
582592

583593
internal func resetInputStates() {
584594
self.north.resetInputStates()

0 commit comments

Comments
 (0)