plat/apple_mac_pad.rs (Apple)#
Source: lib/plat/apple_mac_pad.rs
apple_mac_pad -- (G7a part 2) game pads on macOS: GameController (the shared part: pad.rs)
start() -> bool an observer of GCControllerDidConnectNotification and
...DidDisconnectNotification, then the controllers there already
stop() every pad goes, the observer is removed
poll(now, focused, full) -> next the pads' extendedGamepad values (pad_update), once a second
(and with full) GCController.controllers against the slots: a
notification that never came still connects or disconnects
gc_test_pad(state) / gc_test_disconnect(slot) (tests) a controller of GameController's own
(controllerWithExtendedGamepad) with these values, through the
same paths as a real one
Only controllers with the extended gamepad profile count (Xbox, PlayStation, Switch Pro, MFi
pads); a Siri remote or a single Joy-Con (micro gamepad) does not. GameController names the
buttons by their places as the standard layout does (buttonA the bottom one); its sticks have up
positive (the layout: down). It hands input to the frontmost app only (shouldMonitorBackgroundEvents
stays off), as pad.rs wants it anyway. Everything on the main thread: the notifications come on
the main queue, inside the window loop's run loop, which a wake-up (wake_app) lets return.
fn gc_test_pad(st: &PadState) -> Option<(PadState, usize)>(test aid, plattest --test pad) a controller of GameController's own (+[GCController controllerWithExtendedGamepad], macOS 10.15) with the buttons and sticks ofstset on its elements (setValue:, setValueForXAxis:yAxis:), read back through the backend's mapping and connected through its path (watching or not) -> (what the mapping read, the slot); None: no such controller herefn gc_test_disconnect(slot: usize)(test aid) the test controller ofslotgoes through the backend's path (pad_disconnect)