From 3178f8770791823555d8081590d052198e80bdc0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Oct 2014 22:08:40 -0400 Subject: [PATCH] Add support for the pause button --- Limelight/ControllerSupport.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Limelight/ControllerSupport.m b/Limelight/ControllerSupport.m index 7dd583f..c3d5234 100644 --- a/Limelight/ControllerSupport.m +++ b/Limelight/ControllerSupport.m @@ -26,6 +26,19 @@ static NSLock *controllerStreamLock; if (controller != NULL) { NSLog(@"Controller connected!"); + controller.controllerPausedHandler = ^(GCController *controller) { + // We call LiSendControllerEvent while holding a lock to prevent + // multiple simultaneous calls since this function isn't thread safe. + [controllerStreamLock lock]; + LiSendControllerEvent(PLAY_FLAG, 0, 0, 0, 0, 0, 0); + + // Pause for 100 ms + usleep(100 * 1000); + + LiSendControllerEvent(0, 0, 0, 0, 0, 0, 0); + [controllerStreamLock unlock]; + }; + if (controller.extendedGamepad != NULL) { controller.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element) { short buttonFlags;