GCMouse mouse-moved handler is never called on macOS Big Sur, but works on Monterey

Using the GameController framework to receive raw mouse-movement input does not work for me on an Intel Mac with Big Sur.

I can replicate it by simply creating a new Swift application in Xcode and modifying the AppDelegate like this:

func applicationDidFinishLaunching(_ aNotification: Notification)
{
    NotificationCenter.default.addObserver(forName: .GCMouseDidConnect, object: nil, queue: nil) { note in
        let mouse = note.object as? GCMouse
        mouse?.mouseInput?.mouseMovedHandler = { mouseInput, deltaX, deltaY in
            NSLog("%1.1f|%1.1f", deltaX, deltaY)
        }
    }
}

While the GCMouseDidConnect notification will be received, the mouseMovedHandler code will never be called on my Mac mini 2018 with macOS 11.6, but the same code will run perfectly fine on my Apple Silicon MacBook Pro with macOS 12.0.1.

I couldn't find anything about why this code won't work looking it up, the whole topic of mouse input via the GameController framework seems to be not much talked about.

Before filing a bug report I wanted to make sure that the problem isn't on my side. With code that simple, I just can't find anything I might be missing.

  • Hi doppelgamer.

    I created a macOS application project with your code snippet, but I am seeing the mouseMovedHandler called on the latest Monterey and on Big Sur 11.5. Is your test application foreground when the mouseMovedHandler isn't called? GCMouse (and GCKeyboard) only delivers events to the current foreground application.

    I think we need a bug report with your test Xcode project to investigate further. Before you submit the bug, please run your test app again and then capture a sysdiagnose to attach to the bug report. Thanks.

Add a Comment