I am using the new GCMouse.mice() API on iPadOS 14.
My Bluetooth mouse (Logitech MX Master 2S) is clearly recognized, and I can navigate the OS and even my app with it. If I go to Settings → Accessibility → AssistiveTouch → Devices, my mouse is right there.
However, no matter at what point I call GCMouse.mice()
, the result is an empty list, and GCMouse.current
is always nil.
Similarly, I listen for GCMouseDidConnect
but it never fires.
To reproduce: I added this code to AppDelegate.swift
in the default project template.
import UIKit
import GameController // new
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// new:
@objc func showMice() { print(GCMouse.mice()) }
@objc func newMouse(notification: Notification) { print(notification) }
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// new:
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(showMice), userInfo: nil, repeats: true)
NotificationCenter.default.addObserver(self, selector: #selector(newMouse), name: NSNotification.Name.GCMouseDidConnect, object: nil)
return true
}
...
In the console I simply see:
2020-09-21 21:52:52.737457+0200 MouseTest[1639:1517093] Metal API Validation Enabled
[]
[]
[]
[]
[]
...
Is there something I'm missing? Is there maybe an entitlement I don't know about?