Skip to content

Commit a2ebac6

Browse files
committed
Improvements for tvOS
1 parent 781dfb5 commit a2ebac6

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

Sources/GameControllerKit/GCKMovePosition.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,29 @@ public enum GCKMovePosition: Comparable {
4444
/// The thumbstick position is unknown (usually a phase in between a position and center)
4545
/// if it keeps being unknown, check if the event you are sending is correct.
4646
case unknown
47+
48+
public var arrowRepresentation: String {
49+
switch self {
50+
case .up:
51+
""
52+
case .upRight:
53+
""
54+
case .right:
55+
""
56+
case .downRight:
57+
""
58+
case .down:
59+
""
60+
case .downLeft:
61+
""
62+
case .left:
63+
""
64+
case .upLeft:
65+
""
66+
case .centered:
67+
""
68+
case .unknown:
69+
""
70+
}
71+
}
4772
}

Sources/GameControllerKit/GameControllerKit.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public class GameControllerKit: ObservableObject {
8080

8181
self.eventHandler = { [weak self] button, pressed, controller in
8282
let message = "Controller #\(String(describing: controller.playerIndex.rawValue)), " +
83-
"Button \(String(describing: button)) is \(pressed ? "Pressed" : "Unpressed")"
83+
"Button \(String(describing: button)) \(button.position.arrowRepresentation) " +
84+
"is \(pressed ? "Pressed" : "Unpressed")"
8485

8586
self?.logger.info("\(String(describing: message))")
8687
}
@@ -201,18 +202,18 @@ public class GameControllerKit: ObservableObject {
201202
}
202203

203204
let contr = String(describing: currentControllerType)
204-
logger.info("Did connect controller \(currentController.productCategory) recognized as \(contr).")
205+
logger.info(
206+
"Did connect controller \(currentController.productCategory) recognized as \(contr)."
207+
)
205208

206-
logger.info("CONNECTED: \(self.controllers.count)")
207-
208-
// Disfavor Siri Remote over a external controller.
209-
if (currentControllerType == .siriRemote && controllers.count == 1) ||
210-
currentControllerType != .siriRemote {
209+
if !isConnected && currentControllerType != .siriRemote {
211210
isConnected = true
212211
controller = currentController
213212
controllerType = currentControllerType
214213

215-
logger.info("Did set controller \(currentController.productCategory) as main (first) controller.")
214+
logger.info(
215+
"Did set controller \(currentController.productCategory) as main (first) controller."
216+
)
216217
}
217218

218219
setupController(controller: currentController)

0 commit comments

Comments
 (0)