Post

Replies

Boosts

Views

Activity

GCController.battery for PlayStation controllers
Hello- I am trying to monitor the battery level of my DualShock or DualSense controller, but I can't seem to get readings. Here is the code I'm using: ... @objc dynamic var myController: GCController? ... func handleControllerDidConnectNotification(_ notification: Notification) { for controller in GCController.controllers() { self.myController = controller self.myController!.addObserver(self, forKeyPath: "battery", options: [.new, .old, .initial, .prior], context: nil) } } override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { // Set breakpoint here } The observer gets an initial battery level, but it's nothing: - value : GCDeviceBattery - battery=0.0, state=-1 ...and no other updates get reported. Am I doing something wrong, or are PS controllers not supported for battery level and battery state?
1
0
610
May ’21